Repository navigation
fix: host browser popups in an Orca origin-bar window instead of chrome-less child windows - #8343
Conversation
…me-less child windows A guest-opened popup previously became a default Electron child window with no address bar, so users could not verify a popup's origin — a phishing surface flagged in the prod-release scan of #7392. The reverted #8332 tried gating on disposition, which is bypassable and breaks featureless window.open() OAuth flows. Instead, keep hosting popups in-app (preserving the shared session partition and live window.opener handle OAuth depends on) but build the child window ourselves via setWindowOpenHandler's createWindow callback: a BaseWindow with an Orca-controlled origin-bar WebContentsView on top and a content WebContentsView that adopts the pre-created popup WebContents. The bar shows only the destination origin (never path or query), updates on navigation, and flags plain http to remote hosts. Also pins secure webPreferences (contextIsolation, no nodeIntegration, sandbox, no webviewTag) on popup children via SAFE_POPUP_WINDOW_OPTIONS, attaches guest policies to popup contents directly (did-create-window does not fire for createWindow children), emits the existing opened-in-orca renderer notice, and closes popups with their opener guest. Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds an origin-bar window utility that hosts popup web contents, displays sanitized origins, applies locked-down preferences, updates on navigation, and manages cleanup. Browser-manager popup handling now uses this utility for allowed child windows, inherits opener guest policies, forwards sanitized popup events, supports recursive popups, and closes children with their opener. Tests expand coverage for origin parsing, layout, security settings, lifecycle behavior, and popup routing. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/browser/browser-manager.ts (1)
150-176: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPresentational
SAFE_POPUP_WINDOW_OPTIONSfields are now dead oncecreateWindowis used.Once
createWindowis provided, Electron calls it "instead ofnew BrowserWindow" — no native window is constructed fromoverrideBrowserWindowOptions.openPopupWithOriginBar'sBaseWindowonly readswidth/height/x/y/minWidth/minHeight/titlefrom the passed options (seepopup-origin-bar-window.tslines 99-111), soalwaysOnTop,closable,focusable,frame,fullscreen,kiosk,modal,movable,opacity,show,simpleFullscreen,skipTaskbar,titleBarStyle, andtransparentare silently ignored for popups routed through this path. OnlywebPreferencesstill has effect (Electron applies it when constructing the underlyingWebContentsbeforecreateWindowruns).Leaving these dead fields in place in a security-hardening constant risks a future maintainer believing they still constrain popup chrome/behavior. Consider trimming this object to just
webPreferences, or add a comment noting the rest is vestigial now thatcreateWindowowns window creation.Suggested comment clarifying dead fields
const SAFE_POPUP_WINDOW_OPTIONS = { + // Note: only `webPreferences` below has any effect once `createWindow` + // (see setWindowOpenHandler usage) takes over window creation — Electron + // never applies the presentational fields below in that path. alwaysOnTop: false,
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: aa6eec0c-0721-433b-9bcf-6373c5bd740f
📒 Files selected for processing (4)
src/main/browser/browser-manager.test.tssrc/main/browser/browser-manager.tssrc/main/browser/popup-origin-bar-window.test.tssrc/main/browser/popup-origin-bar-window.ts
The native title bar and the origin bar both showed the origin, reading as a doubled header. Match Chrome popup behavior: title bar shows the page title (reset to origin on navigation so a stale title cannot outlive its origin); the origin bar below remains the unspoofable trust surface. Co-authored-by: Orca <[email protected]>
…stays visible
Adversarial review findings on the origin bar:
- The bar right-ellipsized long hostnames, hiding exactly the part that
matters: window.open('https://accounts.google.com.<...>.evil.com',
'', 'width=360') rendered as 'https://accounts.google.com.signin.s…'.
Clip from the left instead (rtl container + isolated ltr bdi so host
and port keep normal character order), matching how Chrome elides.
- Re-assert the origin on the popup's did-finish-load so a transiently
dropped executeJavaScript write cannot leave a stale origin up.
- Re-pin view layout on enter/leave-full-screen: verified at runtime
that HTML5 fullscreen keeps the bar visible on macOS (resize fires);
the explicit events make that hold on every platform.
- Test hardening: fake WebContents now flips isDestroyed after
'destroyed' so the double-close guard is actually exercised.
Co-authored-by: Orca <[email protected]>
|
Adversarial code review (subagent) completed against the branch — no hard-invariant violations (OAuth handle/session preservation, no disposition gating, file:/javascript: denial, origin-only rendering, lifecycle cleanup, cross-platform all CONFIRMED). Two real findings, both fixed in 4a7f6ee:
Also runtime-verified the reviewer's fullscreen-escape concern: HTML5 One accepted behavior worth reviewer sign-off: popups close when their opener guest is destroyed (parity with Electron's default child-window lifecycle), which includes browser-pane remounts that re-register the guest — an in-flight OAuth popup closes in that case. |
…me-less child windows (stablyai#8343) * fix: host browser popups in an Orca origin-bar window instead of chrome-less child windows A guest-opened popup previously became a default Electron child window with no address bar, so users could not verify a popup's origin — a phishing surface flagged in the prod-release scan of stablyai#7392. The reverted stablyai#8332 tried gating on disposition, which is bypassable and breaks featureless window.open() OAuth flows. Instead, keep hosting popups in-app (preserving the shared session partition and live window.opener handle OAuth depends on) but build the child window ourselves via setWindowOpenHandler's createWindow callback: a BaseWindow with an Orca-controlled origin-bar WebContentsView on top and a content WebContentsView that adopts the pre-created popup WebContents. The bar shows only the destination origin (never path or query), updates on navigation, and flags plain http to remote hosts. Also pins secure webPreferences (contextIsolation, no nodeIntegration, sandbox, no webviewTag) on popup children via SAFE_POPUP_WINDOW_OPTIONS, attaches guest policies to popup contents directly (did-create-window does not fire for createWindow children), emits the existing opened-in-orca renderer notice, and closes popups with their opener guest. Co-authored-by: Orca <[email protected]> * fix: show page title in popup title bar instead of doubling the origin The native title bar and the origin bar both showed the origin, reading as a doubled header. Match Chrome popup behavior: title bar shows the page title (reset to origin on navigation so a stale title cannot outlive its origin); the origin bar below remains the unspoofable trust surface. Co-authored-by: Orca <[email protected]> * fix: elide the start of long popup origins so the registrable domain stays visible Adversarial review findings on the origin bar: - The bar right-ellipsized long hostnames, hiding exactly the part that matters: window.open('https://accounts.google.com.<...>.evil.com', '', 'width=360') rendered as 'https://accounts.google.com.signin.s…'. Clip from the left instead (rtl container + isolated ltr bdi so host and port keep normal character order), matching how Chrome elides. - Re-assert the origin on the popup's did-finish-load so a transiently dropped executeJavaScript write cannot leave a stale origin up. - Re-pin view layout on enter/leave-full-screen: verified at runtime that HTML5 fullscreen keeps the bar visible on macOS (resize fires); the explicit events make that hold on every platform. - Test hardening: fake WebContents now flips isDestroyed after 'destroyed' so the double-close guard is actually exercised. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
Problem
PR #7392 made
BrowserManager.setWindowOpenHandlerallow any http(s) popup from a registered browser tab as a native Electron child window. That design is correct for OAuth — the child inherits the guest's session partition and keeps a livewindow.openerhandle — but the resulting window is effectively chrome-less: no address bar, so users cannot verify a popup's destination. Since Orca's browser pane is general-purpose, an origin allowlist doesn't apply, and a phishing page can open a convincing fake-login popup.The first attempt (#8332) gated the allow on
disposition === 'new-window'and was reverted: trivially bypassed viawidth=,height=features, breaks featurelesswindow.open()OAuth flows that need the returned handle, and disposition is a UX hint, not a trust signal.Approach
Keep #7392's core design (popups stay in-app with shared session + opener handle) and fix the actual gap: give popups Orca's own chrome with a visible destination-origin bar, via
setWindowOpenHandler'screateWindowcallback.New
src/main/browser/popup-origin-bar-window.tsbuilds aBaseWindowwith:WebContentsViewon top — Orca-controlled, sandboxed, isolated from the popup content, showing only the popup's current origin (never path/query, which routinely carry OAuth codes), updating ondid-navigate, with a "Not secure" badge for plain http to remote hosts (loopback exempt);WebContentsViewthat adopts the pre-created popupWebContentsElectron passes throughcreateWindow's options — this adoption is what preserveswindow.openerand the inherited session.browser-manager.tschanges:createWindowcallback that opens the origin-bar window, attaches guest policies to the popup contents directly (did-create-windowis not emitted forcreateWindowchildren), forwards the existingopened-in-orcarenderer notice (sanitized origin only), and closes the popup when its opener guest is destroyed (parity with Electron's default child lifecycle);SAFE_POPUP_WINDOW_OPTIONSnow pins securewebPreferences(contextIsolation: true,nodeIntegration: false,nodeIntegrationInSubFrames: false,sandbox: true,webviewTag: false,allowRunningInsecureContent: false) — these are applied by Electron when it creates the popup contents, beforecreateWindowruns.Everything else from #7392 is preserved:
file:/javascript:denial, guest-policy inheritance on popup descendants, unregistered-guest external fallback, Kagi token redaction.OAuth safety validation (real Electron 43, real
<webview>)Ran a runtime harness driving the bundled module exactly as browser-manager does —
<webview allowpopups>guest calls featurelesswindow.open('about:blank'):window.open()returned a live handle; opener successfully wrote into the child (handle-ok|write-ok)window.openeruseContentSize)onClosedfiresAlso confirmed at runtime:
createWindow's options include the pre-createdwebContents, anddid-create-windowdoes not fire forcreateWindowchildren (hence the direct policy attach).Tests
popup-origin-bar-window.test.ts(13 tests): contents adoption, origin-only rendering (asserts OAuthcode=SECRETnever reaches the bar), navigation updates + insecure badge, loopback-http exemption, layout, locked-down bar webPreferences, close wiring both directions.browser-manager.test.ts: updated allow-path assertion to include the webPreferences pins +createWindow; new regression test that featureless popups stay allowed for every disposition (fails under the reverted fix(browser): narrow native popup allow to genuine OAuth popups #8332 gate); new test thatcreateWindowadopts the pre-created contents, attaches guest policies to the popup, emits sanitizedopened-in-orca, closes popups with their opener, and keeps recursive popup routing.vitest src/main/browser/: 26 files, 452 tests pass. Typecheck + oxlint clean. (Theverify:localization-catalogfailure on this branch is pre-existing on main —UsagePercentageDisplayChangeNotice.tsx.)Notes / residual
main.css); light/dark viaprefers-color-scheme.BaseWindow/WebContentsVieware cross-platform; no path/shortcut/platform assumptions. Popups are always local renderer surfaces, so SSH workspaces are unaffected.Made with Orca 🐋