Skip to content

fix(browser): stop the auth-host UA write from cancelling redirects - #15221

Merged
brennanb2025 merged 3 commits into
stablyai:mainfrom
choihjin:fix/browser-auth-ua-redirect-abort
Aug 19, 2026
Merged

brennanb2025 merged 3 commits into
stablyai:mainfrom
choihjin:fix/browser-auth-ua-redirect-abort

Conversation

@choihjin

Copy link
Copy Markdown
Contributor

ELI5

Orca changed the browser's user agent in the middle of a redirect. Chromium reacts to that by cancelling the page load and starting over, and a "Sign in with Google" flow cannot start over — so the tab went blank and the click looked ignored. Orca now changes the identity in a way that does not interrupt the load.

What Changed

  • applyGoogleAuthUserAgent takes a duringRedirect flag. On that path it no longer calls WebContents.setUserAgent(); it writes the identity through the CDP override instead, reusing sendViewportUserAgentOverride so both CDP writers resolve one identity per URL.
  • Added authUserAgentOverrideByGuestId — the CDP override outranks the WebContents UA, so getUserAgent() stops reporting what the document sees. Without this reading, a guest that entered an auth host by redirect would keep presenting Firefox on every later host. Cleared on guest retire and on shutdown.
  • With no debugger attached the redirect is left alone rather than cancelled. A stale navigator.userAgent is recoverable; a dead navigation is not.
  • did-start-navigation keeps the setUserAgent write — it runs before the request is dispatched and does not cancel anything.

No change to the wire UA: setupClientHintsOverride already rewrites User-Agent and strips sec-ch-ua* per request for auth-host URLs, independently of this call.

Why

WebContents.setUserAgent() inside will-redirect makes Chromium abort the in-flight navigation with ERR_ABORTED (-3) and replay the original request. A chain that cannot be replayed — one started by a POST, or one carrying one-time auth state — never lands, so the navigation dies with loadError: null and the tab is left at data:text/html,.

That is every redirect crossing GOOGLE_AUTH_HOSTS, which is exactly the "Sign in with Google" path: the provider button POSTs, and accounts.google.com is reached only by redirect.

Isolated on the Electron 43.1.0 the app ships, no Google and no Orca involved — local server, /start → 302 → /dest, one arm per process:

Arm aborted requests the server saw on /start navigator.userAgent
A — control, no UA write in will-redirect no 1× base base
B — WebContents.setUserAgent() (before this PR) ERR_ABORTED (-3) 2× — base, then Firefox Firefox
C — CDP Emulation.setUserAgentOverride (this PR) no 1× base Firefox

Arm B is the defect: the original request is issued twice and will-redirect fires twice. In that trivial local GET the replay happens to succeed, which is why the damage stays invisible until the chain cannot be replayed.

Two alternatives were measured and rejected. did-redirect-navigation crashes the main process (exit 133, 3/3 runs). Dropping the redirect-path write entirely leaves navigator.userAgent disagreeing with the header-level Firefox switch, which is the mismatch #12884 exists to remove.

Linked Issue

Fixes #15216

Visual Proof

Same machine, same profile state, https://accounts.google.com/ opened in an embedded browser tab:

committed URL navigator.userAgent
1.4.184 (before) data:text/html, — blank, no error surfaced …Chrome/150.0.7871.47 Electron/43.1.0…
this branch (after) https://accounts.google.com/v3/signin/identifier?continue=… Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:140.0) Gecko/20100101 Firefox/140.0

https://mail.google.com/ (non-auth host redirecting into one) behaves the same way: blank before, commits at accounts.google.com/v3/signin/identifier?continue=https://mail.google.com/mail/u/0/&… after, on the Firefox auth UA.

There is no UI surface of its own here — the visible change is that the page loads at all.

Testing

Final merge base: f8e728bb8b87c0375b320fcd31316996f73e3d88

Manual, macOS, on a dev build of this branch against installed 1.4.184 as the before-arm — the table above. Reproduction that motivated it: https://gitlab.com/users/sign_in → click Google → nothing happens on 1.4.184, while the GitHub button on the same page (same <form class="js-omniauth-form" method="post"> markup, non-Google redirect target) navigates correctly.

