Cache Poisoning: From Cache Hits to Bounty
The application reflected the value of the X-Forwarded-For header into its response, and that response was cached by CloudFront. An attacker could poison the cache so that other visitors received the malicious script and had it executed in their browsers.
medium.com
Published on medium.com
Most of the time, it starts with casually browsing a website and paying attention to tiny behavioral differences. Over time, I realized that cache poisoning bugs hunting don’t start with complicated exploitation chains.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application reflected an untrusted HTTP header (X-Forwarded-For) into the response without sanitisation, and the CDN cached that response without varying on the header.
Impact
An attacker could poison the CDN cache with malicious JavaScript that executes in the browsers of other users visiting the affected page, potentially hijacking sessions, stealing tokens, or performing actions on behalf of victims.
What the attacker needed
Target uses a CDN that caches responses; application reflects X-Forwarded-For header; attacker can send requests to the target
How it was found
- Open Burp Suite and enable Intercept.
- Browse to the target application's homepage, which is served from the cache.
- Capture the request in Burp Suite.
- Send the intercepted request to Repeater.
- Add an X-Forwarded-For header containing a script payload.
- Send the request repeatedly until the response contains a cache hit from CloudFront.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A web cache is a storage layer that keeps copies of responses so the server does not have to rebuild them for every visitor. If an attacker can make the server include malicious content in a response before it is cached, that poisoned copy is then served to everyone else. Here, the server copied a value from a request header into the page, and the cache stored that page, so other users got the attacker's script.
What is Cache bugs?
A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.