Skip to content
Cache bugs Disclosed report Advanced CVE-2024-1554

Browser cache poisoning attack using fetch() with different headers

The browser's private cache is shared between Fetch requests and normal navigation, but the cache key does not include request headers that can vary the response. An attacker can use Fetch to pre-load a poisoned response into the cache, then force the victim to navigate to the page, activating the attack.

scarlet Follow

Originally disclosed on Mozilla

  • Fixed in 11 months
  • Paid in 12 months
  • Disclosed after 11 months

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0

Steps to reproduce:

TL;DR

If the right set of circumstances are present, Fetch can be used to pre-load the browser private cache, and poison normal navigation. Using this approach, a range of attacks that were previously thought to be unexploitable, can be unlocked and made practical. Hurrah!

Blah Blah Blah

The reason that this works is because the browser shares the private cache between Fetch and normal navigation, with the cache key being based upon the URI and originating context. However, because Fetch is able to add headers to the request that can vary the response (but which are not included in the cache key), an attacker can pre-request resources to poison the private cache, then force the browser to navigate to the page, which activates the attack.

To make this work requires two things:

  • The Fetch request and response must be cacheable under normal circumstances by the browser. Typically, a GET method, and the response must be implicitly cacheable (301/308 status code, and last-modified header), or explicitly cacheable (cache-control, pragma and expires headers).

  • The target endpoint must pass a pre-flight check, as adding additional headers to a Fetch request requires CORS.

As an interesting observation, the response does not always have to be made available to Fetch for the browser cache to be updated. For example, if the pre-flight passes, but the actual response does not have an access-control-allow-origin header, then it will be blocked due to CORS. But even so, the cache will sometimes still be updated successfully.

Recommendations

It is recommended that additional information is added to the cache key, so that requests made by Fetch and the normal navigation are separated.

PoC

The following PoC links launch same-origin, same-site and cross-origin tests, either directly or from within an iframe data URI (to force a null origin).

301 status code (direct)

200 status code (direct)

301 status code (iframe)

200 status code (iframe)

Actual results:

as above

Expected results:

as above

The original report as published on Mozilla's Bugzilla, by scarlet. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The browser's cache key does not include request headers that can change the response, allowing Fetch requests to poison the cache for normal navigation.

Impact

An attacker could poison the browser cache to serve malicious content, potentially enabling attacks previously thought unexploitable, but only if the response is cacheable and the request passes CORS pre-flight.

What the attacker needed

Response must be cacheable; request must pass CORS pre-flight

The fix

The cache key should be extended to include request headers that can vary the response, separating Fetch requests from normal navigation.

How it was found

  1. Use Fetch to send a request with headers that cause a malicious response, which gets cached.
  2. Force the browser to navigate to the same URL, which loads the poisoned response from the cache.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A web browser keeps a local copy (cache) of pages to load them faster. This report shows that a script can trick the browser into saving a malicious version of a page, which is then shown when the user visits that page normally.

What is Cache bugs?

A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.

More by scarlet

View all

2 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Web cache poisoning and deception

The lesson behind this report.

A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.