`EventSource` in Web Workers bypasses the `connect-src` CSP directive
CSP's connect-src directive is not enforced for EventSource connections created inside a Web Worker, allowing an attacker to bypass the restriction and connect to arbitrary URLs.
- Fixed in 5 days
- Paid in 11 days
- Disclosed after 5 days
Created attachment 9568971 server.py
VULNERABILITY DETAILS
CSP is not properly enforced when instantiating an EventSource within a Web Worker. This allows an attacker to bypass the restrictive connect-src directive and establish connections to arbitrary URLs with EventSource.
VERSION
Firefox Version: 149.0.2 stable
The vulnerability is also present in Firefox 151.0a1 nightly
REPRODUCTION CASE
Steps to reproduce
- Run the attached
server.pywithpython3 server.pyto start the local server. - Navigate to either
http://127.0.0.1:1337/?bloborhttp://127.0.0.1:1337/?worker.jsin the browser. This will trigger the page to spawn a Web Worker using either a Blob URL or theworker.jsscript. - The worker will attempt to establish an
EventSourceconnection tohttp://127.0.0.1:1337/bypass?bloborhttp://127.0.0.1:1337/bypass?worker.js.
Expected results
The connection should be blocked by the connect-src 'none' CSP.
Actual results
The connection is successfully established.
CREDIT INFORMATION
Reporter credit: lebr0nli of National Yang Ming Chiao Tung University, Dept. of CS, Security and Systems Lab.
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
Impact
An attacker could bypass a restrictive connect-src CSP to establish EventSource connections to arbitrary URLs.
What the attacker needed
Victim visits a malicious page; page uses a Web Worker; CSP with connect-src 'none'
How it was found
- Run the attached server script to start a local server.
- Navigate to a URL that causes the page to spawn a Web Worker using either a Blob URL or a script file.
- The worker attempts to open an EventSource connection to a bypass endpoint.
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 that tells the browser which network connections a page is allowed to make. This report shows that when a page uses a background script called a Web Worker to open a special type of connection called EventSource, the browser ignores the rule that should block it. That means a malicious page could talk to servers it is not supposed to.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.