Skip to content

fix(browser): resolve authorized scope when Chrome masks frame URLs - #1411

Closed
BaaRai wants to merge 3 commits into
morluto:mainfrom
BaaRai:fix/cdp-masked-main-frame-url
Closed

BaaRai wants to merge 3 commits into
morluto:mainfrom
BaaRai:fix/cdp-masked-main-frame-url

Conversation

@BaaRai

@BaaRai BaaRai commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Implements the recovery described in #1384 at the gating surfaces. Linking the issue for the full protocol matrix; summary below.

Summary

Official Chrome and Chromium-for-Testing builds, at least 150 and 154, report masked values where CDP consumers expect URLs: Page.getFrameTree returns ":" (150) or "" (154) as the main-frame URL with securityOrigin: "://", Page.getNavigationHistory returns empty strings, DOMSnapshot documents carry no documentURL, and the storage agents reject or stall on every otherwise-valid request. Fedora's distro build of 154 reports real URLs, which is why this only reproduces on official builds. Every origin gate rejected these targets as out of scope, so inspect_web_page failed on the first call with target_not_allowed.

Scope resolution now falls back to the target URL that authorizeCdpTarget already gated the attach on, but only when a frame-tree URL carries no URL evidence at all; a parsed but out-of-scope origin still rejects, and parseable non-HTTP pages such as about:blank keep their existing wait semantics.

Problem and expected behavior

Smallest trigger: inspect_web_page (or npm run verify:browser) against any official Chrome-family build with an allowed origin. Reproduced on Kali Chromium 150.0.7871.181, Chrome-for-Testing 150.0.7871.124, and Chrome-for-Testing 154.0.8037.57; each rejected at authorizedMainFrame or the discovery gate before any capture.

Violated invariant: absence of URL evidence was treated as out-of-scope evidence. A frame tree that reports no parseable URL cannot prove the target left the authorized scope, and the attach was already authorized against the target URL, so rejecting discards an authorized observation without a contradicting fact.

Change and scope

  • CdpCaptureValues.ts: isUnparseableFrameUrl recognizes the masked placeholders (":", the empty string) while treating an absent field and parseable non-HTTP URLs as before.
  • CdpWebMcpDiscovery.ts: both gates resolve through authorizedMainFrameUrl, which falls back to the attach-authorized target URL only for URL-less evidence.
  • CdpAuthorizedMainFrame.ts: the same fallback ends the 80-poll wait that could never succeed; parseable non-HTTP URLs keep waiting.
  • CdpCaptureDocuments.ts: captureFrames recovers the root frame from the authorized target URL (child frames are unaffected); resolvedMainFrameUrl provides the attached/completed main-frame URLs, which previously crashed new URL(":") in captureStorage; captureDom recovers the leading DOM document's URL the same way.
  • CdpPageCapture.ts: threads the authorized target URL to the call sites above.
  • CdpCaptureStorage.ts: storage probes disclose browser-side command rejections as limitations (matching the sibling optional-command semantics) and skip the deeper fingerprint probes once their own discovery was unavailable, which also removes the stall where a fingerprint probe never responds.

Intentionally not included: the script and resource capture surfaces filter by masked URLs the same way and remain excluded with disclosed reasons on masked builds; finishing them is mechanical per surface or a unified authorized-origin pass, whichever you prefer. No contract or schema changes; the allowlist enforcement is unchanged, only its URL source when the frame tree reports none.

Contract and boundary impact

  • Semantic owner and earliest changed stage: browser provider capture (src/browser); no domain or contract changes.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: restores official Chrome-family builds as usable inspection targets; no change when frame trees report real URLs.
  • Evidence, artifact, provenance, or reconstruction contract: masked-run captures now disclose storage unavailability as limitations instead of failing the observation.
  • Process execution, authorization, cleanup, or containment impact: none; authorization semantics unchanged.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: none; the recovery is exercised end to end by the real-browser lane and the behavior on healthy builds is unchanged by construction (every fallback triggers only on URL-less evidence, which previously could only fail).
  • Base reproduction and other evidence, all on Linux x64, --headless=new:
    • Base: inspect_web_page fails target_not_allowed at the first gate on all three official builds; unmodified main also fails verify:browser on Chrome-for-Testing 154.
    • This change: on Chrome-for-Testing 154 the lane now runs the entire pipeline with the root frame and DOM document captured, storage unavailability disclosed as limitations, and no stall; it currently stops at the script-metadata assertion, which is the remaining script-surface work noted above.
    • Probe matrix across builds (frame-tree placeholder, securityOrigin, navigation history, target info) is in [Bug] inspect_web_page rejects every target on Chromium 150: Page.getFrameTree reports the opaque placeholder URL #1384; Target.getTargetInfo and the /json endpoint still report real URLs, which is what the fallback uses.
    • npm run check:fast passes.
  • User-visible CLI/MCP output: inspect_web_page returns complete observations on official Chrome builds instead of target_not_allowed; masked storage dimensions appear as disclosed limitations.

