SharedWorker and AudioWorklet bypass --blockedUrlPattern/--allowedUrlPattern

Aperta
#3,399 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
8/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, typescript
Ambito
devtools, security

Direzione di ricerca

The bypass sits in how Puppeteer enforces the URL allow/block callbacks: build/src/third_party/index.js (#maybeSetupNetworkConditions, #attachToServiceWorkers) and the MCP side in src/utils/logger.ts and src/bin/chrome-devtools.ts. Reproduce with the PoC scripts described in the issue and a local server on 127.0.0.1:18999 and 19000. Done means shared-worker and audio-worklet loads are blocked under both flags, with tests, plus the status args redaction fix.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

confirmed p3

Version: 1.12.0 (npm), Chrome 156, Windows 11, bundled puppeteer-core 25.16.0.

Description

A page can bypass both network guardrail flags by issuing requests from a
SharedWorker. The page's own fetch and the same fetch from a dedicated
Worker are blocked; the identical fetch from a SharedWorker reaches the
blocked origin and returns its body.

The worker needs no server-side script: a blob worker created with
new SharedWorker(URL.createObjectURL(new Blob([...]))) is enough, so any page
that can run JavaScript is sufficient.

Impact: with --allowedUrlPattern, an allowed page can reach arbitrary
excluded origins, read CORS-enabled responses (including intranet/admin
endpoints) and trigger side effects; the same applies to blocked origins under
--blockedUrlPattern. Exfiltrated bodies can be posted back through the
MessagePort into the allowed page DOM, where the server returns them.

This is distinct from the service-worker bypass (#2990, fixed): the fix only
added service_worker handling. Shared workers are still unhandled on
puppeteer/main.

Reproduction

The PoCs are standalone (Node 24, Chrome 156; set PUPPETEER_BASE to a
directory where puppeteer resolves if it is not installed in the cwd).
poc-server.mjs starts 127.0.0.1:18999 (allowed) and 127.0.0.1:19000
(blocked) and always sends Access-Control-Allow-Origin: *.

node poc-server.mjs                    # terminal 1
node poc-shared-worker.mjs allowlist   # terminal 2
node poc-shared-worker.mjs blocklist

The scripts pass the patterns directly to puppeteer.launch({allowlist}) /
({blocklist}), which is what the MCP server does with the CLI flags.

The same was reproduced end-to-end through the MCP server with
--allowedUrlPattern=http://127.0.0.1:18999/* (and with
--blockedUrlPattern=*://127.0.0.1:19000/*), navigating to the allowed page
and running the page script above.

Observed, both list types:

control fetch          ERR:TypeError: Failed to fetch
dedicated worker       ERR:TypeError: Failed to fetch
shared worker (bypass) OK:{"label":"blocked","path":"/ping"}

Also reproduced from https://example.com with --allowedUrlPattern=https://example.com/*:
the page and a blob dedicated worker cannot reach https://example.org, the
blob shared worker can.

Second vector: AudioWorklet

AudioWorklet.addModule() needs no user gesture and loads its module from the
audio service rather than the page's network context. The same allowlist /
blocklist is not applied, and the module executes (registerProcessor, then
new AudioWorkletNode(...) succeeds). This also works with
--no-javascript-evaluation, from page inline script only.

const ac = new AudioContext();
await ac.audioWorklet.addModule('http://127.0.0.1:19000/audioworklet.js');
const node = new AudioWorkletNode(ac, 'w');
node.port.onmessage = e => console.log(e.data);   // worklet code ran

AudioWorkletGlobalScope has no fetch, so this vector gives code execution
from an excluded origin rather than body exfiltration.

Mechanism detail (page session): Network.setBlockedURLs does not block the
module load, Fetch interception does. For shared workers it is the opposite
(setBlockedURLs works, Fetch.enable on the worker session does not). Neither
single mechanism closes both.

Confirmed blocked neighbours: paint worklet, animation worklet, FontFace,
<audio>/<video>, fetch, workers, iframes, navigations.

Root cause

BlocklistCallback/AllowlistCallback are forwarded to Puppeteer, which
enforces them with Network.emulateNetworkConditionsByRule. That command is a
silent no-op on shared_worker sessions. Fetch.enable on the session is also
a no-op; Network.setBlockedURLs works. Audio worklet modules are loaded by the
audio service, outside the page's network context, and no worklet target exists
to attach, so the page-session rule never sees them either. See
build/src/third_party/index.js #attachToServiceWorkers (service workers
only) and #maybeSetupNetworkConditions.

Expectation

The same fetch inside a shared worker, and the audio worklet module load,
should fail, for both flags.

Fix options

  • Puppeteer: send Network.setBlockedURLs on shared-worker sessions
    (blocklist works today); enforce page sessions with Fetch interception
    (required for audio worklets). Document the allowlist gap until a mechanism
    or a Chrome fix exists.
  • MCP: bump Puppeteer; optionally add the page-session Fetch enforcement in
    McpPage/McpContext and document both exceptions in puppeteer-options.ts,
    docs/configuration.md and SECURITY.md in the meantime.

Separate minor finding: status leaks daemon arguments

chrome-devtools status prints DaemonStatusResult.args unredacted:

args=["--viaCli","--ws-endpoint=ws://127.0.0.1:65535/devtools/browser/x?token=SECRET","--ws-headers={\"Authorization\":\"Bearer TOPSECRET\"}"]

redactDaemonArgsForLogging already exists in src/utils/logger.ts and is
applied by daemon/client.ts before the start log, but the daemon stores and
returns the raw mcpArgs and src/bin/chrome-devtools.ts prints
JSON.stringify(data.args). status is the documented health check, so
bearer tokens end up in pasted reports and CI logs. Redacting in the daemon
when building the status result (or applying the helper before printing) fixes
it.

Lingua principale
TypeScript
Stelle
59.8k
Fork
4.8k
Merge medio
2g 10h
PR unite (30g)
162

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ChromeDevTools/chrome-devtools-mcp

Tutte le issue di ChromeDevTools/chrome-devtools-mcp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.