How I (Accidentally) Poisoned a Cache with Just the Host Header
The web application reflected the Host header into asset URLs and cached the response, so an attacker could poison the cache with a malicious host. This could lead to XSS, redirects, or broken assets for other users.
medium.com
Published on medium.com
So, I was casually poking around Inzpire’s web app (as one does when you’ve had too much coffee and not enough sleep), and I stumbled upon a neat little trick: Web Cache Poisoning via the Host header.
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 server reflected the Host header into asset URLs without validation and the cache stored the response without considering the Host header.
Impact
An attacker could poison the cache to serve malicious JavaScript (XSS), redirect users to phishing sites, or cause denial of service by breaking assets.
What the attacker needed
Ability to send requests with custom Host header; cache stores responses keyed without Host header
The fix
The application should validate the Host header against an allowlist, avoid caching responses that include user-controlled data, and configure the CDN or reverse proxy to not cache based on untrusted headers.
How it was found
- Send a request with a modified Host header containing a random port.
- Observe that the server reflects the injected host/port in asset URLs.
- Send a normal request with the correct Host header.
- Observe that the poisoned response is still served from the cache.
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 a page includes a value from the request (like the Host header) and that page is cached, an attacker can make the cache store a version with their own value, which is then shown to other visitors.
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.