Official Chrome and Chromium-for-Testing builds, at least 150 and 154,
report masked values where CDP consumers expect URLs: Page.getFrameTree
returns ':' or '' as the main-frame URL with securityOrigin '://',
Page.getNavigationHistory returns empty strings, DOMSnapshot documents
carry no documentURL, and the storage agents reject or stall on every
otherwise-valid request. Every origin gate rejected these targets as
out of scope, so inspect_web_page failed on the first call.

Scope resolution now falls back to the target URL that authorizeCdpTarget
already gated the attach on whenever a frame-tree URL carries no URL
evidence at all, while a parsed but out-of-scope origin still rejects.
The recovery covers the discovery and capture gates, the root frame,
the attached and completed main-frame URLs, and the leading DOM
document; storage probes disclose browser-side rejections as
limitations and skip the deeper fingerprint probes whose discovery
already failed.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

The masked-frame fallback returned on the first placeholder read, but ':'
is also the pre-commit transitional value, so committed navigations landed
on the target URL and failed as target_changed. Fall back only once the
commit wait is exhausted, which a masked build never satisfies.

Narrow storageOptionalCommand to the frame-not-found rejection family so
protocol failures stay fatal, and restore the dropped await on captureJsonResponseBodies
whose pending body fetch surfaced as disconnected during session close.
'Frame not found for the given storage id' does not contain the substring
'frame found', so the first probe still threw protocol_error. Match on
frame and found separately to cover all three wordings the masked storage
agents use.
@BaaRai

BaaRai commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

The earlier red CI was on me, three separate causes, all fixed in 6ff26b2 and 08a6aab:

  • a stray dropped await on captureJsonResponseBodies left a body fetch in flight at session close, which surfaced as disconnected on the real-browser lane and swallowed a protocol_error the network tests expect
  • the masked-URL fallback fired on the first placeholder read, but ':' is also the pre-commit transitional value, so committed navigations landed on the target URL and tripped target_changed. The fallback now applies only once the commit wait is exhausted, which a masked build never satisfies
  • the storage tolerance matched one wording only; 'Frame not found for the given storage id' does not contain 'frame found'. It now covers all three frame-not-found wordings while other rejections stay fatal

Reran the real lane against the masked CfT 154 build locally: capture now completes through frames, DOM, storage and network, stopping exactly at the script metadata assertion noted above, which is the part left open for your call.

@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: The latest head, 08a6aab5, passes everything I ran. That covers three Node versions and a real browser.

npm run verify:browser, Node 24:

Code Fedora Chromium Google's test build
08a6aab5 pass, 1 of 1 not run
6ff26b2a pass, 3 of 3 pass, 2 of 2

Both browsers are at 154.0.8037.57. The Chromium license is BSD-3-Clause. The only change from 6ff26b2a to 08a6aab5 is the storage message check.

Browser unit tests, src/browser and tests/boundary/browser:

Code Node 22 Node 24 Node 26
08a6aab5 533 pass 533 pass 533 pass

Your 03:48Z commit also covers the storage message I saw from Chromium 154. It was "Frame not found for the given storage id".

Neither browser here masks URLs. So the masked path never ran. More on that is in #1384.

Not run:

  • The masked path, since I could not get a mask.
  • 08a6aab5 on Google's test build.
  • verify:browser on Node 22 or 26.
  • The full test suite. I only ran the browser tests.

Thanks, BaaRai, for the quick fixes.

The first head and what changed

On 23744663, the CI real-browser crash came from a dropped await on captureJsonResponseBodies. I saw the same crash here. 6ff26b2a puts the await back. That line now matches main.

6ff26b2a also made the masked fallback wait its turn. It now waits for the page to load first. Then 08a6aab5 made the storage check match more messages.

Storage messages

I checked all three messages against the new rule. The rule is code -32000 or -32602, and the text holds both "frame" and "found".

Code Message Matches
-32000 Frame not found for the given storage id yes
-32000 No document for given frame found yes
-32602 No frame found for given storage key yes

I saw the first two live from Chromium 154. The third is the one you quoted. My probe did not get that error here.

Commands
REA_BROWSER_EXECUTABLE=<browser> TMPDIR=<short dir> npm run verify:browser
npx vitest run src/browser tests/boundary/browser
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: 08a6aab5 / 7aa4d768
  • Chromium (BSD-3-Clause): the one from Fedora 44, at 154.0.8037.57
  • Google's official Chrome for Testing build: the zip for Linux, at 154.0.8037.57

🤖 Generated with Claude Code (Opus 5.5) 🦊

@BaaRai

BaaRai commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #1432. The premise of this PR was wrong: the frame tree was not carrying masked URLs, the page had never loaded at all, because headless Chrome stalled on a reachable-but-locked desktop keyring over the session bus (full chain on #1384). The fallbacks here would authorize capturing an uncommitted about:blank against the attach-authorized target URL, which is fail-open against that failure mode. Keeping REA strict when the frame never commits is the right call; the launchers now pass --password-store=basic so verification browsers cannot hit the stall. Thanks for the CI feedback, the three follow-up fixes (commit-wait exhaustion, frame-not-found wording, dropped await) were correct but landed in the wrong premise.

@BaaRai BaaRai closed this Oct 10, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants