Skip to content

Page guards for owned tabs: other extensions' frames no longer wedge a tab; popups join the session; host logs refusals (#81) - #84

Merged
SSFSKIM merged 4 commits into
mainfrom
fix/foreign-frames
Oct 8, 2026
Merged

SSFSKIM merged 4 commits into
mainfrom
fix/foreign-frames

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Closes #81

The bug

On the cua route, focusing any field in a tab where another extension draws a frame (the owner's input-helper pejdijmoenmkgeppbflobdenhhabjlaj, an invisible /completion_list.html iframe) made Chrome detach chrome.debugger and refuse every re-attach with Cannot access a chrome-extension:// URL of different extension. The tab was then undrivable for its life. Same Chrome session: vendor route 8/8 twice, cua route 0/8.

What the vendor extension actually does (read before implementing)

ChatGPT extension 1.26.901.11451, background.js (Mh, also shipped as content-scripts/foreign-frame-monitor.js):

  • What it does to the frame: in the isolated world it walks the document and every open or closed shadow root (chrome.dom.openOrClosedShadowRoot). For an <iframe> whose src is another extension's chrome-extension:// URL it sets srcdoc=""; for a <frame> it sets src="about:blank". It never removes or hides the element. A MutationObserver (childList, subtree, src) repeats this for every addition.
  • When: it is not a declared content script. It is injected with chrome.scripting.executeScript into every document of a leased tab on every session request that touches the tab (requireSessionTab: attach, attachTarget, executeCdp, createTab, claimUserTab, markTab) and when a leased tab starts loading. So it is in place before each attach and catches frames as they are inserted (both). It is removed at turn end.
  • Its attach path (Os) has no retry of its own. Recovery is the service's re-attach, which finds the frame already blanked.
  • Its popup interceptor (Rh in the page world, a bridge kh in the isolated world) sits behind a Statsig gate (codex-app-chrome-extension-background-popups). It replaces window.open and target-link clicks with a request; the extension turns that into a background tab claimed for the session. It also claims any child tab through webNavigation.onCreatedNavigationTarget.

What this PR builds

  • Extension (0.2.0): adds scripting and host_permissions: ["<all_urls>"]. No declared content script; injection works the way the vendor's does, and only into tabs the host owns (a user's other tabs never see cua code).
    • pageGuard (isolated world, every frame) blanks other extensions' frames the way the vendor does, on insertion and on the host's sweep. The sweep waits up to 1 s for the frames to unload.
    • pagePopups (page world, top frame only) takes a user-activated window.open (no target, or _blank) or a _blank link of an http(s) URL. It gives the page a stand-in window. Sized popups, which need window.opener, named targets and sandboxed frames are left to Chrome.
    • New primitives tabs.guard/tabs.unguard; tabs.create {openerTabId, guard}; a new notification tabs.popup. Each new document is guarded at commit.
  • Host:
    • Created tabs are guarded from creation, and every tab is swept before each attach (wait bounded at 1.5 s, so a JS dialog cannot hang the attach).
    • Cannot access a chrome-extension:// gets one more sweep and one retry.
    • A turn's end unguards handoff tabs and tabs it releases open (not awaited).
    • tabs.popup from the current turn's tab becomes a created tab of that turn, the session's active tab.
    • Every refused extension request is logged (method, debuggee/tab, CDP method, Chrome's message; never CDP params).
  • Tests (955: 954 pass, 1 skip):
    • A fake page (test/helpers/fake-page.mjs) runs the serialized page functions in two vm worlds under the chrome stub. The stub refuses the attach while another extension's frame is committed, and detaches when such a frame commits.
    • Contract tests cover: blanking, including inside closed shadow roots; re-guarding on navigation; unguard and port drop; the popup paths; the guard/unguard race.
    • Host tests with the fake extension cover: refusals logged with no params; sweep and retry once; a stalled guard; popup adoption and drop.
  • Spec: a Decision Log entry dated 2026-10-07 reverses "no content scripts" for exactly these two behaviours. Also updated: "The extension", the protocol table, "Page guards and popups", Progress, and Surprises (the probe numbers and tab creation 0.2–0.5 s on the cua host vs 8–10 s on the vendor route).
  • Plugin version 0.4.1.

Live (this Mac, helper enabled; docs/evidence/2026-10-07-foreign-frames-acceptance.md)

  • pm-probe: 8/8 fills, twice (was 0/8). Text fields read back 4/4. After every focus the helper's frame was present with srcdoc="". No attach refusal at all.
  • Popup: window.open from an agent tab was listed by cua.listTabs() 4 ms after the click, session-owned (origin: created), with no claim.
  • accept-chrome --live --route cua: 40/40 PASS. Vendor manifests sha256 unchanged.
  • The live run measured 59bbcf5. The review fixes in d7970a5 are proven under the stub only and need an extension reload.
  • Left as debt (tech-debt-tracker.md):
    • 4 recoverable detaches happened right at navigations (the vendor route shows the same).
    • Sized sign-in popups still open as user tabs.
    • The password field's value after a fill was replaced by something in the profile (not read).

Review

One opus reviewer on the high-rung brief found one P2: an open JS dialog would make attach and turnEnded hang on the guard injection. It also found three P3s: a guard/unguard race, named targets across frames, and the popup bridge in sandboxed frames. All four are fixed with tests in d7970a5.

…re Chrome detaches the debugger, route a page's window.open to the session; host sweeps and retries a foreign-frame attach refusal once and logs every refused extension request; spec Decision Log reverses 'no content scripts' for these two behaviours; extension 0.2.0, plugin 0.4.1
…d never for an unguard (an open dialog blocks chrome.scripting); an unguard racing a guard install wins; the popup interceptor runs in the top frame only and takes only new-context opens (no target or _blank), leaving named targets to Chrome
… 0/8), popup listed in the session without a claim, accept-chrome --route cua 40/40, vendor manifests unchanged; evidence, spec Progress and Surprises, debt; the stub's about:blank refusal now uses Chrome's wording
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T02:58:56.525812Z fb0c945 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…live): pm-probe 8/8 with no detach, popup in the session, accept-chrome --route cua 40/40, vendor manifests unchanged; evidence, spec Progress, debt
@SSFSKIM

SSFSKIM commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author

Live rerun on the branch head after the owner reloaded the extension (so d7970a5's review fixes are now measured live, not only under the stub): pm-probe 8/8 fills with the helper's frame blanked after every focus and no detach at all, popup listed in the session 9 ms after the click, accept-chrome --route cua 40/40, vendor manifests sha256 unchanged. Evidence appended in docs/evidence/2026-10-07-foreign-frames-acceptance.md.

@SSFSKIM
SSFSKIM merged commit 651d10c into main Oct 8, 2026
@SSFSKIM
SSFSKIM deleted the fix/foreign-frames branch October 8, 2026 03:00
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.

cua route: a foreign extension's iframe wedges the tab (port the vendor's foreign-frame monitor + popup interceptor; host logs refused requests)

1 participant