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 (Tib3rius, 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 (Detectify, 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) (Detectify, 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 (Cache keys mismatch). WCVS groups the technique families as path parameters, path traversal toward a cacheable location (a
.cssfile, a/staticdirectory,robots.txt), and appended special characters, encoded and not (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 (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 (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 (Wiz).
What to check
- Inventory endpoints returning user-specific data: account/profile pages, API responses, token/session/billing views, auth flows (NahamSec).
- Identify the cache and its signals:
X-Cache,Age,Cache-Control,X-Proxy-Cache; a sensitive page withAge: 0vs a static file with a growingAge(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 (Wiz).
- Check sensitive 302/404 responses in auth flows are not cacheable (DEF CON 34 TikTok).
- Automate coverage with WCVS deception modules (WCVS).
Notable cases
- ChatGPT (March 2023) — Nagli reported a web cache deception ATO exposing chat history and billing information; OpenAI fixed it within hours (NahamSec).
- NGINX + Express.js platform — extension-based caching combined with a normalization mismatch cached victims’ API tokens, leading to full ATO (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 (DEF CON 34 TikTok).
- GraphQL API behind Cloudflare — the user-data query was sent as
POST /api/graphql(CF-Cache-Status: DYNAMIC), but the server also executed it as GET./api/graphql/test.css?query=…failed, while the;path-parameter form/api/graphql;test.css?query=…still reached the GraphQL handler and returnedCF-Cache-Status: HIT, so a user-specific response was stored in the shared cache. GET execution of a POST-only API widens the deception surface (0x_karim; GraphQL Security). - Request collapsing incidents — Wiz describes recurring “user sees another user’s account” incidents on CloudFront despite
no-cache(Wiz). - Original research: Omer Gil (2017) and the USENIX Security 2020 path-confusion paper, both referenced by Detectify (Detectify).
Defenses
- Mark private responses at the origin.
Cache-Control: no-storeon anything with session or user data (no-cachestill allows storage;<meta http-equiv>is not equivalent);privatefor user-specific responses so shared caches don’t store them (OWASP Session, 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 (Cache keys mismatch, Detectify).
- CloudFront: use the
CachingDisabledmanaged policy for sensitive paths, or min TTL 0 and originno-cachetogether, to avoid request collapsing (Wiz). - Keep cache policy and routes in sync when APIs are renamed or versioned (Wiz).
- Don’t cache 302/404 on sensitive endpoints, and fix the root cause instead of each reported instance (DEF CON 34 TikTok).
- On logout,
Clear-Site-Dataclears browser caches (not shared caches) (OWASP Session).
Related
- Web Cache Poisoning — parent guide; the same key mismatch in the other direction.
- Unkeyed Inputs — the poisoning-side counterpart.
- GraphQL Security — GET-executable GraphQL endpoints as deception targets.
- URL Parser Differentials, Account Takeover, OAuth 2.0 Vulnerabilities, HTTP Request Smuggling.
Sources
- How a Cache Keys Mismatch Led to a Web Cache Deception Account Takeover · original
- Web AppSec Interview Questions (Tib3rius) · original
- 10 Types of Web Vulnerabilities that are Often Missed (Detectify) · original
- Top Vulnerabilities for Pentest & Bug Bounty in 2025 (NahamSec) · original
- DEF CON 34: How cache poisoning led to critical account takeover in TikTok's web · original
- Avoiding security incidents due to request collapsing (Wiz) · original
- The journey of Web Cache + Firewall Bypass to SSRF to AWS Credentials compromise · original
- Hackmanit Web Cache Vulnerability Scanner · original
- OWASP Session Management Cheat Sheet · original
- OWASP HTTP Headers Cheat Sheet · original
- When GraphQL Meets Web Cache Deception · original