Lesson 18 of 19 · 18m
Cache Poisoning and Deception: The CDN's Memory Is Your Bug
Unkeyed headers turn shared caches into stored-XSS delivery — X-Forwarded-Host reflection, path-normalization mismatches that cache private pages as assets, and the cache-key fix.
Send X-Forwarded-Host: attacker.example to an app that echoes it into a password-reset link or an asset URL. The CDN keys the response on method and path, caches it, and serves your injected host to every visitor until the TTL dies. You sent one request. The cache does the distribution. That's web cache poisoning: stored XSS where the storage is infrastructure that looks trustworthy.
Cache keys versus everything else
The cache key is deliberately small: method, path, maybe a few nominated query params or headers. Every other byte of the request is unkeyed — and any unkeyed input that reaches the response is a payload you inject once and the CDN delivers many times.
The usual suspects are the forwarding headers. X-Forwarded-Host is the worst because frameworks consume it for absolute URL building — Rails, Laravel, and Django all have trusted proxies configuration that decides whose X-Forwarded-* gets believed. X-Forwarded-Scheme flips http/https in generated links. X-Original-URL and X-Rewrite-URL override the path entirely on some stacks — Drupal's exposure to that family was part of the research wave around SA-CORE-2018-005. Even User-Agent and Referer show up reflected in pages.
Unkeyed query parameters work the same way: ?utm_source= changes nothing for the origin but shows up reflected in a page, and if the edge treats it as unkeyed, everyone's cached copy carries it. Cloudflare and Fastly let you nominate which params join the key; the defaults are narrower than your app's parameter surface.
James Kettle's "Practical Web Cache Poisoning" (PortSwigger, 2018) walked through live sites serving reflected XSS off nothing but an unkeyed header and a shared cache. The technique also converts useless bugs — a self-XSS, a JSONP quirk — into stored attacks, because the cache holds the poisoned response for strangers.
Cache deception is the other half
Deception flips the disagreement: origin and edge disagree about what the request was, not what it contained. Request /account/nonexistent.css. If your router resolves the path to the account page and returns 200, but the CDN sees .css and treats the response as a cacheable static asset, private content is now parked on a public, shareable cache entry. Anyone who requests that URL gets the victim's page.
The whole class is path-normalization mismatch: trailing-slash rules, dot-segment handling (/a/../admin, %2e%2e), percent-decoding order. Two components decode the same bytes into different meanings. It belongs to the same family as request smuggling — disagreement, not malice — but the payoff is data theft instead of injection.
Two related shapes round out the audit. Fat GETs: a body on a GET request that the cache ignores when keying but the origin honors — parameters in the body are unkeyed by definition. And Vary: when a response legitimately differs by a header (Vary: User-Agent, Vary: Accept-Language), that header joins the key and each variant caches separately — set Vary deliberately, because a missing Vary means the wrong variant gets served to the next visitor.
What actually fixes it
Don't reflect headers into responses. The entire X-Forwarded-* family exists to be trusted only after you've pinned down which proxy wrote it: trusted proxies lists who may set those headers, and everything else must be ignored. When a header genuinely needs trusting, put it in the cache key — Varnish's vcl_hash, Cloudflare cache-key rules, nginx proxy_cache_key. A keyed input can't cross-pollinate between victims.
For deception: private pages get Cache-Control: private, no-store, and your router returns real 404s for /account/anything — deception only works if the origin over-resolves. Then align normalization: the same trailing-slash rule, the same dot-segment handling, the same decode order at edge and origin. Audit by requesting a private page as page.css, page.jpg, and page/../page and confirming nothing cacheable comes back.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Building a Production REST API With Node.js and Express
Build a REST API in Node.js and Express the way production systems need: input validation, JWT auth, refresh token rotation, status codes, rate limiting, idempotency keys, and centralized error handling.
Node.js Fixed 16 Flaws in One Release. Most of Them Live in HTTP/2 and TLS.
The November 11 Node.js security releases fix 16 CVEs across the 26, 24 and 22 lines, seven of them rated high. Nearly all sit in HTTP/2 and TLS, where a remote client can crash a server, leak memory, or get past per-host client-certificate checks.
Next.js Shipped Seven Advisories and Six of Them Are the Cache
The November 2026 Next.js security release patches seven issues, and six live in the new Cache Components layer, the feature meant to make your app faster by remembering more. Three hit self-hosted next start specifically: the ones Vercel's own platform quietly absorbs.
Forum Archaeology: Nulled vBulletin, XenForo, and the Missing Footer
I could spot a nulled forum in about four seconds, and it never stopped being funny. Here's why the copyright line gives it away, what a measured 97% of nulled add-ons actually contain, and why MyBB quietly became the smart choice for everyone who wanted the look without the paper trail.