How I Used Cache Poisoning to Bag a Bug Bounty
The application reflected the X-Forwarded-Host header into the page title and cached the response, allowing an attacker to poison the cache with a malicious hostname and later inject JavaScript. This could affect all visitors, potentially stealing cookies or redirecting to phishing pages.
medium.com
Published on medium.com
A few months ago, I was casually hunting for bugs late at night ☕🕵️♂️. I stumbled upon a target with a Content Delivery Network (CDN) in front of their app.
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 the X-Forwarded-Host header into the response without sanitisation and cached the response without varying on that header.
Impact
An attacker could poison the cache to serve malicious JavaScript to all visitors, potentially stealing cookies or tokens, or redirecting to phishing pages.
What the attacker needed
Cacheable response; reflected header; no authentication needed
The fix
The vulnerability was fixed by sanitising input, whitelisting headers, varying cache keys, and disabling caching for dynamic pages.
How it was found
- Send a request with a modified X-Forwarded-Host header and observe it reflected in the response.
- Load the page from another browser without cookies to confirm the poisoned content is served.
- Inject a JavaScript payload via the header and verify it executes in the cached page.
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 cache stores copies of web pages to make them load faster. If a page includes user-supplied information (like a header) without cleaning it, an attacker can trick the cache into storing a malicious version. Then everyone who visits gets the attacker's content, which can run harmful scripts.
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.