The scanner says the response is cacheable and reflects an unkeyed header. Did the cache store it for someone else? Web cache poisoning and web cache deception as DAST findings: cache keys and unkeyed inputs, what Age, X-Cache, Cache-Control and Vary do and do not prove, poison-then-fetch confirmation, path confusion, and the fixes

DedSec Security Research ·

Here is a hypothetical. A dynamic scan of a marketing site and its customer portal, both behind the same caching layer, returns three results.

The first is titled "Web cache poisoning (unkeyed header)" and rated high, on the home page. The scanner sent X-Forwarded-Host with a hostname it controls, the hostname came back inside a <script src>, and the response carried Cache-Control: public, max-age=300 and a header saying MISS. The second is a low, "Cacheable response reflects input", on a landing page: a utm_content value the scanner sent came back inside a link. The third is not a finding at all. The scanner fetched /account, saw Cache-Control: private, and moved on, so the portal is recorded as clean for caching issues.

The high gets escalated, the low is filed as informational, and the clean result goes into the report. As in the earlier posts in this series, each call rests on the title and the rating rather than on what the scanner observed and what that observation can prove. The high may be a reflection that the cache never shared with anyone. The low may be the real poisoning, because the parameter the scanner changed may not be part of the cache key. The clean portal may be the worst of the three, because whether a private page ends up in a shared cache depends on the cache's rules about paths, not on the header the page sends.

This post is for whoever is holding a cache poisoning finding from a dynamic scan, or a clean result on an authenticated area behind a cache. It covers:

It belongs to our series on confirming DAST findings. The series guide sets out the evidence classes the series uses, and lists this post as number 23. The evidence here is the guide's last class, an effect seen by a second party, where the second party is a client that never sent the attack. The Host header post already showed one round of X-Forwarded-Host poisoning through nginx. This post starts from that result and covers the rest of the cache key. The CRLF post and the request smuggling post each reach cache poisoning by another route, and the reflected XSS post covers what a reflected value can do once a browser parses it.

How we tested. Everything ran on 18 November 2026 on a virtual machine with two vCPUs, Ubuntu 24.04.4 and kernel 6.8.0. The origin is a deliberately vulnerable application we wrote on Python 3.12.3, using only the standard library's http.server. It builds a script URL from X-Forwarded-Host, redirects to HTTPS when X-Forwarded-Scheme says http, reflects query parameters into a landing page, and serves a logged-in "account" page that contains a fake API key. Every response it generates carries an X-Origin-Serial header, a counter that increases on each response, so a client can tell exactly which origin response it received. In front of it ran nginx 1.24.0, the Ubuntu package, as an unprivileged process with proxy_cache and nine server blocks. Each block is one cache configuration, and they are described where they come up. One block terminated TLS with a self-signed certificate made with OpenSSL 3.0.13. Everything listened on 127.0.0.1 only.

The client was a Python harness built on http.client, so we controlled every header and could send a body with a GET. Each test ran 20 trials, each with its own random cache-buster, and each trial sent the attack request and then a clean request with no attack header and no cookie, on a new connection. The run made 1,555 requests in all. The scripts, the nginx configuration and one JSON line per request are archived with the lab.

This lab models one cache, nginx, configured the ways shown. It is not a CDN, and nothing in it describes how any CDN or commercial cache keys requests, normalises paths or treats headers. Those are configuration and product questions, and the answer is in your cache's documentation. Statements about RFC 9111 (HTTP caching), RFC 9110 (HTTP semantics) and RFC 9211 (the Cache-Status header), and about published research, describe their content in our own words. We had no copy of the RFCs on the machine to quote from. No number here measures any scanner, ours included.

What a cache key is

A shared cache stores a response and serves it again to later requests that it considers equivalent. The cache key is the rule for "equivalent". RFC 9111 says the key consists, at a minimum, of the request method and the target URI. RFC 9111 notes that many caches store only GET responses and so key on the URI, plus whatever their configuration adds or removes. nginx's documented default key is $scheme$proxy_host$request_uri: the scheme, the name of the upstream (not the client's Host header) and the path with its query string.

The key has a second part. A response can carry Vary, which names request headers that also have to match. Under RFC 9111, a cache may serve a stored response only to a request whose values for those headers match the request that produced it. Vary: Accept-Language means "this response is only correct for requests with this Accept-Language value".

