Cache Key Normalization DoS
Two new denial of service techniques based on keyed input, host header case normalization and path normalization, plus CVE-2020-7764 in Fastify.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Caching exists to cut latency and server load, and many teams tune their cache configuration to push the hit ratio as high as possible. This write-up looks at what happens when that tuning normalises part of the request, such as the host header or the path, before building the cache key, while the request that reaches the origin is left untouched. The result is a cache poisoning denial of service: one attacker request plants a response that every other user then receives.
The article covers two techniques based on keyed input, host header case normalisation and path normalisation, plus a separate bug in Fastify's Accept-Version header that was assigned CVE-2020-7764. The research was carried out against private bug bounty programs.
Setup
The methodology was deliberately simple and only needed two tools:
- Detect subdomains that use caching services by looking for cache specific headers such as
X-Cacheandcf-cache-status. - Use Param Miner to bruteforce potential uncached headers.
The precondition is a cache in front of an origin that returns an error or a malformed response for some input the cache does not key on, or keys on in a normalised form.
Finding it
The starting point is the general shape of a cache poisoning DoS: an uncached header that forces the origin server to send a malformed request or an error, which the cache then stores and serves to everyone.

The first target found with this methodology was assets.redacted.com, the subdomain hosting every JavaScript and CSS file used on one of the private programs. The cause was Fastify's Accept-Version header, which lets the client describe which version of a resource should be sent back. The header is not part of the cache key, so a request carrying a version the origin does not have produces a 404 that gets cached, and any user requesting the JavaScript file afterwards receives that cached 404.

This one paid 2000$. Because Fastify had no option to disable the Accept-Version header, it also received CVE-2020-7764.
After testing further hosts it became clear that this technique would not scale, so the researcher went looking for other cache poisoning DoS gadgets. Most of the existing research discussed unkeyed input such as the header above and largely ignored keyed input such as the Host header or the path. That gap produced the two attacks below, both reproduced on bug bounty programs.
Exploitation
Step 1: Host header case normalisation
RFC 4343 says fully qualified domain names should always be case insensitive, but frameworks do not always respect that. Because the host value is supposed to be case insensitive, some developers assume it is safe to lowercase the host header value when inserting it into the cache key, without altering the actual request sent to the backend server.
Pairing those two behaviours gave a DoS against a host using a customly configured Varnish as its caching solution.

The capitalised host header value causes a 404 error, and Varnish caches that error under the normalised (lowercased) value of the host header in the cache key. The 404 is cached by Varnish using the normalised value of the host header in the cache key. The report was fixed quite quickly and paid 800$.
The program also said that its load balancer, HAProxy, is the component responding with the 404 when it is given a capitalised header.
Beyond host headers, parameters and paths can also be lowercased before being injected into the cache key, so it is always worth checking how a cache treats them.
Step 2: Path normalisation
While identifying subdomains that use caches, the researcher found a subdomain hosting images used to construct maps. Requesting an image looked something like this:

Param Miner again found no hidden headers, so the next step was a closer look at the path. The last three numbers in the path appeared to be ranges telling the server which part of the map to return. Playing with those for a while led nowhere.
The 1.0.5 segment was initially assumed to be just a version and was ignored, but trying 1.0.4 returned a cache HIT. The natural assumption was that some other APIs use an older version, so 1.0.0 was tested and it also returned a cache HIT. Whatever directory replaced 1.0.5 was returning 200 OK together with an X-Cache Hit response header. That produced the following DoS proof of concept:

