Skip to content

fix(browser): allow trusted embedded popup windows - #7392

Merged
Jinwoo-H merged 2 commits into
stablyai:mainfrom
rodboev:pr/orca-7374-embedded-oauth-popups
Jul 10, 2026
Merged

Jinwoo-H merged 2 commits into
stablyai:mainfrom
rodboev:pr/orca-7374-embedded-oauth-popups

Conversation

@rodboev

@rodboev rodboev commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Allow trusted embedded browser popup requests to create real Electron popup windows instead of rerouting them into Orca browser tabs.
  • Keep unregistered safe popups on the existing external-browser fallback and keep unsafe popup URLs denied with sanitized metadata only.
  • Attach the same BrowserManager guest policy to any child popup WebContents that Electron creates.

Closes #7374.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/browser/browser-manager.test.ts -t "allows registered safe popup URLs as Electron child windows" - passed.
  • pnpm exec vitest run --config config/vitest.config.ts src/main/browser/browser-manager.test.ts -t "falls back to opening popup URLs externally before a guest is registered" - passed.
  • pnpm exec vitest run --config config/vitest.config.ts src/main/browser/browser-manager.test.ts -t "blocks unsafe popup URLs for registered guests" - passed.
  • pnpm exec vitest run --config config/vitest.config.ts src/main/browser/browser-manager.test.ts -t "attaches guest policies to created popup child windows" - passed.
  • pnpm exec vitest run --config config/vitest.config.ts src/main/browser/browser-manager.test.ts - passed.
  • pnpm run typecheck:node - passed.

AI Review Report

No issues found in the final diff review.

  • Platform coverage: popup policy stays in BrowserManager and uses Electron's child-window lifecycle, which is shared across macOS, Linux, and Windows.
  • SSH, terminal, provider integration, command execution, filesystem, and visual UI paths are unchanged.
  • The allow path only applies to registered guests that normalize to a browser URL.

Security Audit

No new security issues found.

  • Popup URL validation stays centralized through normalizeBrowserNavigationUrl.
  • Unregistered safe URLs still use the redacted external handoff path.
  • Unsafe URLs, including javascript:alert(1), still deny with sanitized origin metadata.
  • Child popup WebContents inherits BrowserManager navigation guards and anti-detection setup through attachGuestPolicies.

Notes

No visual change. Out of scope: claiming that every OAuth provider accepts Electron embedded browsers. Some providers can still reject embedded user agents independently of popup support.

@coderabbitai

coderabbitai Bot commented Jul 5, 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: 89d8287e-b0ff-4811-880a-3a9bf2193650

📥 Commits

Reviewing files that changed from the base of the PR and between 9ee4ec7 and ef3ab65.

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

📝 Walkthrough

Walkthrough

BrowserManager now allows permitted guest popups as Electron child windows with constrained options, propagates guest policies and ownership context through did-create-window, and cleans up those listeners and contexts during teardown. The obsolete Orca-tab popup routing helper was removed. Tests cover popup allow/deny behavior, child-window policy propagation and cleanup, and platform-independent download savePath construction.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed It clearly summarizes the primary change: trusted embedded popup windows are now allowed.
Description check ✅ Passed The description covers summary, testing, review, security, and notes; the missing screenshots section is acceptable for a no-visual-change PR.
Linked Issues check ✅ Passed The changes implement real child popup windows, keep safety fallbacks, and propagate guest policies as requested by #7374.
Out of Scope Changes check ✅ Passed The diff stays focused on popup handling and related tests, with no clear unrelated feature work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@Jinwoo-H Jinwoo-H 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.

Thanks—this is the right root-cause fix for popup-based OAuth flows. Before landing, I tightened the native-window boundary and added regression coverage:

  • Block local-file popup targets and disruptive native-window options.
  • Preserve opener/postMessage/window.close across nested popup flows.
  • Route child permissions/downloads to the owner while isolating child load failures.
  • Clean up descendant ownership without adding hot-path scans.

Verified in Electron with a live opener round trip, repeat popup creation, normal native chrome, window.close, and file-popup denial. All 123 affected tests pass.

@Jinwoo-H
Jinwoo-H merged commit 1afec6c into stablyai:main Jul 10, 2026
2 checks passed
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
* fix(browser): allow trusted embedded popup windows

* fix(browser): harden embedded popup windows

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Jinwoo-H <[email protected]>
Co-authored-by: Orca <[email protected]>
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.

[Bug]: OAuth sign-in popups (window.open) are denied in the embedded browser, breaking auth flows

2 participants