Everything in the request that is outside the key is unkeyed. Most of a request is unkeyed: almost every header, the body, and often parts of the query string, since many caches can be configured to ignore some parameters or to key on an allow-list. Being unkeyed is normal and harmless while the response does not depend on the input. Poisoning starts when it does:

All three have to be true. A scanner that sees the first one has seen a third of the bug.

The unkeyed inputs, measured

The first nginx block honoured the origin's Cache-Control and used the default key. The second used a key built from an allow-list of query parameters, cb, page and lang, which models a cache configured to ignore tracking parameters. Each row is 20 trials. "Clean client got the payload" means the follow-up request, which carried no attack input, received the attacker's value.

InputWhere the attack put itAttack responseClean client got the payloadClean response had the attack's origin serial
X-Forwarded-HostheaderMISS, canary in <script src>20 of 20, HIT20 of 20
X-Forwarded-Scheme: httpheaderMISS, 301 to https://20 of 20 got the cached 30120 of 20
X-Forwarded-Scheme and X-Forwarded-HostheadersMISS, 301 to the canary host20 of 20, HIT20 of 20
utm_contentunkeyed query parameterMISS, canary in a link20 of 20, HIT20 of 20
lang behind a semicolonutm_content=x;lang=…MISS, canary in a script path20 of 20, HIT20 of 20
lang duplicatedlang=en&lang=…MISS, canary in a script path20 of 20, HIT20 of 20
lang in a GET bodyrequest bodyMISS, canary in a script path20 of 20, HIT20 of 20

Forwarding headers. X-Forwarded-Host and X-Forwarded-Scheme are conventions, not standards. A proxy adds them to tell the application the original host and scheme. Nothing stops a client from sending them too, and nginx's proxy_pass passes client headers through unless it is told to replace them. The scheme case needs no reflected value at all. The origin's "redirect HTTP to HTTPS" logic fired on the attacker's header, the 301 was cacheable, and every clean client then got a redirect instead of the page. Combined with X-Forwarded-Host, the cached redirect pointed at the attacker's host. The same pattern with an error page, an unkeyed header that makes the origin answer with an error that then gets cached, was published as cache-poisoned denial of service by Nguyen, Lo Iacono and Federrath in 2019. Header-based poisoning in general was laid out by James Kettle of PortSwigger in "Practical Web Cache Poisoning" in 2018.

Unkeyed query parameters. A cache that ignores tracking parameters to improve its hit rate makes those parameters unkeyed. If the page reflects one, the reflection is shared. This is the hypothetical low, and it is a stronger result than the high: a link to the page carrying the parameter is something an attacker can get the cache to store with one request.

Parameter cloaking and duplicate parameters. These need no unkeyed parameter, because they exploit a disagreement about which parameters a request has. In our toy, the origin's parser treated ; as a separator, as Python's own urllib.parse did before a 2021 security fix (CVE-2021-23336). nginx splits only on &. So utm_content=x;lang=PAYLOAD was one ignored parameter to the cache and a lang value to the origin. For duplicates, the key used the first lang, because the clean request with lang=en hit the entry created by lang=en&lang=PAYLOAD. The origin used the last one. Which value a component takes from a duplicated parameter varies by language and framework, so the test is to try both orders, not to assume. Kettle's 2020 follow-up, "Web Cache Entanglement", described parameter cloaking and the next item as poisoning vectors.

Fat GET. A GET with a body. nginx forwarded the body, our origin merged body parameters into the query, as some frameworks do, and the cache keyed only on the URL. Whether a given cache forwards a GET body, and whether a given framework reads one, are both things to check rather than assume.

Why a reflection in one response is not poisoning

The same X-Forwarded-Host canary, reflected the same way by the same origin, did not reach a clean client in three configurations:

Origin responseAttack responseClean client
Cache-Control: no-storeMISS, canary presentMISS, no canary, new origin serial, 20 of 20
Cache-Control: private, max-age=60MISS, canary presentMISS, no canary, new origin serial, 20 of 20
public, max-age=60 with Vary: X-Forwarded-HostMISS, canary presentMISS, no canary, 20 of 20
control: public, max-age=60, never attackedn/aMISS, no canary, 20 of 20

