[Fix] Cache Poisoning vulnerability #210
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Vulnerability:
The report identifies CVE-2023-46298, described as a Cache Poisoning and potential Denial of Service (DoS) flaw in Next.js versions before 13.4.20-canary.13.
Cause:
The core issue is, as the report states, the lack of a Cache-Control header in empty prefetch responses. This flaw allows a Content Delivery Network (CDN) to cache an empty response, which then gets served to all subsequent users requesting the same resource.
Impact:
The stated impact—that an attacker can cause other users to be unable to access the website—is consistent with the known Denial of Service (DoS) consequence of this cache poisoning vulnerability. The cached empty response effectively locks out legitimate users until the cache expires.
Severity:
The classification of the severity as High is consistent with advisories from several security firms (e.g., Wiz states a CVSS v3.1 base score of 7.5).
POC:
Phase 1: Cache Poisoning
This request will use the unique query parameter and the X-Middleware-Prefetch: 1 header to induce a vulnerable Next.js server to return an empty response without a restrictive Cache-Control header. The CDN may then cache this empty response, poisoned to the unique query parameter's path.
Target:
https://plugin.jup.ag/Poisoning Endpoint: /?poison_test=12345(using a unique string for the test)Expected Result (on the first request):
Phase 2: Verification
This request attempts to access the same unique URL again to determine if the empty response from Phase 1 was successfully cached by the CDN.
Re-use the same URL to test the cache
VERIFICATION_URL="https://${TARGET_HOST}/?${CACHE_BUSTER}"
Successful Exploitation Indication:
If the attack is successful, the CDN will serve the empty response from its cache, showing the impact of the cache poisoning.