Internal Cache Poisoning: How Multi-Layer Caches Can Be Exploited for Stored XSS
The web cache poisoning flaw arises because an internal fragment cache does not include the X-Forwarded-Host header in its cache key, allowing an attacker to inject a malicious domain into cached JavaScript references. This causes victims visiting the home page to load an attacker-hosted script, resulting in stored cross-site scripting.
osintteam.blog
Published on osintteam.blog
This lab demonstrates a web cache poisoning flaw where multiple caching layers (an external cache and an internal fragment cache) treat different parts of an HTTP request inconsistently when building their cache keys.
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 internal fragment cache builds its cache key without including the X-Forwarded-Host header, so responses that reflect that header are cached and served to other users.
Impact
The cached malicious script is served to many users without further interaction, enabling cookie theft, account takeover, credential harvesting, and persistent drive-by malware delivery.
What the attacker needed
Access to the lab environment; ability to send crafted HTTP requests; victim visits the home page
How it was found
- Open the cache-poisoning lab and send the GET / request to Repeater.
- Add a cachebuster parameter and observe that it is reflected and part of the external cache key.
- Remove the cachebuster parameter and run Param Miner's Guess headers to find the X-Forwarded-Host header.
- Test with evil.com and confirm the domain is reflected in the response.
- Send crafted requests until all three HTML components (canonical link, analytics.js, geolocate.js) are overridden by the malicious domain.
- Point X-Forwarded-Host to the exploit server, keep sending requests until components are overridden, then refresh the lab to trigger the XSS popup.
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 is like a storage box that keeps copies of web pages to load them faster. Here, the box ignored a special header that told the website which domain to use for scripts, so an attacker could trick the box into storing a page that loads a malicious script. When other people visit the site, their browsers run that script, which can steal their cookies.
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.