Skip to content

fix(browser): narrow native popup allow to genuine OAuth popups - #8332

Closed
AmethystLiang wants to merge 2 commits into
mainfrom
fix-f2-browser-popup-harden
Closed

AmethystLiang wants to merge 2 commits into
mainfrom
fix-f2-browser-popup-harden

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

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 for window.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 with SAFE_POPUP_WINDOW_OPTIONS (unchanged, OAuth-safe).
  • foreground-tab / background-tab (plain target=_blank, featureless window.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-window is 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 as new-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 — asserts foreground-tab / background-tab deny + shell.openExternal + opened-external popup 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 🐋

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]>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f25fbcff-c702-4469-bc4b-cb120f5c781f

📥 Commits

Reviewing files that changed from the base of the PR and between 3c4518a and fe1486f.

📒 Files selected for processing (2)
  • src/main/browser/browser-manager.test.ts
  • src/main/browser/browser-manager.ts

📝 Walkthrough

Walkthrough

Updated popup handling to require disposition: 'new-window' for native Electron child windows. Generic foreground-tab, background-tab, and unspecified dispositions are routed externally or blocked as appropriate, with renderer notifications preserved. Tests now cover external opening, popup messages, safe native popups, and child-window policy behavior using explicit dispositions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required template sections for Screenshots, AI Review Report, Security Audit, and Notes. Restructure it to match the repo template and add the missing sections, including screenshot status, testing checklist, AI review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: restricting native popups to genuine OAuth-style new-window requests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AmethystLiang

Copy link
Copy Markdown
Contributor Author

Closing without merging after review.

The disposition gate here is not the right fix: gating native-child popups on disposition === 'new-window' is (a) trivially bypassed — an abusive page just adds width=,height= to get 'new-window' — and (b) risks a regression for featureless window.open() OAuth/SSO flows that capture the returned handle (now null + routed to the OS browser, losing the shared session). Surveying prior art (Electron security docs, Jitsi SDK, Doyensec/Electronegativity), nobody gates popups on disposition; that's a UX hint, not a trust signal.

#7392's in-app popup is intentional and session-correct (the native child inherits the guest partition, so OAuth's shared cookies + window.opener handle survive). The real gap for a general-purpose browser pane is that a chrome-less Electron window has no address bar, so users can't verify a popup's origin — the actual phishing surface. The proper fix is an Orca-chrome popup surface with a visible origin bar (via setWindowOpenHandler's createWindow callback + overrideBrowserWindowOptions pinning secure webPreferences), tracked as its own feature.

Reverted the two-file change; new work moved to a fresh worktree.

AmethystLiang added a commit that referenced this pull request Jul 12, 2026
…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]>
@Jinwoo-H Jinwoo-H mentioned this pull request Aug 12, 2026
8 tasks done
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
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.

1 participant