# Web Cache Deception
> Getting a shared cache to store a victim's private, dynamic response under a URL the attacker can later request, because the cache judges the URL static while the origin serves the user's own data.
## How it works
- **Inverse of poisoning.** In [[Web Cache Poisoning]] the attacker's request shapes a response everyone gets. In deception the *victim* is lured into requesting a crafted URL, the origin answers with the victim's authenticated content, the cache stores it, and the attacker fetches the same URL from the cache ([[raw/tib3rius.com/web-appsec-interview-questions-5906|Tib3rius]], [[raw/cpebuddy.com/def-con-34-how-cache-poisoning-led-to-critical-account-takeover-in-tik-13785|DEF CON 34 TikTok]]).
- **Cacheability decided by URL shape, not content.** Caches are commonly configured to store anything that looks like a static asset (`.css`, `.js`, `.png`, `.jpg`, `.svg`) on the assumption that such files are public and carry no user data ([[raw/labs.detectify.com/10-types-of-web-vulnerabilities-that-are-often-missed-labs-detectify-1874|Detectify]], [[raw/nahamsec.com/top-vulnerabilities-for-pentest-bug-bounty-in-2025-4269|NahamSec]]). The cache never checks whether the body actually is static.
- **Path confusion between cache and origin.** The bug needs the two layers to read the same URL differently: the cache sees a static-looking path; the origin's router ignores or strips the trailing part and serves the dynamic page (e.g. an account page reached via a URL that ends in a static extension) ([[raw/labs.detectify.com/10-types-of-web-vulnerabilities-that-are-often-missed-labs-detectify-1874|Detectify]], [[raw/tib3rius.com/web-appsec-interview-questions-5906|Tib3rius]]).
- **Normalization differentials.** Beyond extensions, the layers can disagree on path normalization, delimiters and encodings. One write-up traces an ATO to a URL normalization discrepancy between an NGINX caching proxy (caching by extension) and an Express.js origin, which leaked private API tokens ([[raw/medium.com/how-a-cache-keys-mismatch-led-to-a-web-cache-deception-account-takeove-14688|Cache keys mismatch]]). WCVS groups the technique families as path parameters, path traversal toward a cacheable location (a `.css` file, a `/static` directory, `robots.txt`), and appended special characters, encoded and not ([[raw/github.com/hackmanit-web-cache-vulnerability-scanner-web-cache-vulnerability-scan-7155|WCVS]]). See [[URL Parser Differentials]].
- **Rule matching on paths.** CDN cache policies match path patterns (CloudFront's default key is domain + path; `/images/*` cached, `/api/*` not). If the origin moves sensitive routes (e.g. `/api/` to `/apiv2/`) the policy silently stops protecting them ([[raw/wiz.io/avoiding-security-incidents-due-to-request-collapsing-9595|Wiz]]). The same path-rule logic works in reverse: a small URL change that falls outside an Nginx cache rule bypassed a cached empty response ([[raw/logicbomb.medium.com/the-journey-of-web-cache-firewall-bypass-to-ssrf-to-aws-credentials-co-1993|Logicbomb]]).
- **Accidental deception.** Request collapsing on CloudFront can hand one user's response to concurrent requesters even with `Cache-Control: no-cache`, producing "logged in as someone else" incidents with no attacker involved ([[raw/wiz.io/avoiding-security-incidents-due-to-request-collapsing-9595|Wiz]]).
## What to check
- [ ] Inventory endpoints returning user-specific data: account/profile pages, API responses, token/session/billing views, auth flows ([[raw/nahamsec.com/top-vulnerabilities-for-pentest-bug-bounty-in-2025-4269|NahamSec]]).
- [ ] Identify the cache and its signals: `X-Cache`, `Age`, `Cache-Control`, `X-Proxy-Cache`; a sensitive page with `Age: 0` vs a static file with a growing `Age` ([[raw/labs.detectify.com/10-types-of-web-vulnerabilities-that-are-often-missed-labs-detectify-1874|Detectify]]).
- [ ] Does the origin still serve the dynamic page when the path is extended or decorated so it looks static? Does the cache then store it (MISS then HIT)?
- [ ] Review the cache configuration: is cacheability keyed on extension or directory rather than on origin headers and content type?
- [ ] Compare path normalization (decoding, delimiters, dot segments, trailing segments) between cache and origin framework.
- [ ] Check that the cached copy is reachable without the victim's cookies, i.e. the cookie is not in the key.
- [ ] Test with two accounts, sequentially **and** concurrently, to catch collapsing ([[raw/wiz.io/avoiding-security-incidents-due-to-request-collapsing-9595|Wiz]]).
- [ ] Check sensitive 302/404 responses in auth flows are not cacheable ([[raw/cpebuddy.com/def-con-34-how-cache-poisoning-led-to-critical-account-takeover-in-tik-13785|DEF CON 34 TikTok]]).
- [ ] Automate coverage with WCVS deception modules ([[raw/github.com/hackmanit-web-cache-vulnerability-scanner-web-cache-vulnerability-scan-7155|WCVS]]).
## Notable cases
- **ChatGPT (March 2023)** — Nagli reported a web cache deception ATO exposing chat history and billing information; OpenAI fixed it within hours ([[raw/nahamsec.com/top-vulnerabilities-for-pentest-bug-bounty-in-2025-4269|NahamSec]]).
- **NGINX + Express.js platform** — extension-based caching combined with a normalization mismatch cached victims' API tokens, leading to full ATO ([[raw/medium.com/how-a-cache-keys-mismatch-led-to-a-web-cache-deception-account-takeove-14688|Cache keys mismatch]]).
- **TikTok (DEF CON 34)** — three critical ATO reports from cache misconfiguration; a later bypass used path traversal to reach a cached 404 whose secondary header leaked OAuth codes ([[raw/cpebuddy.com/def-con-34-how-cache-poisoning-led-to-critical-account-takeover-in-tik-13785|DEF CON 34 TikTok]]).
- **Request collapsing incidents** — Wiz describes recurring "user sees another user's account" incidents on CloudFront despite `no-cache` ([[raw/wiz.io/avoiding-security-incidents-due-to-request-collapsing-9595|Wiz]]).
- Original research: Omer Gil (2017) and the USENIX Security 2020 path-confusion paper, both referenced by Detectify ([[raw/labs.detectify.com/10-types-of-web-vulnerabilities-that-are-often-missed-labs-detectify-1874|Detectify]]).
## Defenses
- **Mark private responses at the origin.** `Cache-Control: no-store` on anything with session or user data (`no-cache` still allows storage; `<meta http-equiv>` is not equivalent); `private` for user-specific responses so shared caches don't store them ([[raw/cheatsheetseries.owasp.org/owasp-session-management-cheat-sheet-3896|OWASP Session]], [[raw/cheatsheetseries.owasp.org/http-headers-6630|OWASP HTTP Headers]]).
- **Cache by origin intent and content type, not by URL extension.** Configure the CDN to honour origin headers, and cache only explicit static-asset routes.
- **Align routing and normalization.** The origin should reject or 404 unexpected trailing path segments instead of serving the parent page, and cache and origin should normalize paths the same way ([[raw/medium.com/how-a-cache-keys-mismatch-led-to-a-web-cache-deception-account-takeove-14688|Cache keys mismatch]], [[raw/labs.detectify.com/10-types-of-web-vulnerabilities-that-are-often-missed-labs-detectify-1874|Detectify]]).
- **CloudFront:** use the `CachingDisabled` managed policy for sensitive paths, or min TTL 0 *and* origin `no-cache` together, to avoid request collapsing ([[raw/wiz.io/avoiding-security-incidents-due-to-request-collapsing-9595|Wiz]]).
- **Keep cache policy and routes in sync** when APIs are renamed or versioned ([[raw/wiz.io/avoiding-security-incidents-due-to-request-collapsing-9595|Wiz]]).
- **Don't cache 302/404 on sensitive endpoints**, and fix the root cause instead of each reported instance ([[raw/cpebuddy.com/def-con-34-how-cache-poisoning-led-to-critical-account-takeover-in-tik-13785|DEF CON 34 TikTok]]).
- **On logout**, `Clear-Site-Data` clears browser caches (not shared caches) ([[raw/cheatsheetseries.owasp.org/owasp-session-management-cheat-sheet-3896|OWASP Session]]).
## Related
- [[Web Cache Poisoning]] — parent guide; the same key mismatch in the other direction.
- [[Unkeyed Inputs]] — the poisoning-side counterpart.
- [[URL Parser Differentials]], [[Account Takeover]], [[OAuth 2.0 Vulnerabilities]], [[HTTP Request Smuggling]].
## Sources
- [[raw/medium.com/how-a-cache-keys-mismatch-led-to-a-web-cache-deception-account-takeove-14688|How a Cache Keys Mismatch Led to a Web Cache Deception Account Takeover]]
- [[raw/tib3rius.com/web-appsec-interview-questions-5906|Web AppSec Interview Questions (Tib3rius)]]
- [[raw/labs.detectify.com/10-types-of-web-vulnerabilities-that-are-often-missed-labs-detectify-1874|10 Types of Web Vulnerabilities that are Often Missed (Detectify)]]
- [[raw/nahamsec.com/top-vulnerabilities-for-pentest-bug-bounty-in-2025-4269|Top Vulnerabilities for Pentest & Bug Bounty in 2025 (NahamSec)]]
- [[raw/cpebuddy.com/def-con-34-how-cache-poisoning-led-to-critical-account-takeover-in-tik-13785|DEF CON 34: How cache poisoning led to critical account takeover in TikTok's web]]
- [[raw/wiz.io/avoiding-security-incidents-due-to-request-collapsing-9595|Avoiding security incidents due to request collapsing (Wiz)]]
- [[raw/logicbomb.medium.com/the-journey-of-web-cache-firewall-bypass-to-ssrf-to-aws-credentials-co-1993|The journey of Web Cache + Firewall Bypass to SSRF to AWS Credentials compromise]]
- [[raw/github.com/hackmanit-web-cache-vulnerability-scanner-web-cache-vulnerability-scan-7155|Hackmanit Web Cache Vulnerability Scanner]]
- [[raw/cheatsheetseries.owasp.org/owasp-session-management-cheat-sheet-3896|OWASP Session Management Cheat Sheet]]
- [[raw/cheatsheetseries.owasp.org/http-headers-6630|OWASP HTTP Headers Cheat Sheet]]