Skip to content
CORS Disclosed report Advanced CVE-2019-11712

Cross-origin requests can be made with NPAPI plugins by following 308 redirects

Firefox followed a 308 redirect issued by an attacker-controlled server for requests made through NPAPI plugins such as Flash, so the redirected request reached a cross-origin endpoint with its body and custom headers intact. An attacker could use this to send cross-site requests to JSON endpoints that normally reject them, bypassing CORS checks.

Gregory Smiley Follow

Originally disclosed on Mozilla

  • Fixed in 55 days
  • Paid in 60 days
  • Disclosed after 55 days
Text
Created attachment 9057658
firefoxHttpRedirector.py

Cross-origin requests can be made with NPAPI plugins such as Flash which can allow an attacker to perform Cross-Site Request Forgery attacks using otherwise inaccessible HTTP headers such as Content-Type. This can be achieved by sending a request to an attacker controlled server (same-origin request) which will then respond with a 308 redirect with the “Location” header set to the target origin/vulnerable endpoint.

Once the browser receives this 308 redirect, the request is made to the cross-origin endpoint, and in Flash’s case, an immediate request for the target endpoints crossdomain.xml file is requested. However, since the browser has already responded to the 308 redirect, CORS has been violated.

Reproduction Steps:

A modular exploit has been attached including: csrf.html, csrf.as, and firefoxHttpRedirector.py. On a web server under your control, run the firefoxHttpRedirector.py script in the same folder as the csrf.html and compiled flash applet (csrf.swf) files. The command would look something like:

sudo python firefoxHttpRedirector.py --port 80 --target https://vulnerableapp123.com/api/endpoint

Then, once the web server has started, emulate a victim by constructing a CSRF request in the following format:

http://<attack_server>/csrf.html?attackerUrl=http://<attack_server>/&md=POST&jsonData={“foo”:”bar”}&headers=Content-Type:application/json

Where the URL parameters are as follows:

attackerUrl - server where the firefoxHttpRedirector.py script is running
md - HTTP method/verb to use in the request to the target server (GET or POST)
jsonData - body data to be sent to the target server (the parameter is jsonData but any format would work)
headers - headers to include in the request, such as Content-Type

Once the appropriate URL has been constructed, navigate to that URL and note how Firefox
follows the redirection to the target server with the body and headers intact. 
I have setup an attack server which can be used as a PoC upon request. Currently I have it configured to be inaccessible however if there’s issues setting up the exploit, I can provide that URL. 

Expected behavior:
Firefox does not follow the 308 redirect or waits for a CORS evaluation before following the redirect.

Observed behavior:
Firefox follows the 308 redirect. 

Tested versions:
Firefox 66.0.3 x64 (Windows 7 6.1.7601)
Firefox 66.0.2 x64 (Windows 10 10.0.17134)
Firefox ESR 60.6.1esr x64 (macOS Sierra 10.12.6)

References:
https://bugzilla.mozilla.org/show_bug.cgi?id=1436241
https://blog.appsecco.com/exploiting-csrf-on-json-endpoints-with-flash-and-redirects-681d4ad6b31b
https://github.com/sp1d3r/swf_json_csrf

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

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What the report shows

The report concerns Mozilla Firefox and its handling of NPAPI plugins, filed under the Core Graveyard: Plug-ins component. The researcher, Gregory Smiley of Security Compass, found that cross-origin requests can be made with NPAPI plugins such as Flash, which allows an attacker to perform Cross-Site Request Forgery attacks using HTTP headers that would otherwise be inaccessible, such as Content-Type.

The mechanism the report describes is a redirect. The attacker sends a request to a server they control, which is a same-origin request from the plugin's point of view. That server answers with a 308 redirect whose Location header points at the target origin and vulnerable endpoint. When the browser receives the 308, the request is made to the cross-origin endpoint. In Flash's case an immediate request for the target endpoint's crossdomain.xml file follows, but because the browser has already responded to the 308 redirect, CORS has been violated.

The reproduction steps use a modular exploit attached to the report: csrf.html, csrf.as and firefoxHttpRedirector.py. The redirector script is run on a web server under the researcher's control, in the same folder as csrf.html and the compiled Flash applet csrf.swf:

Bash
sudo python firefoxHttpRedirector.py --port 80 --target https://vulnerableapp123.com/api/endpoint