Automated

npx vitest run --config config/vitest.config.ts \
  src/main/browser/browser-manager-auth-user-agent.test.ts \
  src/main/browser/browser-manager-viewport-override.test.ts
# Test Files 2 passed (2) | Tests 29 passed (29)

Three new cases in browser-manager-auth-user-agent.test.ts:

  • a redirect onto an auth host retargets over CDP and never calls setUserAgent, and leaving the host afterwards reads the override rather than the stale getUserAgent()
  • a redirect with no debugger attached is left alone
  • a non-redirect navigation still uses the WebContents write

Two cases in browser-manager-viewport-override.test.ts asserted the cancelling write and were updated to the CDP contract.

Full src/main/browser/ suite is unchanged against this merge base: 18 pre-existing failures before and after (all in browser-cookie-*, unrelated), 570 → 573 passing (+3 new).

Not tested on Linux, Windows, or SSH. The path is main-process Chromium behavior with no platform branch, and the embedded browser runs in the desktop process on every platform.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Investigated and written with Claude (Opus 5) via Claude Code. The Electron oracle, the before/after app runs, and the test results above were produced by running them, not inferred.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Authentication redirects use CDP user-agent overrides when a debugger is attached. The browser tracks pending and confirmed overrides, retries failed operations, and restores the session user-agent when appropriate. Viewport overrides preserve the active authentication identity and accept explicit base user-agents. Cleanup clears authentication state during debugger detachment, guest retirement, viewport reset, and unregister. Tests cover redirects, races, failures, popups, and direct navigation.

Merge Risk: 🔵 Low · up to 5db58

The change prevents authentication redirects from being cancelled, but a bounded risk remains that a failed or detached debugger session could leave later authentication identity updates stale or skipped; owner follow-up is recommended.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary fix: preventing auth-host user-agent writes from cancelling redirects.
Description check ✅ Passed The description is detailed and covers the change, rationale, linked issue, visual proof, testing, and AI disclosure; several optional template sections are absent.
Linked Issues check ✅ Passed The implementation addresses issue #15216 by replacing redirect-time WebContents UA writes with CDP overrides and preserving auth-host navigation.
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on auth-host redirect handling, UA override coordination, lifecycle cleanup, and related viewport behavior.
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.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 164c5eea-97c3-484a-8431-58e0f5361e41

📥 Commits

Reviewing files that changed from the base of the PR and between 13b10e0 and e8f22e1b966fc16347d71562c33c399fa52f6ce8.

📒 Files selected for processing (3)
  • src/main/browser/browser-manager-auth-user-agent.test.ts
  • src/main/browser/browser-manager-viewport-override.test.ts
  • src/main/browser/browser-manager.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.