The Vary row is the important one for triage. The attack was cached. Repeating the attack request returned a HIT with the canary in all 20 trials. But it was cached only under the variant keyed by the attacker's header value, so the only client who could receive it was one who sent the same header, which is the attacker. A scanner that sends the attack twice and sees a HIT has proved that its own variant is cached, and nothing more. That may be what the hypothetical high is.

So a scanner's poisoning finding built from "the input was reflected" plus "the response looks cacheable" is a hypothesis. It is worth having, because it tells you where to look. What it lacks is the third condition, a client that did not send the input receiving the response.

What the headers do and do not prove

Cache-related response headers are where most mis-triage of this class starts. Here is what each one can carry.

Cache-Control is the origin's instruction, not the cache's behaviour. It tells caches what the origin wants. A cache configured to override it will. Our extension-based cache block, described in the deception section, ignored Cache-Control: private, no-store by configuration and stored the page anyway. And a response with no Cache-Control at all is not necessarily uncacheable: RFC 9111 lets a cache assign a heuristic freshness lifetime to a response that has no explicit expiry if its status code is one RFC 9110 defines as heuristically cacheable, a list that includes 200, 301 and 404.

Vary changes the key, and only for caches that honour it. RFC 9111 tells caches what Vary means, but caches differ in how fully they implement it, and some configurations strip or ignore it. A Vary header in the response tells you the origin's intent. The clean-client test tells you the cache's behaviour.

Age is not reliable in either direction. RFC 9111 describes Age as the sender's estimate of how long ago the response was generated or validated at the origin. Its presence suggests the response came from a cache, but its absence does not prove the origin was contacted. In our lab, nginx sent no Age header on any of the 1,555 responses, including every HIT. A tester who reads "no Age header" as "not cached" would have cleared every poisoned entry in the tables above.

Cache-status headers are whatever the cache operator decided they are. X-Cache, X-Cache-Status, CF-Cache-Status and similar headers are vendor- or configuration-specific, and each value means what that product's documentation says it means. The one in our results exists because we added it: nginx exposes the cache result as a variable, $upstream_cache_status, and we put it in a header. Two of its values in our data show the traps.

RFC 9211 defines a standard Cache-Status response header that caches can use to report hits, misses and why they forwarded a request. Where a cache emits it, it is more precise than ad hoc headers, but it still reports what the cache did with this request, not who will receive the stored copy next.

None of these headers can confirm poisoning. They help you read the result of the test that can.

Confirming cache poisoning

The confirmation is two requests and a comparison. The care goes into making sure the two requests share a key that nobody else uses.

  1. Choose a cache-buster that is in the key. Usually a query parameter with a random value, sometimes a path segment. It isolates your test entry from the one real users get.
  2. Prove the buster is keyed. Send two otherwise identical clean requests with different buster values. Both should be MISS. If the second is a HIT, the buster is not in the key, and your "isolated" test is writing to the key real users share. In our allow-list cache, a buster placed in an unkeyed parameter (utm_x) failed this check in 20 of 20 trials: the second request, with a different utm_x, was a HIT carrying the first request's origin serial. A tester who skipped the check would have poisoned the shared entry on their first attack.
  3. Send the attack once, with the buster and a unique canary. Record the response and whether it was a MISS. If it was a HIT, someone else's entry answered, and you have learned nothing.
  4. Fetch the same URL from a clean client. Use a new connection, without the attack input, without your cookies, and ideally from a different network vantage point if the cache has several. Send it within the response's freshness lifetime.
  5. Look for a HIT that carries the canary, and confirm it is the attack's response: the same canary, the same body, and an origin identifier if the application has one.
  6. Check the lifetime. In our short-lived variant, max-age=3, a clean fetch straight after the attack got the canary in 5 of 5 trials, and a clean fetch four seconds later was a fresh origin response labelled EXPIRED, with no canary, in 5 of 5. By mechanism, a poisoned entry lasts as long as its freshness lifetime, and an attacker can re-poison it as soon as it expires. The TTL bounds one poisoning, not the exposure.

What to record:

That last item sets severity. A poisoned <script src> runs the attacker's code for every visitor to that key, which is stored cross-site scripting delivered by the cache. A poisoned redirect or error page takes the page away from everyone. A poisoned piece of text that is HTML-escaped and never becomes a URL or markup is a content-spoofing issue at most. The open redirect post and the XSS post cover how to judge the last step.

Web cache deception

Web cache deception uses the same machinery for a different purpose. Poisoning gets the cache to store the attacker's response for the victim. Deception gets the cache to store the victim's response for the attacker. It was described publicly by Omer Gil in 2017. Martin Doyhenart's 2024 PortSwigger research, "Gotta cache 'em all", extended it to delimiter and normalisation discrepancies between caches and origins.

The mechanism:

  1. The cache has a rule that says, in effect, "this looks static, store it", usually based on a file extension or a path prefix, and often configured to ignore the origin's Cache-Control for static content.
  2. The origin maps a path that matches that rule to a dynamic, authenticated page. It might ignore trailing path segments, strip ; parameters, or decode or normalise the path differently from the cache.
  3. The attacker gets the victim to request that path while logged in: a link, an image tag, a redirect.
  4. The cache stores the victim's personal page under a key the attacker knows, and the attacker fetches it.

Our deception block cached any path ending in .css, .js or a few image and font extensions, ignored the origin's Cache-Control, Expires and Set-Cookie there, and cached 200 responses for ten minutes. Everything else passed through uncached. The origin's account page returned Cache-Control: private, no-store. Each trial sent the victim's request with a session cookie, then the attacker's request with no cookie:

PathWhat the origin didAttacker received the victim's API key
/account?cb=… (control)account page, not in a cached location0 of 20, got "Please log in"
/account/RANDOM.cssignored the trailing segment, served the account page20 of 20, HIT
/account;RANDOM.cssstripped the ; parameter, served the account page20 of 20, HIT
/account%2FRANDOM.cssdid not decode %2F, answered 4040 of 20; the 404 was not cached
/static/..%2Faccount and /static/../account on a /static/ prefix ruleanswered as a static file0 of 20

The last two rows are the instructive negatives. On the prefix rule, nginx normalised the path before matching its locations, so it treated the request as /account and did not use the caching location. Our toy origin did not normalise. It received a path that still began with /static/, and served the stylesheet. Deception needs the opposite pairing: a cache that sees a static-looking path and an origin that resolves the same bytes to the private page. Our pairing had the disagreement the wrong way round, and the result says nothing about a pairing where it runs the other way. That is why deception testing means trying several delimiters and encodings, not one.

Two contrasts with poisoning matter for triage:

Testing safely

Poisoning and deception tests both write to a cache other people read. General practice follows:

A scanner that sends poisoning payloads without a verified buster takes the same risk as a person doing it, and needs the same scoping.

Fixes, and what they cost

Each fix below was run as its own nginx block or origin variant, with 20 trials per row.

FixMeasured result
Add the forwarding headers to the cache keyX-Forwarded-Host and redirect attacks: clean client MISS, no canary, 20 of 20 each
Proxy overwrites X-Forwarded-Host and X-Forwarded-Scheme with its own values, behind TLSAttack response already clean, no redirect; clean client HIT on a clean entry, 20 of 20
The same overwrite on a plain-HTTP front endNo canary, but the attack got a 301 to https:// and the clean client got that cached 301, 20 of 20. Because the proxy set X-Forwarded-Scheme to its own scheme, http, the origin would redirect any request on that route
Extension rule that honours the origin's Cache-ControlDeception: attacker got "Please log in", 0 of 20 leaks
Origin with strict routing (404 for /account/anything)Deception: 404, 0 of 20 leaks

Stop trusting the input, or key it. The better fix for forwarding headers is the overwrite. The proxy sets X-Forwarded-Host and X-Forwarded-Scheme from what it knows, so a client's values never reach the origin, and the application builds absolute URLs from configuration, as the Host header post recommends. The plain-HTTP row is a lab artefact, and a warning at the same time: an overwritten header is only correct if the proxy's value is true, and a proxy that does not terminate TLS will truthfully report http. Keying the header also stops cross-user delivery, but it keeps the origin trusting a client-controlled value and splits the cache by it.

Vary has a cost. In a separate test, we sent ten distinct User-Agent values to the same URL, each five times, and repeated that on 5 fresh URLs. With Vary: User-Agent, the cache made 50 origin fetches for 250 requests, one per user agent per URL. Without it, it made 5. Real user-agent strings are far more varied than ten. Varying on a header with many values multiplies origin load and divides the hit rate, which is why the narrower fix, overwriting or dropping the header at the proxy, is usually better than Vary on it.

