Cache Poisoning for XSS Delivery
You'll learn how attackers weaponize cache poisoning to deliver XSS payloads to every user who requests a poisoned resource.
The Core Idea
Cache poisoning for XSS delivery combines two powerful attack vectors into one devastating technique. Instead of targeting a single victim with XSS, an attacker poisons the web cache to persistently serve malicious JavaScript to everyone who requests the cached resource—until the cache expires or is purged.
Think of it like poisoning a town's water tower instead of poisoning individual glasses. Everyone who drinks from that source gets poisoned automatically.
How It Works
Attackers exploit unkeyed input (headers or parameters the cache ignores) to inject malicious payloads into the cached response. When successful:
- The attacker crafts a request with an XSS payload in an unkeyed input
- The server reflects this payload into the response (vulnerable to XSS)
- The cache stores the poisoned response based only on keyed inputs
- All subsequent users receive the cached, malicious response
- The XSS executes in every victim's browser
Example scenario:
An attacker finds the X-Forwarded-Host header is unkeyed but reflected in page links. They send:
GET /home HTTP/1.1
Host: victim.com
X-Forwarded-Host: evil.com"><script>/* malicious code */</script>
If the response gets cached and includes the malicious script, every user visiting /home now executes the attacker's JavaScript—without any further action from the attacker.
Why This Is Dangerous
- Massive scale: One poisoned request affects all users
- Persistence: Lasts until cache expiration
- Stealth: Victims request legitimate URLs
- Amplification: Combines web cache poisoning with XSS impact
Key Takeaway: Cache poisoning for XSS delivery transforms a single-victim XSS vulnerability into a mass-exploitation vector by weaponizing the web cache to persistently distribute malicious payloads to all users requesting the poisoned resource.