With the server running, the victim is emulated by constructing a CSRF request in this format:

Text
http://<attack_server>/csrf.html?attackerUrl=http://<attack_server>/&md=POST&jsonData={"foo":"bar"}&headers=Content-Type:application/json

The URL parameters are described as follows:

Parameter Meaning
attackerUrl server where the firefoxHttpRedirector.py script is running
md HTTP method to use in the request to the target server (GET or POST)
jsonData body data sent to the target server; the parameter is named jsonData but any format would work
headers headers to include in the request, such as Content-Type

Navigating to the constructed URL shows Firefox following the redirection to the target server with the body and headers intact. The researcher offered an attack server as a proof of concept on request, configured to be inaccessible at the time of writing.

The expected behaviour is that Firefox does not follow the 308 redirect, or waits for a CORS evaluation before following it. The observed behaviour is that Firefox follows the 308 redirect. The report lists these tested versions:

  • Firefox 66.0.3 x64 (Windows 7 6.1.7601)
  • Firefox 66.0.2 x64 (Windows 10 10.0.17134)
  • Firefox ESR 60.6.1esr x64 (macOS Sierra 10.12.6)

The report references a related Bugzilla entry (1436241), a blog post on exploiting CSRF on JSON endpoints with Flash and redirects, and the swf_json_csrf project on GitHub. The text does not describe a fix or a bounty amount.

Root cause

The report describes the redirect being followed before any CORS evaluation of the cross-origin destination. The plugin's request is same-origin when it leaves for the attacker's server, so the plugin is willing to attach the chosen method, body and headers. The 308 status preserves the method and body across the redirect, and the browser then issues the request to the new origin without first checking whether that origin authorises the request. The plugin's own policy check, the fetch of crossdomain.xml, happens too late to matter.

Impact

Where a target endpoint accepts a state-changing request and relies on the browser's inability to send certain headers cross-origin, an attacker can forge that request from a victim's browser. The report names Content-Type as an example of an otherwise inaccessible header. The report frames the result as CSRF and does not claim data theft or code execution.

How this kind of bug works

Browsers restrict cross-origin requests in two ways: the same-origin policy limits which responses a page can read, and CORS governs whether a cross-origin request may carry non-simple headers or methods. A request with Content-Type: application/json, or with a method other than GET, HEAD or POST with simple content types, triggers a preflight, and the server must approve it. Many APIs therefore treat the presence of such a header as proof that the request came from trusted JavaScript.

Redirects complicate this. A 307 or 308 redirect preserves the method and body; 301, 302 and 303 may rewrite the method to GET. If a component follows a redirect to a new origin and replays the original request, including its headers and body, the CORS decision that should have applied to the final destination is skipped or made against the wrong origin. Legacy plugin networking stacks, which predate modern CORS enforcement and use their own cross-domain policy files, are a classic place for this gap.

How to test for it

  1. Identify endpoints that change state and depend on a header or method a browser cannot send cross-origin without a preflight, for example JSON APIs that reject requests without Content-Type: application/json.
  2. Stand up a server you control that returns a 308 redirect to the target endpoint, preserving method and body.
  3. From a browser, issue a same-origin request to your server with the method, body and headers you want replayed. Use a client component that can set arbitrary headers, such as a plugin, or test whether the browser itself replays them.
  4. Observe the request that reaches the target: check the method, the body and the headers. A positive result is the target receiving the full original request, with the sensitive header intact, without a preflight for the final origin.
  5. Confirm the side effect on the target, for example a changed record, rather than only the arrival of the request.

Common false positives: the redirect downgrading the method to GET so the body is dropped; the browser stripping the sensitive header on the cross-origin hop; the target rejecting the request for a reason unrelated to CORS, such as a missing session or CSRF token; and a preflight actually being sent and approved, which makes the behaviour legitimate.

How it is fixed

Browsers should evaluate CORS for the redirect destination before replaying the request, or refuse to follow cross-origin redirects for requests that carry non-simple headers or bodies. Servers should not treat a header such as Content-Type as an authentication or CSRF defence on its own; they should require a token, check Origin and Sec-Fetch-Site, and reject cross-site requests to state-changing endpoints. Retiring plugin networking stacks removes a whole class of these gaps.

Hunting notes

