Skip to content

fix(browser): pause intercepted subresources instead of blocking them - #644

Open
marcoripa96 wants to merge 1 commit into
h4ckf0r0day:mainfrom
marcoripa96:fix/643-subresource-interception
Open

fix(browser): pause intercepted subresources instead of blocking them#644
marcoripa96 wants to merge 1 commit into
h4ckf0r0day:mainfrom
marcoripa96:fix/643-subresource-interception

Conversation

@marcoripa96

Copy link
Copy Markdown

Fixes #643.

should_block_url treated Fetch interception patterns as a block list, so any <script src> or <link rel="stylesheet"> matching them was dropped before fetch and the client never asked. Puppeteer's setRequestInterception(true) enables Fetch with pattern *, so in practice every subresource of every page silently vanished the moment a puppeteer client turned interception on, whatever its request handler intended — a handler aborting only *.css* lost all scripts too, and pages whose inline scripts depend on external ones died on ReferenceErrors with their JS-rendered content missing.

Changes:

  • should_block_url consults only Network.setBlockedURLs patterns.
  • Static subresource fetches (scripts, stylesheets, stylesheet @imports) matching active interception patterns are paused on the existing InterceptedRequest channel (the one op_fetch_url already uses for fetch()/XHR) and the client's verdict is obeyed: Continue (with URL override), Fail (skip the resource), Fulfill (use the provided response).
  • An empty pattern list intercepts everything, matching Fetch.enable's default and the library's enable_interception().
  • Fail-open on a closed channel or a client that does not answer within 5s, so a crashed or hung client cannot stall rendering.
  • linked_stylesheet_graph_fetches_once_and_preserves_order_and_bases encoded the old semantics (pattern match with no client attached = silent drop); it now attaches an interception client that refuses the matched stylesheet, which is the contract CDP specifies.

Test plan:

  • New crates/obscura/tests/subresource_interception.rs: a page with one stylesheet, one external script, and an inline script depending on it; the interception client aborts .css and continues the rest. On main the script never runs and neither request reaches the client; with the fix the script executes, the stylesheet is skipped, and both requests reach the client.
  • cargo nextest run -p obscura -p obscura-cdp -p obscura-cli -p obscura-mcp -p obscura-browser: 244 passed, 3 skipped.
  • Obstacle course: 32/33, identical to unpatched main (pre-existing observer-intersection failure, see fix(js): bind computed style methods passed through to the declaration #636's test plan).

should_block_url treated Fetch interception patterns as a block list, so
any script or stylesheet matching them was dropped before fetch and the
client never asked. Puppeteer's setRequestInterception enables Fetch with
pattern *, which made every subresource of every page silently vanish the
moment interception was on: a client aborting only *.css* lost all
scripts too, and WordPress pages died on "wp is not defined" with their
JS-rendered content missing.

Route matched static subresources (scripts, stylesheets, stylesheet
imports) through the existing InterceptedRequest channel and obey the
client's verdict: Continue (with URL override), Fail (skip), Fulfill
(use the provided response). Empty pattern list means intercept
everything, matching Fetch.enable's default and the library's
enable_interception(). Fail-open on a closed channel or a client that
does not answer within 5s so a crashed client cannot stall rendering.
should_block_url now consults only Network.setBlockedURLs patterns.

Fixes h4ckf0r0day#643
@SGavrl SGavrl closed this Aug 14, 2026
@SGavrl SGavrl reopened this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fetch interception blocks every matched subresource outright instead of pausing and asking the client

2 participants