How I Made $16,500 Hacking CDN Caching Servers — Part 3
The CDN caching server cached a 301 redirect response triggered by the X-Forwarded-Scheme header, causing a redirect loop that denied access to the site for all users until the cache expired. An attacker could poison the cache to cause a denial of service.
infosecwriteups.com
Published on infosecwriteups.com
Bug Bounty
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
This is the third part of a series on CDN cache poisoning, and it covers a single report from a private program. The asset was a site sitting behind caching servers and running Ruby on Rails. The bug is a cache poisoning denial of service: a request header makes the origin answer with a redirect, the CDN stores that redirect, and every later visitor to the same URL is sent into a redirect loop until the cache entry expires.
The researcher credits the idea to a blog post by @iustinBB, "Cache Poisoning at Scale", which describes the mechanism:
Sending the x-forwarded-scheme: http header would result into a 301 redirect to the same location. If the response was cached by a CDN, it would cause a redirect loop, inherently denying access to the file.
Setup
No accounts, roles or tooling are described beyond a proxy capable of sending custom headers and reading responses. The precondition is the one that matters: the target must be served through a CDN that caches responses keyed on the URL, and the origin must react to the X-Forwarded-Scheme header by redirecting. The researcher had access to the private program's asset and knew it used caching servers and Ruby on Rails.
Finding it
After reading the blog post, the researcher recalled a private program asset that matched the two conditions: caching in front, Rails behind. When the application trusts it and the value disagrees with the scheme it expects, a redirect back to the same location is a common response. If the CDN does not include that header in its cache key, the redirect is stored and served to everyone.
Exploitation
Step 1: send the header with a cache buster
The researcher sent a request with the X-Forwarded-Scheme: http header and a unique query string so that only a fresh cache entry was affected:
GET /?xxx HTTP/2 Host: RedactedX-Forwarded-Scheme: http ...
The ?xxx is a cache buster. The researcher notes that anyone testing this should always use one, in this case (?xxx), so as not to poison the cache for other users. The header tells the application the request arrived over plain HTTP; the application answers with a redirect to the same location.
Step 2: observe the cached redirect
The response came back as a 301 pointing at the same location, and the CDN reported it as a cache hit:
HTTP/2 301 Moved Permanently Date: Wed, 19 Jan 2022 17:16:13 GMT Content-Type: text/html Location: RedactedVia: 1.1 vegur Cf-Cache-Status: HIT Age: 3
The Cf-Cache-Status: HIT shows the CDN served it from cache, and Age: 3 shows the entry was three seconds old. The redirect is now stored.
Step 3: the effect on other users
Once the entry is poisoned, a normal visitor requesting the same URL receives the stored redirect:
HTTP/2 301 Moved PermanentlyCf-Cache-Status: HIT
The browser follows the stored redirect, and the page will not load until the cache refreshes. As the researcher puts it, users will not be able to access the site because the attacker saved the 301 redirect, and it will not load until the cache refreshes. The researcher also notes that an attacker can time the request against the cache server to poison the page.
Timeline
The report moved through the program as follows:
| Stage | Date |
|---|---|
| Reported | January 19, 2022 |
| Pending Program Review | January 25, 2022 |
| Triaged | January 25, 2022 |
| Bounty Awarded | January 26, 2022 |
The bounty for this report was 3,000. The researcher states that the three reports in the series totalled $11,300, chosen because they were the most awarded ones. Applying the same methodology on other programs, including cache deception issues such as report 1343086 on HackerOne, brought the total to $15,400 on HackerOne and $1,100 on BugCrowd.
Root cause
The redirect target is the same URL, so following it produces the same request and the same cached response.
Impact
A single request can deny access to a URL for every user behind the CDN until the cache entry refreshes. The researcher's example is the site root. The effect is temporary and self-healing when the cache expires, and it depends on the CDN caching the redirect and on the origin honouring the header.
Fix
The report does not describe a fix.
Variants to test
- A positive result is a 301 to the same location with a cache hit status.
- A positive result is a cached redirect or a cached response that differs from the clean one.
- Request the poisoned URL without the header and confirm the cached redirect is served. A positive result is the same 301 with a cache hit and no header sent.
- A positive result is the redirect surviving until the entry's age reaches the cache lifetime.
What happened, in plain words
A security researcher found a way to make a website unreachable for other people by sending a single request. The trick relied on two pieces of technology working together: a content delivery network (CDN) that stores copies of web pages to serve them faster, and a web application that can be told to redirect visitors to a different address. By sending a special header, the researcher caused the application to respond with a redirect that pointed back to the same page. The CDN then saved that redirect and served it to everyone who asked for the page, so the page would not load until the cache refreshed. The researcher reported the issue through a bug bounty programme and was paid $3,000 for this particular finding. This article explains the whole process from scratch, assuming no prior security knowledge.