This bug class hides where legacy clients, plugins or embedded browsers meet modern APIs: JSON endpoints, file upload handlers, and anything that trusts a content type. Recon signals include endpoints that return 307 or 308 redirects, APIs that document a JSON-only content type, and applications still loading NPAPI or similar plugin content.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 8 min read.

What happened, in plain words

This report is about Mozilla Firefox and the way it handled old-style browser add-ons called NPAPI plugins, such as Adobe Flash. The researcher, Gregory Smiley of Security Compass, found that these plugins could be tricked into sending requests to another website, which in turn allowed an attack called Cross-Site Request Forgery (CSRF).

A few words first, because the whole report depends on them.

  • A request is what your browser sends to a website when you click a link or submit a form: a message asking the server to do something, such as "show me this page" or "save this change".
  • A header is a small labelled line attached to a request, carrying extra information. One example is Content-Type, which tells the server what kind of data the request body contains, for example JSON.
  • The origin of a page is the combination of scheme, host and port, roughly "which site this is". A request to the same site is same-origin; a request to a different site is cross-origin.
  • CSRF is an attack where a malicious page makes your browser send a request to another site while you are logged in there, so the request carries your session. The site cannot tell it apart from a request you made yourself.

Normally a web page is not allowed to send certain headers, such as Content-Type: application/json, to a different site without first asking that site for permission. That permission check is called CORS (Cross-Origin Resource Sharing). Many APIs rely on this: they accept a request only if it carries that JSON content type, assuming a browser could not have sent it from another site.

The trick in this report is a redirect. A redirect is a server's answer saying "not here, go to this other address instead", and the new address is given in a header called Location. The attacker sends a request to a server they control. From the plugin's point of view this is a same-origin request, so the plugin happily attaches the method, body and headers the attacker wants. The attacker's server answers with a 308 redirect, a redirect type that keeps the original method and body, pointing at the target site and its vulnerable endpoint.

When the browser receives the 308, it sends the request on to the cross-origin endpoint. In Flash's case, a request for the target's crossdomain.xml file (a policy file that says which other sites may talk to it) follows immediately, but by then the browser has already acted on the 308, so CORS has been violated.

To reproduce it, the researcher attached a small set of files: csrf.html, csrf.as and firefoxHttpRedirector.py. The redirector script is started on a web server under the attacker's control, in the same folder as csrf.html and the compiled Flash applet csrf.swf:

Bash
sudo python firefoxHttpRedirector.py --port 80 --target https://vulnerableapp123.com/api/endpoint

This runs a Python script with administrator rights (sudo), listening on port 80, and tells it which target endpoint to redirect to. The attacker's server is the first stop; the target is where the forged request should land.

With the server running, the victim is emulated by building a CSRF request in this format:

Text
http://<attack_server>/csrf.html?attackerUrl=http://<attack_server>/&md=POST&jsonData={"foo":"bar"}&headers=Content-Type:application/json

This is a URL with parameters after the question mark, each one a setting for the attack page. The report describes them as follows:

Parameter Meaning
attackerUrl server where the firefoxHttpRedirector.py script is running
md HTTP method to use in the request to the target server (GET or POST)
jsonData body data sent to the target server; the parameter is named jsonData but any format would work
headers headers to include in the request, such as Content-Type

So md=POST means the forged request should be a POST, the kind of request used to submit data and change things on a server. jsonData={"foo":"bar"} is the body that will be sent. headers=Content-Type:application/json is the header that a normal page could not set on a cross-origin request without permission. Each of these matters because together they carry the method, body and header the attacker chose.

Navigating to the constructed URL shows Firefox following the redirect to the target server with the body and headers intact. The researcher offered an attack server as a proof of concept on request, configured to be inaccessible at the time of writing.

The expected behaviour is that Firefox does not follow the 308 redirect, or waits for a CORS evaluation before following it. The observed behaviour is that Firefox follows the 308 redirect. These versions were tested:

  • Firefox 66.0.3 x64 (Windows 7 6.1.7601)
  • Firefox 66.0.2 x64 (Windows 10 10.0.17134)
  • Firefox ESR 60.6.1esr x64 (macOS Sierra 10.12.6)

The report references a related Bugzilla entry (1436241), a blog post on exploiting CSRF on JSON endpoints with Flash and redirects, and the swf_json_csrf project on GitHub. The text does not describe a fix or a bounty amount.

In general, how this kind of bug works

