Skip to content

fix: host browser popups in an Orca origin-bar window instead of chrome-less child windows - #8343

Merged
AmethystLiang merged 3 commits into
mainfrom
oauth-popup-origin-bar
Jul 12, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
oauth-popup-origin-bar

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

PR #7392 made BrowserManager.setWindowOpenHandler allow 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 live window.opener handle — 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 via width=,height= features, breaks featureless window.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's createWindow callback.

New src/main/browser/popup-origin-bar-window.ts builds a BaseWindow with:

  • an origin-bar WebContentsView on 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 on did-navigate, with a "Not secure" badge for plain http to remote hosts (loopback exempt);
  • a content WebContentsView that adopts the pre-created popup WebContents Electron passes through createWindow's options — this adoption is what preserves window.opener and the inherited session.

browser-manager.ts changes:

  • the allow branch returns a createWindow callback that opens the origin-bar window, attaches guest policies to the popup contents directly (did-create-window is not emitted for createWindow children), forwards the existing opened-in-orca renderer notice (sanitized origin only), and closes the popup when its opener guest is destroyed (parity with Electron's default child lifecycle);
  • SAFE_POPUP_WINDOW_OPTIONS now pins secure webPreferences (contextIsolation: true, nodeIntegration: false, nodeIntegrationInSubFrames: false, sandbox: true, webviewTag: false, allowRunningInsecureContent: false) — these are applied by Electron when it creates the popup contents, before createWindow runs.

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 featureless window.open('about:blank'):

  • window.open() returned a live handle; opener successfully wrote into the child (handle-ok|write-ok)
  • child sees non-null window.opener
  • popup contents share the guest's session partition
  • origin bar renders at the top (34px), content gets the full requested size (useContentSize)
  • close wiring: window close ↔ content close, onClosed fires

Also confirmed at runtime: createWindow's options include the pre-created webContents, and did-create-window does not fire for createWindow children (hence the direct policy attach).

Tests

  • popup-origin-bar-window.test.ts (13 tests): contents adoption, origin-only rendering (asserts OAuth code=SECRET never 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 that createWindow adopts the pre-created contents, attaches guest policies to the popup, emits sanitized opened-in-orca, closes popups with their opener, and keeps recursive popup routing.

vitest src/main/browser/: 26 files, 452 tests pass. Typecheck + oxlint clean. (The verify:localization-catalog failure on this branch is pre-existing on main — UsagePercentageDisplayChangeNotice.tsx.)

Notes / residual

  • The origin bar inlines the styleguide token values (data: URL pages can't import main.css); light/dark via prefers-color-scheme.
  • Cross-platform: BaseWindow/WebContentsView are cross-platform; no path/shortcut/platform assumptions. Popups are always local renderer surfaces, so SSH workspaces are unaffected.

Made with Orca 🐋

…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]>
@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: 755c63ff-c761-45a1-bf26-88589d9a514b

📥 Commits

Reviewing files that changed from the base of the PR and between 925bccc and 4a7f6ee.

📒 Files selected for processing (2)
  • src/main/browser/popup-origin-bar-window.test.ts
  • src/main/browser/popup-origin-bar-window.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/browser/popup-origin-bar-window.ts

📝 Walkthrough

Walkthrough

Adds 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)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: replacing chrome-less child windows with Orca origin-bar popup windows.
Description check ✅ Passed The description is substantial and covers the change, validation, tests, and notes; a few template sections are not spelled out.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/browser/browser-manager.ts (1)

150-176: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Presentational SAFE_POPUP_WINDOW_OPTIONS fields are now dead once createWindow is used.

Once createWindow is provided, Electron calls it "instead of new BrowserWindow" — no native window is constructed from overrideBrowserWindowOptions. openPopupWithOriginBar's BaseWindow only reads width/height/x/y/minWidth/minHeight/title from the passed options (see popup-origin-bar-window.ts lines 99-111), so alwaysOnTop, closable, focusable, frame, fullscreen, kiosk, modal, movable, opacity, show, simpleFullscreen, skipTaskbar, titleBarStyle, and transparent are silently ignored for popups routed through this path. Only webPreferences still has effect (Electron applies it when constructing the underlying WebContents before createWindow runs).

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 that createWindow owns 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

📥 Commits

Reviewing files that changed from the base of the PR and between e5efbc9 and 384e091.

📒 Files selected for processing (4)
  • src/main/browser/browser-manager.test.ts
  • src/main/browser/browser-manager.ts
  • src/main/browser/popup-origin-bar-window.test.ts
  • src/main/browser/popup-origin-bar-window.ts

AmethystLiang and others added 2 commits July 11, 2026 20:03
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]>
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

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:

  1. Origin bar clipped the end of long hostnames — window.open('https://accounts.google.com.<...>.evil-phisher.com', '', 'width=360') rendered as https://accounts.google.com.signin.s…, hiding the registrable domain. Now elides the start (rtl clip container + isolated ltr bdi), so the same attack renders ….verification.evil-phisher.com. Verified with a real-Electron screenshot at the 360px minimum width.
  2. Fail-silent origin write — a transiently dropped executeJavaScript could leave a stale origin up; the bar now re-asserts on the popup's did-finish-load.

Also runtime-verified the reviewer's fullscreen-escape concern: HTML5 requestFullscreen() from popup content makes the window fullscreen but the origin bar stays pinned on top (and re-pins via explicit enter/leave-full-screen handlers now, for platforms where resize might not fire). Test hardening: the fake WebContents flips isDestroyed after destroyed, so the double-close guard is genuinely exercised.

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.

@AmethystLiang
AmethystLiang merged commit 01dcbcb into main Jul 12, 2026
2 checks passed
@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