Background: what is a CDN and why caching matters
A CDN is a network of servers placed around the world that store copies of website content. When you visit a site, your request goes to the nearest CDN server instead of the original server (called the origin). If the CDN has a fresh copy of the page, it sends that copy immediately, which is faster and reduces load on the origin. This storing of copies is called caching.
Caching works well when the content is the same for everyone. But if an attacker can make the CDN store a malicious or broken response, every visitor will receive that bad response until the cache is refreshed. This is called cache poisoning.
In this case, the researcher found a way to poison the cache with a redirect that creates an infinite loop.
The idea: learning from others
The researcher got the idea from a blog post by @iustinBB titled "Cache Poisoning at Scale". That post described the following mechanism:
Sending the x-forwarded-scheme: http header would result into a 301 redirect to the same location. If the response was cached by a CDN, it would cause a redirect loop, inherently denying access to the file.
Let's break that down:
x-forwarded-scheme: httpis an HTTP header. Headers are extra pieces of information that browsers and servers exchange with each request and response.- A
301 redirectis a server response that tells the browser "the page you want has moved permanently to this other address". The browser then automatically requests the new address. - If the redirect points to the same address that was requested, the browser will keep requesting the same address and getting the same redirect, over and over. That's a redirect loop.
- If the CDN caches that redirect response, then every user who requests that address will get the redirect, and their browsers will loop, making the page inaccessible.
So the attack is: send a request with that header, get a redirect to the same place, and have the CDN store it. Then anyone visiting that URL gets stuck in the loop.
Finding a target
The researcher remembered a private bug bounty programme (a programme where only invited researchers can participate) that had an asset (a website or application in scope) using caching servers and running Ruby on Rails. Ruby on Rails is a popular web framework for building applications. The asset used caching servers and ran Ruby on Rails.
Step 1: send the malicious request
The researcher sent a request with the X-Forwarded-Scheme: http header and a unique query string to avoid affecting other users. Here is the request:
GET /?xxx HTTP/2 Host: RedactedX-Forwarded-Scheme: http ...
Line by line:
GET /?xxx HTTP/2is the request line.GETis the method used to ask for a resource./is the path (the homepage).?xxxis a query string, a way to add parameters to the URL. Here it's used as a "cache buster": a unique string that makes the CDN treat this as a different URL from the normal homepage, so only this specific cached copy is poisoned, not the one other users might request.HTTP/2is the version of the HTTP protocol.Host: Redactedtells the server which website is being requested. The actual hostname is hidden (redacted) in the report.X-Forwarded-Scheme: httpis the custom header that triggers the redirect. It claims the request came over HTTP instead of HTTPS....indicates that other headers may have been present but are not shown.
The researcher notes: "If you will test this, you should always use 'cache busters' (?anything=x) in this case, i used (?xxx) so i don't mistakenly poisoned other users." This is important: without a cache buster, you might poison the cache for the real URL and break the site for everyone.
Step 2: observe the response
The server responded with a 301 redirect, and the CDN indicated it served the response from cache:
HTTP/2 301 Moved Permanently Date: Wed, 19 Jan 2022 17:16:13 GMT Content-Type: text/html Location: RedactedVia: 1.1 vegur Cf-Cache-Status: HIT Age: 3
Line by line:
HTTP/2 301 Moved Permanentlyis the status line.301means the resource has moved permanently, and the new location is given in theLocationheader.Date: Wed, 19 Jan 2022 17:16:13 GMTis the date and time the response was generated.Content-Type: text/htmlindicates the body is HTML (though a redirect typically has a small body).Location: Redactedis the address the browser should go to. It is redacted, but the researcher says it points to the same location.Cf-Cache-Status: HITshows that the response was served from cache (a "hit").Age: 3means the cached response is 3 seconds old.
So the redirect was cached. The researcher notes: "If an attacker timed the cache server and poison https://redacted/" (the sentence is incomplete in the original, but the idea is that an attacker can time the request to poison the main URL).
Step 3: the effect on other users
Now, when a normal user requests the same URL (without the special header), they receive the cached redirect:
HTTP/2 301 Moved PermanentlyCf-Cache-Status: HIT
Line by line:
HTTP/2 301 Moved Permanentlyagain a redirect.Cf-Cache-Status: HITagain served from cache.
The browser follows the stored redirect, and the page will not load until the cache refreshes. The researcher explains: "They won't be able to access https://redacted/ as the attacker saved the 301 redirect and would not load, until the cache refreshes." So the site is effectively down for that URL until the cache entry expires.
Timeline
The report went through these stages:
| Stage | Date |
|---|---|
| Reported | January 19, 2022 |
| Pending Program Review | January 25, 2022 |
| Triaged | January 25, 2022 |
| Bounty Awarded | January 26, 2022 |
- Reported: the researcher submitted the vulnerability to the bug bounty programme.
- Pending Program Review: the programme was reviewing the report.
- Triaged: the programme validated the report and assigned it to be fixed.
- Bounty Awarded: the researcher received the reward.
The bounty for this report was $3,000. The researcher mentions that the three reports in this series totalled $11,300, and that they chose these three because they were the most awarded. Applying the same methodology on other programmes, including cache deception issues like report #1343086 on HackerOne, brought the total to $15,400 on HackerOne and $1,100 on BugCrowd.
Why it worked
(the set of information that determines which cached response to serve). So when the application returned a redirect, the CDN stored it under the URL and served it to everyone, regardless of whether they sent the header. The redirect pointed to the same URL, so following it produced the same request and the same cached response, creating a loop.
Impact
A single request can make a URL inaccessible for all users behind the CDN until the cache entry expires. The researcher demonstrated it on the site root. The effect is temporary and resolves when the cache refreshes. It depends on the CDN caching the redirect and the origin honouring the header.
How to fix it
The report does not describe a fix.
Variants to test
- A positive result is a 301 to the same location with a cache hit status.
- A positive result is a cached redirect or a cached response that differs from the clean one.
- Request the poisoned URL without the header and confirm the cached redirect is served. A positive result is the same 301 with a cache hit and no header sent.
- A positive result is the redirect surviving until the entry's age reaches the cache lifetime.
Glossary
- CDN (Content Delivery Network): a system of distributed servers that cache and deliver web content to users based on their geographic location, improving speed and reducing load on the origin server.
- Cache: a temporary storage area that holds copies of data so future requests can be served faster.
- Cache poisoning: an attack where an attacker causes a cache to store a malicious or incorrect response, which is then served to other users.
- Cache buster: a unique string added to a URL (like a query parameter) to force the cache to treat it as a new, separate entry, preventing interference with existing cached content.
- HTTP header: additional information sent with an HTTP request or response, such as the type of browser or the format of the data.
- X-Forwarded-Scheme: an HTTP header used to indicate the protocol (HTTP or HTTPS) of the original request when it passes through a proxy or load balancer.
- 301 redirect: an HTTP status code indicating that the requested resource has been permanently moved to a new URL, provided in the
Locationheader. - Redirect loop: a situation where a browser is repeatedly redirected to the same URL, never reaching the final content.
- Ruby on Rails: a web application framework written in Ruby, used to build dynamic websites.
- Origin server: the original server that hosts a website's content, as opposed to a CDN or proxy server.
- Cache key: the identifier used by a cache to determine which stored response to serve for a given request, typically based on the URL and sometimes other factors like headers.
- Cf-Cache-Status: a response header added by Cloudflare indicating whether the response was served from cache (HIT) or not (MISS).
- Age: a response header indicating how many seconds the response has been in the cache.
- Location: a response header used in redirects to specify the URL to which the client should be redirected.
- Bug bounty programme: a programme where organisations reward security researchers for finding and reporting vulnerabilities in their systems.
- Triaged: the process of reviewing and validating a reported vulnerability to determine its severity and validity.
- HackerOne: a platform that connects organisations with security researchers for bug bounty programmes.
- BugCrowd: another bug bounty platform.
- Cache deception: an attack where an attacker tricks a cache into storing sensitive information, which can then be accessed by unauthorised users.