Browsers restrict cross-origin requests in two ways. The same-origin policy limits which responses a page may read. CORS governs whether a cross-origin request may carry non-simple headers or methods: a request with Content-Type: application/json, or with a method other than GET, HEAD or POST with simple content types, triggers a preflight, a separate check the server must approve before the real request is sent. Many APIs therefore treat the presence of such a header as proof that the request came from trusted JavaScript.

Redirects complicate this. A 307 or 308 redirect preserves the method and body; 301, 302 and 303 may rewrite the method to GET. If a component follows a redirect to a new origin and replays the original request, including its headers and body, the CORS decision that should have applied to the final destination is skipped or made against the wrong origin. Legacy plugin networking stacks, which predate modern CORS enforcement and use their own cross-domain policy files, are a classic place for this gap.

How to test for it

  1. Identify endpoints that change state and depend on a header or method a browser cannot send cross-origin without a preflight, for example JSON APIs that reject requests without Content-Type: application/json.
  2. Stand up a server you control that returns a 308 redirect to the target endpoint, preserving method and body.
  3. From a browser, issue a same-origin request to your server with the method, body and headers you want replayed. Use a client component that can set arbitrary headers, such as a plugin, or test whether the browser itself replays them.
  4. Observe the request that reaches the target: check the method, the body and the headers. A positive result is the target receiving the full original request, with the sensitive header intact, without a preflight for the final origin.
  5. Confirm the side effect on the target, for example a changed record, rather than only the arrival of the request.

Common false positives: the redirect downgrading the method to GET so the body is dropped; the browser stripping the sensitive header on the cross-origin hop; the target rejecting the request for a reason unrelated to CORS, such as a missing session or CSRF token; and a preflight actually being sent and approved, which makes the behaviour legitimate.

How it is fixed

Browsers should evaluate CORS for the redirect destination before replaying the request, or refuse to follow cross-origin redirects for requests that carry non-simple headers or bodies. Servers should not treat a header such as Content-Type as an authentication or CSRF defence on its own; they should require a token, check Origin and Sec-Fetch-Site, and reject cross-site requests to state-changing endpoints. Retiring plugin networking stacks removes a whole class of these gaps.

Hunting notes

This bug class hides where legacy clients, plugins or embedded browsers meet modern APIs: JSON endpoints, file upload handlers, and anything that trusts a content type. Recon signals include endpoints that return 307 or 308 redirects, APIs that document a JSON-only content type, and applications still loading NPAPI or similar plugin content.

Glossary

  • Request: a message a browser sends to a server asking it to do something, such as fetch a page or save data.
  • Header: a labelled line attached to a request or response carrying extra information, such as the data type or the destination of a redirect.
  • Origin: the scheme, host and port of a page, roughly which site it belongs to.
  • Same-origin: a request to the same site as the page that made it.
  • Cross-origin: a request to a different site from the page that made it.
  • CSRF (Cross-Site Request Forgery): an attack where a malicious page makes your browser send a request to another site while you are logged in there, so the site treats it as your own action.
  • CORS (Cross-Origin Resource Sharing): the browser mechanism that asks a server whether a cross-origin request may carry certain headers or methods.
  • Preflight: the separate permission check a browser sends before a cross-origin request with non-simple headers or methods.
  • Redirect: a server's answer telling the browser to go to a different address instead, given in the Location header.
  • 308 redirect: a redirect type that keeps the original method and body when following it.
  • Endpoint: a specific address on a server that accepts requests and performs an action.
  • NPAPI plugin: an old type of browser add-on, such as Flash, with its own networking code.
  • crossdomain.xml: a policy file a plugin fetches to learn which other sites may talk to it.
  • Same-origin policy: the browser rule limiting which responses a page may read from other sites.
  • JSON: a simple text format for structured data, often used as the body of API requests.
  • Content-Type: a header stating what kind of data a request body contains.
  • HTTP method: the verb of a request, such as GET (fetch) or POST (submit).
  • Session: the logged-in state a site keeps for you, usually tied to a cookie.
  • Cookie: a small piece of data the browser stores for a site and sends back with its requests.
  • Token: a value a server issues and expects back, used to prove a request came from a legitimate page.
  • Origin and Sec-Fetch-Site: headers a server can check to see where a request came from.
  • False positive: a test result that looks like a bug but is not one.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

CORS misconfiguration

The lesson behind this report.

A permissive cross-origin policy lets another site read responses with the user's credentials.