Note(Datetime, Name) : 2025-04-25 Web Cache Poisoning with multiple headers
Metodelogy
- Investigate the system to retrieve a list of features
- Discribe the feature and explain how it works
- List possible vulnerabilities and group by feature
- Proof of concept for possible vulnerabilities
- What is the impact of the vulnerabilities after the proof of concept ?
==========================================================================================================
feature:
- / -> got response -> indicated page is cache
HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 Set-Cookie: session=aRRl8oPADEsf9eyGaK69gY43XSY30squ; Secure; HttpOnly; SameSite=None X-Frame-Options: SAMEORIGIN Cache-Control: max-age=30 Age: 0 X-Cache: miss Connection: close Content-Length: 10914
```
steps taken:
- X-Forwarded-Host: evil.com -> normal response
- X-Forwarded-Scheme: http -> server redirected to the https version of the website
- use this payload -> page is redirected to the evil.com and website is cached by server
X-Forwarded-Host: evil.com
X-Forwarded-Scheme: http
vulnerabilities :
- web cache poisioning by use header
X-Forwarded-Host: evil.com
X-Forwarded-Scheme: http
Proof of concept:
- send payload to / -> and got redirected to evil.com -> cached
X-Forwarded-Host: evil.com
X-Forwarded-Scheme: http
- Locate the file /resource/tracker.js and confirm that it is cacheable.
- Apply this payload and send a request to
/resource/tracker.js. Make sure the tracker.js file is cached by the server:
X-Forwarded-Host: <yourdomain>
X-Forwarded-Scheme: http
- after the response is cached , any page that includes tracker.js will fetch it from
/resource/tracker.js due to the redirect.
impact
1.An attacker can poison the cache and cause browsers to load a malicious tracker.js file.
2.This can lead to the execution of arbitrary JavaScript on victim pages, resulting in:
- Stolen credentials
- Session hijacking
- Full client-side takeover (depending on script capabilities)
takeaways
1.Always validate and sanitize any input headers, especially X-Forwarded-*.
2.Ensure cache keys include all relevant headers to prevent cache poisoning.
3.Avoid caching responses that include user-controllable input (even in headers).