Comment thread src/main/browser/browser-manager.ts Outdated
Comment on lines +988 to +1000
if (options.duringRedirect === true || overriddenUa !== undefined) {
if (this.canOverrideUserAgentOverCdp(guest)) {
this.authUserAgentOverrideByGuestId.set(guest.id, nextUa)
// Why: go through the viewport builder rather than writing nextUa raw, so both CDP writers
// resolve one identity for this URL — Firefox on auth hosts, the profile's clean base off
// them, any mobile preset preserved. Writing the session UA directly would put the
// unlaundered Electron token back on the wire.
void this.sendViewportUserAgentOverride(
guest,
(ownerTabId ? this.viewportUaOverrideMobileByTabId.get(ownerTabId) : undefined) ??
false,
url
).catch(() => {})

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep tracked state synchronized with the CDP override.

Line 990 records nextUa before sendViewportUserAgentOverride() succeeds. Lines 995-1000 suppress command failures. A failed command leaves authUserAgentOverrideByGuestId claiming that the Firefox override is active.

Debugger detachment also clears CDP overrides, but this map is not cleared or reapplied. Later navigations then take the CDP-only path based on stale state. If the debugger is unavailable, the guest keeps the wrong navigator.userAgent.

Set tracked state only after a successful command. Clear or reconcile it on debugger detach. Add failure and detach regression coverage.

@brennanb2025

Copy link
Copy Markdown
Contributor

Electron visual proof (isolated worktree build)

Ran an isolated Orca dev instance for review-15221 / fix/browser-auth-ua-redirect-abort over CDP. Fresh profile. No login completed. playwright-cli only — no computer-use.

Direct https://accounts.google.com/ committed at accounts.google.com/v3/signin/identifier (not a blank data:text/html, tab). Visible Google identifier form. Guest navigator.userAgent was the Firefox 140 auth UA. loadError was null.

Direct accounts.google.com identifier in the embedded browser

GitLab Google OAuth POST (the reproducing path): https://gitlab.com/users/sign_in showed the js-omniauth-form Google button. Clicking Google (no credentials) redirected in-tab to accounts.google.com/v3/signin/identifier with GitLab OAuth params (redirect_uri=…/google_oauth2/callback, flowName=GeneralOAuthFlow). Visible copy: “Sign in / to continue to GitLab”. Same Firefox auth UA. loadError was null.

GitLab sign-in with Google button visible

After Google click: identifier page “to continue to GitLab”

Limitation: https://mail.google.com/ and /mail/u/0/ now land on workspace.google.com/intl/en-US/gmail/ (marketing, Chrome UA), not accounts. That is live Google routing from this isolated profile, not a blank-tab abort. Clicking marketing Sign in opened a popup whose CDP target was accounts.google.com/v3/signin/identifier?continue=https://mail.google.com/mail/…; that popup was a separate window and is not in the main-window shot.

mail.google.com now routes to Gmail marketing

Not compared against 1.4.184 in this run. Linux / Windows / SSH / already-signed-in Google sessions not tested. The worktree also has extra uncommitted local edits on the same three browser files; this instance compiled that local tree.

choihjin and others added 2 commits August 19, 2026 01:31
WebContents.setUserAgent() from will-redirect makes Chromium abort the
in-flight navigation (ERR_ABORTED) and replay the original request, so any
redirect crossing the Google auth-host boundary dies on a blank tab. Route
that write through the CDP override, which retargets navigator.userAgent
without touching the navigation.

Fixes stablyai#15216
@brennanb2025
brennanb2025 force-pushed the fix/browser-auth-ua-redirect-abort branch from e8f22e1 to d6be90d Compare August 19, 2026 08:34
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@brennanb2025

brennanb2025 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Review status: keep this contributor PR

The redirect-safe CDP path fixes the root cause without touching the out-of-scope Firefox identity, storage-access, client-hints brand, or profile-clear work.

Changes made during review

  • Rebased onto current main at 4fc8b65792; PR head is d6be90d3d5.
  • CDP auth identity is recorded only after a successful write, rejected or detached writes are invalidated, and overlapping writes are ordered by sequence so stale settlements cannot regress state.
  • Restore writes use the authoritative session base UA instead of the stale Firefox-shaped WebContents UA.
  • Clearing a viewport preset preserves the auth CDP identity.
  • Desktop OAuth popups no longer inherit a mobile owner UA.
  • The auth writer is the sole CDP UA writer for its navigation event, preventing the generic viewport reapply from overwriting a redirect-off-auth restore.

Validation

  • 69 focused BrowserManager, viewport, lifecycle, and popup tests passed after the rebase.
  • Full typecheck passed.
  • Direct, native-plugin, and type-aware oxlint passed; max-lines ratchet and diff checks passed.
  • Real Electron 43.1.0 oracle for did-start-navigation WebContents writes: direct GET and form POST each produced one request, zero navigation failures, and the expected document UA. This supports retaining the non-redirect path.
  • Fresh isolated Orca Electron proof: direct Google auth and the original GitLab Google POST OAuth repro both reached the visible Google identifier page with Firefox 140 navigator.userAgent, no load error, and no blank-tab abort. Screenshots are in the preceding visual-proof comment.
  • Popup policies cover managed child OAuth windows and descendants. The changed runtime behavior is platform-neutral across macOS, Windows, and Linux; Windows and Linux were reviewed structurally, not executed.

Release / merge state

The regression is present in v1.4.184. There is no active maintenance branch needing a separate cherry-pick, so this should ship through the next mainline release. GitHub has not populated post-force-push checks yet and currently reports the PR as UNSTABLE; please wait for supported Node 24 CI before the maintainer merge decision.

Recommendation: keep PR #15221. No merge performed.

@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-auth-user-agent.test.ts (1)

111-112: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten the new explanatory comments.

Keep the cancellation and user-agent rationale, but state each comment in one concise line.

  • src/main/browser/browser-manager-auth-user-agent.test.ts#L111-L112: reduce the stale-UA explanation to one line.
  • src/main/browser/browser-manager-auth-user-agent.test.ts#L251-L254: reduce the redirect failure rationale to one line.
  • src/main/browser/browser-manager-auth-user-agent.test.ts#L342-L344: reduce the CDP precedence rationale to one line.
  • src/main/browser/browser-manager-auth-user-agent.test.ts#L410-L412: reduce the no-debugger rationale to one line.
  • src/main/browser/browser-manager-auth-user-agent.test.ts#L455-L456: reduce the direct-navigation rationale to one line.
  • src/main/browser/browser-manager-viewport-override.test.ts#L509-L511: reduce the CDP-only redirect rationale to one line.

As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 77cbe585-9389-48e5-bfcb-37c6b8a9be4e

📥 Commits

Reviewing files that changed from the base of the PR and between 73f7767 and d6be90d.

📒 Files selected for processing (3)
  • src/main/browser/browser-manager-auth-user-agent.test.ts
  • src/main/browser/browser-manager-viewport-override.test.ts
  • src/main/browser/browser-manager.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/browser/browser-manager.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.

The auth-host switch writes the Firefox UA through WebContents.setUserAgent on a
direct navigation and then moves to the CDP override, and nothing restores that
WebContents UA. sendViewportUserAgentOverride read it back as its base identity,
so a tab with a viewport preset republished the Firefox UA on every ordinary host
afterwards, with sec-ch-ua still saying Chrome. Read the profile's session UA
instead, which is the stable base identity at both call sites.

@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)

1168-1171: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the rationale comments.

Both comments exceed the preferred concise form. Keep one non-obvious sentence at each site.

  • src/main/browser/browser-manager.ts#L1168-L1171: reduce the rationale to one sentence about using the session UA as the stable base identity.
  • src/main/browser/browser-manager-auth-user-agent.test.ts#L500-L504: reduce the rationale to one sentence about preventing the Firefox auth identity from leaking to ordinary hosts.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2d2504e-5bf1-4f9f-87f2-896019be2c78

📥 Commits

Reviewing files that changed from the base of the PR and between d6be90d and 5db58f9.

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

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@brennanb2025

brennanb2025 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Live Google sign-in on PR head d6be90d3d50f

This is a completed login, not "reached the password page." Run against the exact current PR head, clean tree, isolated Electron profile. Brennan typed the credentials; the agent did not.

What was tested

Item Value
SHA d6be90d3d50f195f8ec0db870dc5c68e3d6c7e3a
Commits ed9f38a37f stop the auth-host UA write from cancelling redirects · d6be90d3d5 recover auth UA override state
Tree clean (git status empty; no uncommitted src/main/browser/** edits)
Instance Orca Dev label QA-15221-LOGIN, Dock title Orca: pr-15221-head
CDP http://127.0.0.1:9333
Profile isolated ORCA_DEV_USER_DATA_PATH=/tmp/orca-electron-profile-qa15221.rKAlsX (did not touch the production Orca profile)

Results — login completed

  1. accounts.google.com → authenticated Google Account

    • Committed URL: https://myaccount.google.com/?pli=1
    • Visible account: Brennan Benson / [email protected]
    • loadError: null
  2. mail.google.com → real inbox (after sign-in)

    • Committed URL: https://mail.google.com/mail/u/0/#inbox
    • Title: Inbox (7,777) - [email protected] - Stably Mail
    • Real mail visible (Linear, Stripe, notifications, etc.)
    • loadError: null
    • Note: the first mail.google.com navigation, opened before Brennan signed in, landed on the unauthenticated marketing page https://workspace.google.com/intl/en-US/gmail/. After the Workspace session existed, a second mail.google.com tab reached the inbox. That first hit is not a failed login.
  3. GitLab Google OAuth (original [Bug]: Redirects that cross the Google auth-host boundary are cancelled by Orca's own UA write in will-redirect — blank tab, no error #15216 POST-started chain) — authenticated

    • Opened https://gitlab.com/users/sign_in, submitted the POST /users/auth/google_oauth2 Google button.
    • Observed chain (no request failures):
      • POST https://gitlab.com/users/auth/google_oauth2 → 302
      • GET https://accounts.google.com/o/oauth2/auth?... → 302
      • GET https://gitlab.com/users/auth/google_oauth2/callback?... → 302
      • GET https://gitlab.com/ → 200
    • Landed signed in as Brennan Benson on the GitLab home/dashboard (Home · GitLab).
    • Playwright requestfailed list for that navigation: empty.

Cookie jar (names only, isolated Partitions/orca-browser/Cookies)

Present, matching a completed Workspace sign-in:

  • accounts.google.com LSID, __Host-GAPS, __Host-1PLSID, __Host-3PLSID
  • .google.com SID, SIDCC, SSID, HSID, APISID, SAPISID, __Secure-1PSID, __Secure-1PSIDCC, __Secure-1PSIDTS, __Secure-3PSID, …
  • .workspace.google.com entries (APPS_MARKETING_SIGNALS, _ga, __utm*)
  • After Gmail: mail.google.com OSID, __Secure-OSID, __Host-GMAIL_SCH_*
  • After GitLab OAuth: .gitlab.com gitlab_user, gitlab.com known_sign_in

No cookie values were captured or posted.

Navigation aborts

Compared with the pre-fix session that produced 224 net::ERR_ABORTED on mail.google.com in 2m35s plus 2× HTTP 429:

Signal This run
net::ERR_ABORTED in the electron-vite / main log 0
www.google.com/sorry/index 0
HTTP 429 on accounts.google.com / mail.google.com 0 (the only 429 in the log is an unrelated Claude usage refresh)
Store loadError on all four tabs null
GitLab OAuth requestfailed []

What was not tested

  • Production Orca profile / persisted user data
  • Windows or Linux
  • SSH / remote-host embedded browser
  • Other OmniAuth buttons (GitHub, Bitbucket, Salesforce)
  • FedCM-vs-popup fallback specifically
  • Cold start after cookie expiry / next-day session restore
  • Mixed client/host versions

I did not merge. Merge call is Brennan's.

@brennanb2025
brennanb2025 merged commit 0b8107a into stablyai:main Aug 19, 2026
44 of 45 checks passed
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for the PR!

@brennanb2025

Copy link
Copy Markdown
Contributor

Review summary (post-merge)

Reviewed the full change with subagents plus an independent precedent check. One real defect was found before merge, fixed, and is included in the merged commit range; everything else came back clean.

Blocker found and fixed — 5db58f94bc

The auth-host switch writes the Firefox UA through WebContents.setUserAgent() on a direct navigation, then moves to the CDP override on the first redirect — and nothing ever restores the WebContents UA. sendViewportUserAgentOverride was re-deriving its base identity from guest.getUserAgent(), so that stale value propagated.

Repro (verified with a test that fails before the fix and passes after):

  1. Tab has a desktop viewport preset (mobile: false)
  2. Navigate directly to accounts.google.com → takes the setUserAgent branch, WebContents UA becomes Firefox 140
  3. Any redirect off the auth host → switches to CDP, WebContents UA never restored
  4. Navigate to github.com → Emulation.setUserAgentOverride is issued with the Firefox UA

Result: a permanent Firefox identity on every ordinary site, while sec-ch-ua still says Chrome — the exact cross-layer mismatch this scope exists to remove, and a regression relative to pre-PR behaviour (where setUserAgent restored the UA correctly). cleanElectronUserAgent is a no-op on a Firefox string, so the value propagated verbatim; with a mobile preset, extractChromeMajor also misses and falls back to the hardcoded 134.

Fix: read the profile's session UA as the base identity instead of the mutable WebContents UA. One line, plus a regression test. No <webview> in the renderer sets a useragent attribute, so the guest UA diverges from the session UA only via this code's own writes.

Verification

  • src/main/browser: 786/786 passing
  • Typecheck (config/tsconfig.node.json) and oxlint clean; the new test is in the typecheck program
  • New test confirmed non-vacuous — fails against the pre-fix implementation
  • CI: 43 checks passing at time of merge. shell contracts was wedged on its Install zsh and fish step (apt/PPA), which is a known infrastructure hang unrelated to this change

Follow-up candidates — not blocking, filed for triage

  1. Direct POST onto an auth host. The abort this PR fixes is triggered by a UA change while a load is in progress, which did-start-navigation also satisfies — not only will-redirect. A form POST landing directly on an auth host would still take setUserAgent and hit the same reload-with-repost path. Redirect-borne flows (including the original [Bug]: Redirects that cross the Google auth-host boundary are cancelled by Orca's own UA write in will-redirect — blank tab, no error #15216 repro) are covered; whether the direct-POST path is reachable in a real provider flow is the open question.
  2. Debugger re-attach. injectAntiDetection's re-attach re-issues only Page.enable and the anti-detection script. Chromium drops all Emulation overrides with the DevTools session, so the auth identity is not restored until the next navigation. This PR makes the auth UA newly dependent on that layer — previously it lived in setUserAgent, which survives a detach. Opening DevTools on a guest detaches the debugger on all platforms.

Neither is a regression severe enough to hold the merge, and both self-heal on the next navigation.

@brennanb2025

Copy link
Copy Markdown
Contributor

Follow-up 1 (direct POST onto an auth host) — measured, not reachable

Ran the isolated harness for this rather than reasoning about it. No Orca, no Google: local HTTP server, a form that POSTs directly to a target path, one arm per process, on the Electron this repo ships.

Arm did-start-navigation writes UA? Requests server saw ERR_ABORTED Landed
control no 1 none /target
setua yes (Firefox 140) 1 none /target

The write demonstrably took effect — after navigation, webContents.getUserAgent() and in-page navigator.userAgent both read …rv:140.0) Gecko/20100101 Firefox/140.0. So this is a real positive for the write and a real negative for the abort, not a vacuous pass.

Conclusion: WebContents.setUserAgent() in did-start-navigation does not cancel the in-flight navigation, including a POST-started one. The PR's original claim holds. The abort is specific to writing the UA once a load is already in flight — will-redirect — which is what this PR moved to CDP.

One detail worth recording: the in-flight request still went out with the Chrome UA, because did-start-navigation fires after the request headers are built. The UA write lands on navigator.userAgent and on subsequent requests. That is not a gap here, because setupClientHintsOverride rewrites the User-Agent header per request for auth-host URLs independently of this code path — so the wire identity is correct regardless.

No fix needed, and no follow-up PR for this one.

Follow-up 2 (debugger re-attach) stands, and it got more relevant

That one reproduces on inspection and is worth tracking: Chromium drops all Emulation overrides with the DevTools session, injectAntiDetection's re-attach re-issues only Page.enable plus the anti-detection script, and opening DevTools on a guest detaches the debugger on every platform. Self-heals on the next navigation, but the auth identity is now dependent on a layer that setUserAgent was not.

It also bears on adjacent work: a proposal to fix the sec-ch-ua versus navigator.userAgentData brand mismatch by installing an always-on CDP metadata override is materially weakened by this — a standing Emulation override silently evaporates whenever the debugger detaches. That pushes the fix toward removing the inaccurate "Google Chrome" header claim instead, which needs no standing override at all.

brennanb2025 added a commit that referenced this pull request Aug 20, 2026
…notices (#15542)

* fix(browser): name the requesting frame and the permission in denial notices

Two defects in the same notice, both found by the review of #15481 and left out
of it deliberately.

The notice named the wrong site. setPermissionRequestHandler passed
webContents.getURL(), which is the top-level document, so a permission request
from a cross-origin sub-frame was attributed to the embedder. Every
PermissionRequest variant carries requestingUrl, so all three call sites now use
it and fall back to the top-level document only when it is absent.

The notice also showed raw Chromium permission names. humanizePermission mapped
two permissions and returned the raw token for the rest. That now matters more:
#15481 granted ordinary storage-access and left top-level-storage-access denied,
making it the storage denial a user can still hit - rendered as its raw token.

The default still returns the raw token. Inventing prose for a permission nobody
has seen is worse than showing its real name.

Does not change any permission verdict, and does not fix Google sign-in (#15221).

* fix(browser): keep permission denial attribution accurate

Capture fallback URLs before asynchronous media permission handling and treat opaque requesters as unknown rather than blaming the top-level page. Clarify permission descriptions and cover origin normalization, navigation races, and mapped copy.
AmethystLiang pushed a commit that referenced this pull request Aug 20, 2026
…15221)

* fix(browser): stop the auth-host UA write from cancelling redirects

WebContents.setUserAgent() from will-redirect makes Chromium abort the
in-flight navigation (ERR_ABORTED) and replay the original request, so any
redirect crossing the Google auth-host boundary dies on a blank tab. Route
that write through the CDP override, which retargets navigator.userAgent
without touching the navigation.

Fixes #15216

* fix(browser): recover auth UA override state

* fix(browser): keep the viewport UA override on the session identity

The auth-host switch writes the Firefox UA through WebContents.setUserAgent on a
direct navigation and then moves to the CDP override, and nothing restores that
WebContents UA. sendViewportUserAgentOverride read it back as its base identity,
so a tab with a viewport preset republished the Firefox UA on every ordinary host
afterwards, with sec-ch-ua still saying Chrome. Read the profile's session UA
instead, which is the stable base identity at both call sites.

---------

Co-authored-by: Brennan Benson <[email protected]>
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…tablyai#15221)

* fix(browser): stop the auth-host UA write from cancelling redirects

WebContents.setUserAgent() from will-redirect makes Chromium abort the
in-flight navigation (ERR_ABORTED) and replay the original request, so any
redirect crossing the Google auth-host boundary dies on a blank tab. Route
that write through the CDP override, which retargets navigator.userAgent
without touching the navigation.

Fixes stablyai#15216

* fix(browser): recover auth UA override state

* fix(browser): keep the viewport UA override on the session identity

The auth-host switch writes the Firefox UA through WebContents.setUserAgent on a
direct navigation and then moves to the CDP override, and nothing restores that
WebContents UA. sendViewportUserAgentOverride read it back as its base identity,
so a tab with a viewport preset republished the Firefox UA on every ordinary host
afterwards, with sec-ch-ua still saying Chrome. Read the profile's session UA
instead, which is the stable base identity at both call sites.

---------

Co-authored-by: Brennan Benson <[email protected]>
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…notices (stablyai#15542)

* fix(browser): name the requesting frame and the permission in denial notices

Two defects in the same notice, both found by the review of stablyai#15481 and left out
of it deliberately.

The notice named the wrong site. setPermissionRequestHandler passed
webContents.getURL(), which is the top-level document, so a permission request
from a cross-origin sub-frame was attributed to the embedder. Every
PermissionRequest variant carries requestingUrl, so all three call sites now use
it and fall back to the top-level document only when it is absent.

The notice also showed raw Chromium permission names. humanizePermission mapped
two permissions and returned the raw token for the rest. That now matters more:
stablyai#15481 granted ordinary storage-access and left top-level-storage-access denied,
making it the storage denial a user can still hit - rendered as its raw token.

The default still returns the raw token. Inventing prose for a permission nobody
has seen is worse than showing its real name.

Does not change any permission verdict, and does not fix Google sign-in (stablyai#15221).

* fix(browser): keep permission denial attribution accurate

Capture fallback URLs before asynchronous media permission handling and treat opaque requesters as unknown rather than blaming the top-level page. Clarify permission descriptions and cover origin normalization, navigation races, and mapped copy.
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…tablyai#15221)

* fix(browser): stop the auth-host UA write from cancelling redirects

WebContents.setUserAgent() from will-redirect makes Chromium abort the
in-flight navigation (ERR_ABORTED) and replay the original request, so any
redirect crossing the Google auth-host boundary dies on a blank tab. Route
that write through the CDP override, which retargets navigator.userAgent
without touching the navigation.

Fixes stablyai#15216

* fix(browser): recover auth UA override state

* fix(browser): keep the viewport UA override on the session identity

The auth-host switch writes the Firefox UA through WebContents.setUserAgent on a
direct navigation and then moves to the CDP override, and nothing restores that
WebContents UA. sendViewportUserAgentOverride read it back as its base identity,
so a tab with a viewport preset republished the Firefox UA on every ordinary host
afterwards, with sec-ch-ua still saying Chrome. Read the profile's session UA
instead, which is the stable base identity at both call sites.

---------

Co-authored-by: Brennan Benson <[email protected]>
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…notices (stablyai#15542)

* fix(browser): name the requesting frame and the permission in denial notices

Two defects in the same notice, both found by the review of stablyai#15481 and left out
of it deliberately.

The notice named the wrong site. setPermissionRequestHandler passed
webContents.getURL(), which is the top-level document, so a permission request
from a cross-origin sub-frame was attributed to the embedder. Every
PermissionRequest variant carries requestingUrl, so all three call sites now use
it and fall back to the top-level document only when it is absent.

The notice also showed raw Chromium permission names. humanizePermission mapped
two permissions and returned the raw token for the rest. That now matters more:
stablyai#15481 granted ordinary storage-access and left top-level-storage-access denied,
making it the storage denial a user can still hit - rendered as its raw token.

The default still returns the raw token. Inventing prose for a permission nobody
has seen is worse than showing its real name.

Does not change any permission verdict, and does not fix Google sign-in (stablyai#15221).

* fix(browser): keep permission denial attribution accurate

Capture fallback URLs before asynchronous media permission handling and treat opaque requesters as unknown rather than blaming the top-level page. Clarify permission descriptions and cover origin normalization, navigation races, and mapped copy.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#15221)

* fix(browser): stop the auth-host UA write from cancelling redirects

WebContents.setUserAgent() from will-redirect makes Chromium abort the
in-flight navigation (ERR_ABORTED) and replay the original request, so any
redirect crossing the Google auth-host boundary dies on a blank tab. Route
that write through the CDP override, which retargets navigator.userAgent
without touching the navigation.

Fixes stablyai#15216

* fix(browser): recover auth UA override state

* fix(browser): keep the viewport UA override on the session identity

The auth-host switch writes the Firefox UA through WebContents.setUserAgent on a
direct navigation and then moves to the CDP override, and nothing restores that
WebContents UA. sendViewportUserAgentOverride read it back as its base identity,
so a tab with a viewport preset republished the Firefox UA on every ordinary host
afterwards, with sec-ch-ua still saying Chrome. Read the profile's session UA
instead, which is the stable base identity at both call sites.

---------

Co-authored-by: Brennan Benson <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…notices (stablyai#15542)

* fix(browser): name the requesting frame and the permission in denial notices

Two defects in the same notice, both found by the review of stablyai#15481 and left out
of it deliberately.

The notice named the wrong site. setPermissionRequestHandler passed
webContents.getURL(), which is the top-level document, so a permission request
from a cross-origin sub-frame was attributed to the embedder. Every
PermissionRequest variant carries requestingUrl, so all three call sites now use
it and fall back to the top-level document only when it is absent.

The notice also showed raw Chromium permission names. humanizePermission mapped
two permissions and returned the raw token for the rest. That now matters more:
stablyai#15481 granted ordinary storage-access and left top-level-storage-access denied,
making it the storage denial a user can still hit - rendered as its raw token.

The default still returns the raw token. Inventing prose for a permission nobody
has seen is worse than showing its real name.

Does not change any permission verdict, and does not fix Google sign-in (stablyai#15221).

* fix(browser): keep permission denial attribution accurate

Capture fallback URLs before asynchronous media permission handling and treat opaque requesters as unknown rather than blaming the top-level page. Clarify permission descriptions and cover origin normalization, navigation races, and mapped copy.
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]: Redirects that cross the Google auth-host boundary are cancelled by Orca's own UA write in will-redirect — blank tab, no error

2 participants