Repository navigation
fix(browser): narrow native popup allow to genuine OAuth popups - #8332
AmethystLiang wants to merge 2 commits into
Conversation
setWindowOpenHandler granted a native Electron child window for any http(s) URL when the guest owned a registered browser tab. That gave every embedded page the popup privilege OAuth needs, widening the phishing / window-spam surface. Gate the native child on Chromium's 'new-window' disposition — the window.open(features) / shift-click popup pattern OAuth uses. Ordinary target=_blank clicks and featureless window.open() (foreground-tab / background-tab) now route to the OS browser like unregistered guests, while file:/javascript: denial, SAFE_POPUP_WINDOW_OPTIONS, guest policy inheritance, and the unregistered external fallback are preserved. 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)
📝 WalkthroughWalkthroughUpdated popup handling to require 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
This reverts commit fe1486f.
|
Closing without merging after review. The disposition gate here is not the right fix: gating native-child popups on #7392's in-app popup is intentional and session-correct (the native child inherits the guest partition, so OAuth's shared cookies + Reverted the two-file change; new work moved to a fresh worktree. |
…me-less child windows (#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 #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]> * 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]>
…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
BrowserManager.setWindowOpenHandler(src/main/browser/browser-manager.ts) granted a native Electron child window (action: 'allow') for any http(s) URL whenever the guest owned a registered browser tab (canOpenAsChild). Introduced in #7392 to unblock OAuth popups, this gave every embedded page in any Orca browser tab the same native-window privilege — a phishing / window-spam surface. Before #7392, ordinary navigations were routed into Orca tabs / the external browser.Fix
Gate the native-child allow on Chromium's
disposition === 'new-window'— the signal Chromium emits forwindow.open()with window features (and shift-click), i.e. the OAuth / consent-dialog popup pattern. Everything else is narrowed:new-window(OAuth popups) → native child withSAFE_POPUP_WINDOW_OPTIONS(unchanged, OAuth-safe).foreground-tab/background-tab(plaintarget=_blank, featurelesswindow.open()) → routed to the OS browser via the existing external-URL branch, exactly like unregistered guests. No native Orca-chrome window for arbitrary pages.Preserved unchanged:
file:/javascript:denial,SAFE_POPUP_WINDOW_OPTIONS, guest-policy inheritance on children, and the unregistered-guest external fallback.Why
new-windowis OAuth-safe: real interactive OAuth popups (Google Identity, Auth0, Firebase, MSAL, Stripe, GitHub) all open a sized centered window (window.open(url, name, 'width=…,height=…')), which Chromium reports asnew-window. Featureless opens that become full tabs don't rely on native popup chrome.Tests
Updated the existing allow-path tests to pass
disposition: 'new-window', and added:routes generic target=_blank navigations to the OS browser instead of a native child— assertsforeground-tab/background-tabdeny +shell.openExternal+opened-externalpopup event.does not grant a native child for a registered guest when disposition is absent— asserts the default/absent disposition falls through to the external fallback.All 439 browser tests pass;
tsc(node project) clean; oxlint clean; max-lines ratchet OK.Made with Orca 🐋