Again the drive to increase the cache hit ratio meant nobody considered DoS. Injecting %2e%2e (URL encoded ..) redirected requests to /map/4/77/16.png, which did not exist on the server, so the result was a 404. The report was triaged and the team is working on a fix.
Root cause
In both keyed-input cases the cache and the origin disagree about the request. The cache normalises a component (lowercasing the host, resolving %2e%2e in the path) before using it as a key, while forwarding the original, unnormalised value to the backend. The backend then answers with an error for the unnormalised form, and the cache stores that error under the normalised key, which is the key every legitimate user will present. The Fastify case is the unkeyed variant: Accept-Version changes the origin's answer but is not part of the key at all.
In all three cases the defence that should have stopped it, keying the cache on everything that changes the response, was absent. The custom configurations were introduced deliberately to raise the hit ratio, which is exactly what made the mismatch possible.
Impact
An attacker can make a cache serve an error response to every other user requesting the affected resource. On assets.redacted.com that resource set was every JavaScript and CSS file used by the application, so any user requesting the JavaScript file receives the cached 404. The host header case and path normalisation variants achieve the same denial of service on hosts behind Varnish and on the map image subdomain respectively. The impact depends on the resource being cacheable and on the origin returning an error for the unnormalised input.
Fix
The Fastify issue could not be fixed by configuration at the time, because there was no option to disable the Accept-Version header; it was assigned CVE-2020-7764. The host header case report was fixed quickly by the program. The path normalisation report was triaged and the team was working on a fix.
Variants to test
- Uncached headers. Run Param Miner against cache-fronted hosts and look for any header that changes the response without changing the key.
- Host header case. Send a request with a capitalised host value to a host behind a cache.
- Path case and encoding. Try lowercased path segments and encoded traversal such as
%2e%2ein a segment the cache appears to normalise. - Parameters. The report notes parameters and paths could also be lower-cased before being injected into the cache key, so it is always worth checking how the cache treats them.
The author notes that how often lowercase normalisation is implemented on paths and parameters has not yet been researched, so there is potentially more to explore around URI normalisation and caches.
What happened, in plain words
Imagine a coffee shop with a big tray of pre-made drinks by the counter. When you order the usual, the barista hands you one from the tray instead of making it fresh. That tray is a cache: a store of ready-made answers kept close to the customer so the kitchen (the origin server, the computer that actually does the work) does not have to cook every order from scratch. Caches make websites faster and cheaper to run.
The trouble starts when the person filling the tray and the person taking orders disagree about what counts as "the usual". If the tray is labelled with a tidied-up version of your order, but the kitchen receives your order exactly as you said it, then a strange order can end up in a slot that ordinary customers will later be handed. That is cache poisoning: one attacker request plants an answer that everybody else then receives.
This write-up describes three ways that mismatch was found in real bug bounty programs (paid programmes where companies reward people for reporting security bugs). Two of them are new techniques based on parts of the request that the cache does use to label its entries (keyed input): the Host header and the path. The third is a separate bug in a piece of software called Fastify, which was given the identifier CVE-2020-7764 (a CVE is a public catalogue number for a known vulnerability).
All three end in a denial of service (DoS): the site stops working properly for ordinary users, not because it was hacked for data, but because it keeps handing out error pages.
The basics of a cache poisoning DoS
Modern websites are built from large bundles of JavaScript (the code that runs in your browser), stylesheets written in SCSS, and build tools such as TypeScript and Webpack. All of that adds weight, so teams lean on caching to cut latency (the delay before a page appears) and to reduce load on their servers.
Caching is meant to make a service more reliable. But some custom cache configurations, tuned to squeeze out a higher hit ratio (the share of requests answered from the cache rather than the origin), introduce denial-of-service vulnerabilities that bring the service down.
A cache poisoning vulnerability arises when the cache is tricked by an attacker into serving an altered response to every other user requesting the resource. This is what a cache poisoning denial of service attack would look like:

The image shows the shape of the attack: the attacker sends one request, the cache stores the bad answer, and every later visitor is served that same bad answer.
Background and method
As the diagram shows, all it takes to achieve a DoS is an uncached header: a piece of extra information in the request that the origin server reacts to, but that the cache does not include when it decides which stored answer belongs to which request. If that header can push the origin into sending a malformed request or an error, the cache will happily store the error and hand it to everyone.
A quick word on the pieces involved:
- A request is what your browser sends to a server: a method (usually GET), a path, and a set of headers, which are labelled lines of extra information such as which browser you use.
- The Host header tells the server which site name you typed, for example
www.example.com. One server can host many sites, so it needs to know which one you meant. - The path is the part of the URL after the site name, such as
/images/map.png. - The cache key is the label the cache uses to file an answer. If two requests produce the same key, the second one gets the first one's stored answer.
The researcher looked for potential DoS vulnerabilities on a few private programs with a deliberately simple method:
- Detect all subdomains that were using caching services by identifying cache specific headers (
X-Cache, cf-cache-status, etc). - Use Param Miner in order to bruteforce potential uncached headers.
Step 1 means looking at the responses for tell-tale headers that only caching services add, such as X-Cache or cf-cache-status. If you see them, you know a cache sits in front of the site. Step 2 means using a tool, Param Miner, that automatically tries many header names to see whether any of them changes the response without changing what the cache stores. It is a way of guessing systematically instead of by hand.
The Fastify Accept-Version bug
It did not take long to find a cache poisoning DoS on assets.redacted.com, the subdomain hosting every JavaScript and CSS file used on one of the private programs. In plain terms, this was the shelf from which the whole site loaded its code and styling, so breaking it breaks the site.
The vulnerability was caused by Fastify's Accept-Version header, which allows the client to describe which version of a resource to send back. Fastify is a framework: a toolkit that developers use to build the server side of a web application, so that they do not write every low-level detail themselves. The Accept-Version header is a feature that lets a browser ask for, say, version 2 of a file instead of version 1. The researcher abused the feature like so:

Because the Accept-Version header is not included in the cache key, any user requesting the JavaScript file will receive the cached 404 response. A 404 is the standard "not found" answer. So the sequence is: the attacker asks for a version that does not exist, the origin answers "not found", the cache files that "not found" under the plain address of the file, and every ordinary visitor asking for the file gets "not found" too.
This was rewarded 2000$. To the researcher's surprise, because Fastify had no option to disable the Accept-Version header, the issue was also assigned CVE-2020-7764. In other words, the problem was not just this one site's configuration: the framework itself offered no switch to turn the feature off.
After testing further hosts, it became increasingly apparent that this technique would not scale: few other targets behaved the same way. So the researcher went looking for other cache poisoning DoS gadgets. Most of the research already published discussed how unkeyed input, such as the header above, can lead to DoS, but largely ignored keyed input such as the Host header or the path. That gap led to the two attacks below, both reproduced on bug bounty programs.
Attack 1: Host header case normalisation
According to RFC 4343, FQDN (Fully qualified domain names) should always be case insensitive. An RFC is a formal internet standards document, and an FQDN is the full name of a machine on the internet, such as assets.example.com. "Case insensitive" means Assets.Example.com and assets.example.com are supposed to mean the same thing.
However, for some reason, this is not always respected by frameworks. Interestingly, since the host value should be case insensitive, some developers assume it is safe to lowercase the host header value when introducing it into the cache key, without altering the actual request sent to the backend server. That is the mismatch: the cache files the answer under the tidy lowercase name, while the origin receives the name exactly as typed, capitals and all.
When pairing the two behaviours, the researcher was able to achieve the following DoS attack on a host using a customly configured Varnish as a caching solution. Varnish is a popular caching server that sits in front of a website.

Notice the capitalised host header value, causing a 404 error, which will then be cached by Varnish using the normalised value of the host header in the cache key. From then on, anyone visiting the site with the ordinary lowercase name is handed the stored 404. This report was fixed quite quickly, and the researcher received an 800$ bounty.
The program also informed the researcher that their load balancer (HAProxy) is the one responding with the 404 error when provided a capitalised header. A load balancer is the traffic cop in front of several servers, deciding which one handles each request; HAProxy is a common piece of software for that job. So in this case it was the traffic cop, not the kitchen, that said "not found".
Besides host headers, parameters and paths could also be lower-cased before being injected into the cache key, so it is always worth checking how the cache treats them. A parameter is a named value attached to a request, such as ?colour=blue in a URL.
Attack 2: Path normalisation
While identifying subdomains using caches, the researcher found a particular subdomain hosting images used to construct maps. Requesting an image would look something like this:

Just like before, Param Miner was not able to find any hidden headers, so the researcher decided to take a deeper look. As far as could be told, the last three numbers in the path were ranges meant to tell the server what part of the map it should return. Playing around with those for a good amount of time led nowhere.
Initially, the researcher thought 1.0.5 was just the version, so it did not get much attention. But to the researcher's surprise, trying 1.0.4 produced a cache HIT. A cache HIT is the cache saying "I already have this one, here it is", as opposed to a miss, where it has to ask the origin. Naturally, the assumption was that some other APIs might be using an older version, so 1.0.0 was tested, and it also returned a cache HIT. An API is a defined way for one piece of software to ask another for data or actions, like a menu of allowed requests.
It did not take long to realise that whatever directory replaced 1.0.5 was returning 200 OK and an X-Cache Hit response header. 200 OK is the standard "here you go, everything is fine" answer. That led to the following DoS proof of concept:

Yet again, while trying to increase the cache-hit ratio, developers did not take into consideration potential DoS attacks. That allowed the researcher to inject %2e%2e (URL encoded ..) and redirect requests to /map/4/77/16.png, which did not exist on the server, therefore leading to the 404. In plain terms, .. means "go up one folder" in a file path, and %2e is simply how a dot is written when it has to be encoded inside a URL. The cache tidied the path up before filing the answer, so the tidied address ended up pointing at a file that was not there, and the "not found" answer was stored for everyone. This was triaged, and the team is working on a fix. Triaged means the security team has reviewed the report and accepted it as a real issue to work on.
Why it works
In both keyed-input cases the cache and the origin disagree about the request. The cache normalises a component (lowercasing the host, resolving %2e%2e in the path) before using it as a key, while forwarding the original, unnormalised value to the backend. The backend then answers with an error for the unnormalised form, and the cache stores that error under the normalised key, which is the key every legitimate user will present. The Fastify case is the unkeyed variant: Accept-Version changes the origin's answer but is not part of the key at all.
In all three cases the defence that should have stopped it, keying the cache on everything that changes the response, was absent. The custom configurations were introduced deliberately to raise the hit ratio, which is exactly what made the mismatch possible.
What the impact is
An attacker can make a cache serve an error response to every other user requesting the affected resource. On assets.redacted.com that resource set was every JavaScript and CSS file used by the application, so any user requesting the JavaScript file receives the cached 404. Cache entries usually expire after a set time, which is why the damage is temporary rather than permanent.
The host header case and path normalisation variants achieve the same denial of service on hosts behind Varnish and on the map image subdomain respectively. The impact depends on the resource being cacheable and on the origin returning an error for the unnormalised input.
How it was fixed
The Fastify issue could not be fixed by configuration at the time, because there was no option to disable the Accept-Version header; it was assigned CVE-2020-7764. The host header case report was fixed quickly by the program. The path normalisation report was triaged and the team was working on a fix.
Variants to test
If you want to look for the same class of bug, these are the checks the research suggests:
- Uncached headers. Run Param Miner against cache-fronted hosts and look for any header that changes the response without changing the key.
- Host header case. Send a request with a capitalised host value to a host behind a cache.
- Path case and encoding. Try lowercased path segments and encoded traversal such as
%2e%2ein a segment the cache appears to normalise. - Parameters. The report notes parameters and paths could also be lower-cased before being injected into the cache key, so it is always worth checking how the cache treats them.
The author notes that how often lowercase normalisation is implemented on paths and parameters has not yet been researched, so there is potentially more to explore around URI normalisation and caches. URI is just another word for the address of a resource, of which a URL is the familiar kind.
Glossary
- API: a defined set of requests one piece of software can make to another, like a menu of allowed questions.
- Backend / origin server: the computer that actually produces the content, behind any cache or load balancer.
- Bug bounty program: a scheme where a company pays researchers for reporting security bugs in its systems.
- Cache: a store of ready-made answers kept close to users so the origin does not have to produce them every time.
- Cache HIT: the cache already holds the answer and returns it without asking the origin.
- Cache key: the label the cache uses to file and find a stored answer.
- Cache poisoning: tricking a cache into storing a bad answer that later visitors receive.
- CVE: a public catalogue number assigned to a known vulnerability.
- Denial of service (DoS): making a service unusable for ordinary users.
- Fastify: a framework for building the server side of web applications in JavaScript.
- FQDN: the full name of a machine on the internet, such as
assets.example.com. - Framework: a toolkit that provides common building blocks so developers do not write everything from scratch.
- HAProxy: software that spreads incoming traffic across several servers (a load balancer).
- Header: a labelled line of extra information sent with a request or response, such as the browser type or the site name.
- Hit ratio: the share of requests answered from the cache rather than the origin.
- Host header: the part of a request that says which site name the visitor typed.
- Keyed input: part of a request that the cache uses when deciding which stored answer to return.
- Latency: the delay before a page or file arrives.
- Load balancer: the traffic cop in front of several servers that decides which one handles each request.
- Normalisation: tidying a value into a standard form, for example lowercasing it or resolving
..in a path. - Parameter: a named value attached to a request, such as
?colour=bluein a URL. - Path: the part of a URL after the site name, such as
/images/map.png. - Proof of concept (POC): a minimal demonstration that a vulnerability really works.
- Request: what a browser sends to a server: a method, a path and headers.
- RFC: a formal internet standards document.
- Triaged: reviewed by a security team and accepted as a real issue to fix.
- Uncached header: a header that changes the origin's answer but is not part of the cache key.
- URI / URL: the address of a resource on the internet.
- Varnish: a popular caching server placed in front of a website.
- 404: the standard "not found" answer from a server.
- 200 OK: the standard "here is your answer" response from a server.