Web Cache Poisoning
Web cache poisoning lets you store a malicious response in a cache that gets served to other users. When a CDN or caching proxy serves your poisoned response to thousands of users, the impact multiplies significantly.
How Caching Works
Caches store responses keyed by some subset of request attributes (URL, Host, some headers). If a request matches the cache key, the cached response is returned instead of forwarding to the origin. Unkeyed inputs — headers or parameters that affect the response but aren’t part of the cache key — are the attack surface.
Identifying Cache Behavior
|
Cache buster
When testing, add a unique parameter to avoid poisoning the real cache:
|
Unkeyed Header Injection
X-Forwarded-Host
If the app uses X-Forwarded-Host to generate absolute URLs and the cache doesn’t include it in the key:
|
If the response generates links like https://attacker.com/static/app.js and this gets cached, all subsequent visitors loading the cached response will fetch JavaScript from your server.
X-Forwarded-Scheme / X-Forwarded-Proto
|
May cause the server to generate an HTTP redirect → redirect gets cached → DoS or redirect to attacker.
X-Original-URL / X-Rewrite-URL
|
If the cache uses the path / as key but the server responds to /admin content, you poison / with admin content.
Poisoning with XSS
If an unkeyed header is reflected in the response:
|
If this gets cached and served to other users, the XSS fires for every visitor.
Fat GET Requests
Some caches key on URL but pass the full request (including body) to the origin. If the origin processes GET body:
|
Parameter Cloaking
Cache keys often strip certain parameters. The origin sees them, but they’re not in the cache key.
|
If utm_source is reflected and unkeyed, the poisoned response is cached against the key /page?a=1.
Cache Key Normalization Differences
Exploiting how the cache and origin differ in normalizing cache keys:
|
Web Cache Deception
Different from poisoning. Trick users into making their browser cache sensitive resources.
|
CDN-Specific Techniques
Cloudflare
|
Varnish
|
Tools
|
Cache Poisoning DoS
|
Remediation
- Include all request inputs that affect the response in the cache key (
Varyheader). - Use cache-busting parameters for dynamic responses.
- Strip or ignore security-sensitive unkeyed headers at the reverse proxy level.
- Mark responses containing user-specific data with
Cache-Control: no-store. - Configure CDN to never cache HTML from authenticated endpoints.
Discussion
Leave a comment · All fields required · No spam
No comments yet. Be the first.