Authenticated responses say private or no-store, and the cache honours it. The origin header is necessary but not sufficient. Our deception leaked through a no-store header because the cache rule ignored it. A cache rule that overrides origin headers should be scoped to paths that are genuinely static: a dedicated prefix served from a static file store, not "anything ending in .css".

Make the cache and the origin agree on what a path and a query string are. Strict routing at the origin, so /account/x.css and /account;x.css are 404s rather than the account page, closed both deception paths in our toy. On the query side, keying on an allow-list of parameters is only safe if the origin ignores every parameter outside the list, and parses ;, duplicates and request bodies the same way the cache does.

Do not cache what you cannot key. If a response depends on something the cache cannot or will not key on, mark it uncacheable. That costs hit rate on that page, which is cheaper than the alternative.

The static side

Code review can find the origin half of both bugs, and infrastructure review can find the cache half. Neither half alone is a vulnerability, which is why they get missed.

On the origin side, look for code that reads X-Forwarded-Host, X-Forwarded-Proto, X-Forwarded-Scheme, Forwarded or the Host header to build a URL; framework "trust proxy" settings; routes with a catch-all suffix under authenticated paths; handlers that read a GET body; and redirect-to-HTTPS middleware that trusts a request header. On the cache side, look at the cache key definition, any rule that ignores origin Cache-Control, rules keyed on extension, and lists of ignored query parameters. A finding is the combination: an input the origin uses that the cache does not key on, or a path the cache will store that the origin resolves to a private page.

A triage checklist for a cache poisoning or deception finding

QuestionIf the answer is no or unknown
Does the origin change the response because of the input?No poisoning is possible through it
Is the input outside the cache key, including Vary?The attacker can only poison their own variant
Was the cache-buster proven to be in the key before the attack?The test may have written to a shared production key
Did a clean client, without the input or cookies, get a HIT carrying the canary?Poisoning is not confirmed; reflection plus cacheable headers is a hypothesis
Was the clean response the attack's response (same canary, same origin identifier)?A HIT may be someone else's entry
Is the finding being judged on Age, X-Cache or Cache-Control alone?Those headers do not establish who receives the stored copy
What does the poisoned response contain: script source, redirect, error, escaped text?Severity is not established
What is the freshness lifetime, and can the attacker re-poison on expiry?Exposure is not established
For authenticated pages: was path confusion tested (trailing segment, ;, encoded delimiters, normalisation) with a logged-in victim and an anonymous reader?A clean result on the real path says nothing about deception
Does any cache rule override origin Cache-Control on paths an origin may treat as dynamic?private and no-store may not be honoured
Was the test run with the owner's consent, on test accounts, with a way to purge?The test itself may be the incident
Does the fix stop the origin trusting the input, or only key it?Keying works, but splits the cache and leaves the trust in place

What this post did not measure

We measured one cache, nginx 1.24.0, in the configurations shown, in front of one toy origin. We did not test any CDN, Varnish, Squid, any commercial load balancer or any application-level cache, or any browser's cache. We did not test HTTP/2 or HTTP/3, cache key normalisation of header case or of query parameter order, the caching of error responses (beyond observing that our extension block, configured to cache only 200s, did not store a 404), cache purging, or any scanner's or proxy tool's cache-testing feature. The parameter-parsing disagreements were built into our origin on purpose. They model behaviour some frameworks have, and are not a measurement of any framework. The numbers measure our lab, and none of them measures AppSecD or any other product.

The hypothetical findings, resolved

Where AppSecD fits

AppSecD's dynamic testing runs Nuclei, Dalfox, SQLMap, Commix, Katana, Arjun, FFuf and Interactsh for out-of-band detection, plus 150+ native checks and API discovery across 50+ web frameworks. Its policy-driven gating blocks a pull request or commit when it introduces a violation. Findings are deduplicated across scans and move through new, reopened and fixed states, with maker-checker approval so a finding cannot be closed unilaterally.

That is the whole claim. data/products.ts is the single source of truth for what these products do, and it does not mention caching, cache poisoning or web cache deception. So this post makes no claim that AppSecD detects web cache poisoning or web cache deception. Nor does it claim anything about:

The mechanisms, measurements, confirmation procedure, fixes and checklist above are general practice that applies to any scanner's output, ours included. The scenario in this post is hypothetical and does not describe any deployment, user or finding.

More about AppSecD · All posts