Web Cache Poisoning via Ambiguous Requests Lead to XSS
The web cache and back-end server handle duplicate Host headers inconsistently, allowing an attacker to poison the cache with a response that loads JavaScript from an attacker-controlled domain. This stored XSS executes in victims' browsers and can steal session cookies.
medium.com
Published on medium.com
This lab, as referenced from PortSwigger’s resource, highlights a web cache poisoning vulnerability that stems from inconsistent handling of ambiguous HTTP requests between the cache layer (e.g., CDN or reverse proxy) and the back-end server.
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 cache and origin server interpret duplicate Host headers differently, so the cache stores a response generated for the attacker's Host value.
Impact
The attacker's JavaScript is stored in the cache and executed by other users, leading to stored XSS and potential session hijacking via stolen cookies.
What the attacker needed
Access to the lab environment; ability to send custom HTTP requests
How it was found
- Find the home page request and note the X-Cache header (miss or hit).
- Send the request to Repeater and add a cachebuster parameter to the URL.
- Send the request twice to confirm caching (X-Cache: hit).
- Add a second Host header with an attacker domain and observe reflection in the HTML.
- Remove the second Host header and resend; if the page still loads from the attacker domain, the cache is poisoned.
- Create an exploit server payload that executes JavaScript, then send a request with the exploit server as the second Host header.
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 stores copies of pages to serve them faster. If the cache and the real server disagree about which website address (Host header) was requested, an attacker can trick the cache into storing a malicious page. That page then runs harmful JavaScript in every visitor's browser.
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.