bypass CSP with fetch with keepalive: true
A browser-specific flaw in Firefox allowed a fetch request with the keepalive option set to true to bypass the site's Content-Security-Policy, while the same request with keepalive false was blocked. An attacker could use this to send data to an external endpoint that the CSP was meant to forbid.
Originally disclosed on Mozilla
- Fixed in 12 days
- Paid in 21 days
- Disclosed after 12 days
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Steps to reproduce:
I verified that on the website https://www.meo.pt it's possible to bypass the Content-Security-Policy by adding the `keepalive` parameter to `true` in the fetch request.
Example where the CSP works and the request is blocked: `fetch("https://mpc-prod-27-s6uit34pua-uk.a.run.app/events?cee=no", { method: 'POST', keepalive: false });`
Example of bypassing the CSP: `fetch("https://mpc-prod-27-s6uit34pua-uk.a.run.app/events?cee=no", { method: 'POST', keepalive: true});`
In Chrome and Edge, you can see that both requests are blocked as expected.
Actual results:
The request with `keepalive` set to `true` is not blocked.
Expected results:
e request with `keepalive` set to `true` should be blocked as expected, just as it happens in Chrome and Edge.
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 browser did not apply the page's Content-Security-Policy checks to fetch requests made with the keepalive option enabled.
Impact
An attacker who can run script on the page could send data to an external endpoint that the CSP was intended to block, but only in Firefox; Chrome and Edge blocked both requests.
What the attacker needed
Firefox browser; ability to run script on the page
How it was found
- Open the website in Firefox.
- Send a fetch request with keepalive set to false and observe it is blocked by CSP.
- Send the same fetch request with keepalive set to true and observe it is not blocked.
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 Content-Security-Policy (CSP) is a rule set a website sends to your browser telling it which other sites it may talk to. Here, Firefox ignored those rules for one specific kind of request (one marked to keep running even if the page closes), so data could be sent to a server the site had tried to block. Chrome and Edge did not have this problem.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.