Repository navigation
fix(browser): restore the Chrome-shaped browser identity (STA-7147) - #19927
Conversation
#18749 replaced every browser partition's Chrome-shaped UA with Electron's stock one, so since v1.4.198 the embedded browser announces itself on every non-Google host as: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Orca/1.4.198 Chrome/150.0.7871.224 Electron/43.4.1 Safari/537.36 No browser sends that. Sites that re-check the identity holding a session reject it: users report being signed out of x.com, LinkedIn and "most websites," and at least one was signed out of LinkedIn in their own Chrome and met LinkedIn's "suspicious activity" SMS check -- server-side revocation, which reaches beyond our app. The repo already documented the mechanism in browser-google-auth-ua.ts: copied-in cookies "sent under a UA that doesn't match a real first-party browser get flagged by anti-fraud." That is why the Google auth-host switch exists; #18749 kept it for accounts.google.com and handed every other host an Electron identity. Restore the pre-#18749 session identity: strip the Electron and app tokens, and rewrite sec-ch-ua to match. Nothing in the cookie-import write path changed -- it never did; cookies were always written correctly and servers were refusing them. Deliberately KEPT from #18749, all independent of the UA: - anti-detection.ts stays deleted. Its premises were measured false on Electron 43 and its overrides are themselves published bot signatures. - No Runtime.enable into cross-origin iframes (the documented Cloudflare CDP tell). - No unconditional CDP debugger attach on every browsing guest. Known tradeoff, measured: this re-opens #13822. On the unmerged predecessor branch brennan/sta-3905-cloudflare-ua, commit 9f0a477 recorded the stock UA clearing dash.cloudflare.com 5/5 while every rewritten variant failed 12/12, and noted that adding client hints does not rescue it. So Cloudflare-gated sites will show verification failures again until a coherent-identity fix lands. That is a bounded, in-app annoyance; session revocation damages users' real accounts. A CDP Emulation.setUserAgentOverride with full userAgentMetadata -- which drives navigator.userAgentData as well as the headers, and was never tested -- is the candidate that could satisfy both, and is being measured separately. Tests: the real-Electron wire-identity test now asserts the stripped identity on ordinary hosts and Firefox on Google auth hosts. Ablation-verified: neutering cleanElectronUserAgent turns it red on the Electron-token assertion. Its fixture also gained an app name -- without one the raw UA carried no app token, so the Orca/x.y.z half of the cleaner was never exercised.
…aped-browser-identity
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (14)
🚧 Files skipped from review as they are similar to previous changes (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe change replaces Chrome and Edge Client Hints synthesis with cleaned session user agents and a Google authentication user-agent override. Non-native sessions apply the cleaned identity, while native sessions bypass it. Tests now cover request headers, navigator identity, authentication-host behavior, navigation restoration, and session persistence. Fixtures, comments, the sign-in probe, and profile documentation describe the updated behavior. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to This PR restores the browser's Chrome-shaped user-agent identity for non-Google sites while keeping a scoped Firefox identity for Google authentication, reverting a prior regression that caused session rejections on sites like X and LinkedIn. The change is well-covered by tests across headers, navigator APIs, and navigation flows, and no unresolved code issues were found, so it appears safe to merge, with the known and disclosed caveat that some Cloudflare-protected sites may still reject the cleaned identity. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 14 files. (1 skipped: 1 unsupported.) Full details: Description checkExplanation The description provides detailed problem, fix, testing, measurements, and caveats, but it does not follow the repository template. It omits the required section headings and information for ELI5, Linked Issue with a Resolution Restructure the description using the repository template. Add an ELI5 section, explicit What Changed and Why sections, a valid Linked Issue entry using
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
Important
The rename to setupClientHintsOverride (plus the new cleanElectronUserAgent dependency) leaves browser-session-registry.persistence.test.ts unmigrated, so 7 of its tests fail and CI will be red. Details are anchored at browser-session-partition-policies.ts:96.
Reviewed changes
- Chrome-shaped session identity —
cleanElectronUserAgentstrips theElectron/x.y.zand app-name tokens from the UA, andsetupClientHintsOverride(renamed fromsetupGoogleAuthUserAgentOverride) now also rewritessec-ch-ua/sec-ch-ua-full-version-listto a Chrome/Edge brand set while keeping the Google auth-host Firefox switch. - Partition wiring —
installBrowserSessionPartitionPoliciesandapplyBrowserSessionUserAgentModesnow set the laundered UA on the session and install the hints override, skippinguserAgentMode: 'native'profiles. - Viewport/navigation plumbing — desktop viewport presets republish the cleaned base identity, and
sendViewportUserAgentOverridelaundersguest.session.getUserAgent()so a preset can't re-publish the tokens. - Tests — a real-Electron wire-identity test (ablation-verified) plus unit tests for the hints rewrite and the cleaner; the fixture gained an app name so the app-token half of the cleaner is actually exercised.
ℹ️ Dead googleAuthOverride option
setupClientHintsOverride gained a googleAuthOverride option, but no production caller ever passes false — both call sites (browser-session-partition-policies.ts:98 and :198) invoke it with the default true. The two tests exercising googleAuthOverride: false describe an "imported-native profile" flow that production never reaches: applyBrowserSessionUserAgentModes skips native profiles entirely (continue), so nothing aligns their hints while suppressing the Firefox switch.
Technical details
# Dead googleAuthOverride option
## Affected sites
- src/main/browser/browser-session-ua.ts:33 — `options: { googleAuthOverride?: boolean } = {}`
- src/main/browser/browser-session-partition-policies.ts:98, :198 — both call `setupClientHintsOverride(sess, cleanUA)` without the option
- src/main/browser/browser-session-registry.test.ts:674-731 — tests for `googleAuthOverride: false`
## Required outcome
- Either wire the option into the imported/native-profile path (if hint-alignment-without-Firefox is intended for imported profiles), or drop the option and its two tests.
## Open questions for the human
- Is imported-native hint alignment (Chrome hints + imported UA + no Firefox switch) a goal? If so, which code path should pass `googleAuthOverride: false`?DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
browser-session-registry.persistence.test.ts still asserted #18749's behaviour ("keeps the stock UA", "keeps the engine UA"), so the shipped code and its test disagreed. Caught by CI shard 4/8, not locally: I reverted four test files and went to typecheck without re-running the browser suite. Also restores the accurate wording that #18749 generalised away, now that the behaviour it described is back: - browser-google-auth-ua.ts: names the Electron/Chrome-shaped UA again as what anti-fraud flags, which is the reason the auth-host switch exists at all. - docs/browser/profiles.mdx: documents the cleaned Chrome UA default and the --no-ua-spoof escape hatch, which is real again. - tests/tools/google-signin-ua-probe.cjs: comments name the live handler. Deliberately left at #18749's version, because those changes stay correct with anti-detection.ts deleted: - browser-manager-viewport.ts: its comment no longer cites the retired addScriptToEvaluateOnNewDocument injection. - browser-webauthn-profile-delete.test.ts: its added webRequest mock is REQUIRED by the restored setupClientHintsOverride, so reverting it would break the test.
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d1b943cf-b7ed-4181-8c9f-f2ce77472df3
📒 Files selected for processing (4)
docs/site/content/docs/browser/profiles.mdxsrc/main/browser/browser-google-auth-ua.tssrc/main/browser/browser-session-registry.persistence.test.tstests/tools/google-signin-ua-probe.cjs
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — the migration leg is clean. One docs nit inline.
Reviewed changes
- Migrated the stale test mock —
browser-session-registry.persistence.test.tsnowvi.doMocks./browser-session-uawithcleanElectronUserAgent+setupClientHintsOverrideand asserts the laundered engine UA, resolving the 7 failing tests from the prior review. - Expanded
setupClientHintsOverridecoverage — thebrowser-session-registry.test.tsdescribe block was rewritten with new Edge/Chrome brand-rewrite, non-Chrome-UA, cross-host Chrome-hints, and non-hint-header cases. - Switched the auth test fixtures to
GUEST_CLEAN_UA— the expected wire identity in the auth/UA tests now reflects the cleaned Chrome shape. - Rewrote docs and comments —
profiles.mdxand several source comments now describe the reverted Chrome-shaped behavior.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Removed the
sec-ch-uaChrome-brand rewrite —setupClientHintsOverride/buildChromeClientHintsare gone;browser-session-ua.tsis back tocleanElectronUserAgent+setupGoogleAuthUserAgentOverride, leaving the client-hint identity (request headers andnavigator.userAgentData) browser-owned. This closes the header-vs-JS brand disagreement the intermediate approach introduced and retires the deadgoogleAuthOverrideoption flagged in the prior review. - Expanded the real-Electron wire-identity test — it now serves a local HTTPS origin and asserts the wire
sec-ch-ua/sec-ch-ua-full-version-listmatchnavigator.userAgentDataand carry noElectron/Orcabrand, so the "browser-owned hints" premise is exercised rather than assumed. - Migrated remaining tests and comments — partition-policy, registry, persistence, viewport, and auth-UA tests plus
profiles.mdxandgoogle-signin-ua-probe.cjsnow describe the browser-owned-hints behavior; theprofiles.mdxwording that implied the cleaned UA improves Cloudflare compatibility is corrected.
ℹ️ Nitpicks
- The PR body's "Fix" section still says "rewrite
sec-ch-uato match", but the final commit leaves client hints browser-owned — a sentence that now contradicts both the code and the "byte-identical to its pre-#18749 original" claim. Worth a one-line body update before merge.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Electron visual proof —
|
Review-until-clean statusVerdict: land — PASS with documented residual risk. Reviewed and fixed through three same-model review/fix rounds. Final head: Judgments
Validation
Remaining gaps / risks
No release-blocking P0/P1 issue remains. |
…tablyai#19927) * fix(browser): restore the Chrome-shaped browser identity (STA-7147) stablyai#18749 replaced every browser partition's Chrome-shaped UA with Electron's stock one, so since v1.4.198 the embedded browser announces itself on every non-Google host as: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Orca/1.4.198 Chrome/150.0.7871.224 Electron/43.4.1 Safari/537.36 No browser sends that. Sites that re-check the identity holding a session reject it: users report being signed out of x.com, LinkedIn and "most websites," and at least one was signed out of LinkedIn in their own Chrome and met LinkedIn's "suspicious activity" SMS check -- server-side revocation, which reaches beyond our app. The repo already documented the mechanism in browser-google-auth-ua.ts: copied-in cookies "sent under a UA that doesn't match a real first-party browser get flagged by anti-fraud." That is why the Google auth-host switch exists; stablyai#18749 kept it for accounts.google.com and handed every other host an Electron identity. Restore the pre-stablyai#18749 session identity: strip the Electron and app tokens, and rewrite sec-ch-ua to match. Nothing in the cookie-import write path changed -- it never did; cookies were always written correctly and servers were refusing them. Deliberately KEPT from stablyai#18749, all independent of the UA: - anti-detection.ts stays deleted. Its premises were measured false on Electron 43 and its overrides are themselves published bot signatures. - No Runtime.enable into cross-origin iframes (the documented Cloudflare CDP tell). - No unconditional CDP debugger attach on every browsing guest. Known tradeoff, measured: this re-opens stablyai#13822. On the unmerged predecessor branch brennan/sta-3905-cloudflare-ua, commit 9f0a477 recorded the stock UA clearing dash.cloudflare.com 5/5 while every rewritten variant failed 12/12, and noted that adding client hints does not rescue it. So Cloudflare-gated sites will show verification failures again until a coherent-identity fix lands. That is a bounded, in-app annoyance; session revocation damages users' real accounts. A CDP Emulation.setUserAgentOverride with full userAgentMetadata -- which drives navigator.userAgentData as well as the headers, and was never tested -- is the candidate that could satisfy both, and is being measured separately. Tests: the real-Electron wire-identity test now asserts the stripped identity on ordinary hosts and Firefox on Google auth hosts. Ablation-verified: neutering cleanElectronUserAgent turns it red on the Electron-token assertion. Its fixture also gained an app name -- without one the raw UA carried no app token, so the Orca/x.y.z half of the cleaner was never exercised. * fix(browser): finish the identity revert in the files CI caught browser-session-registry.persistence.test.ts still asserted stablyai#18749's behaviour ("keeps the stock UA", "keeps the engine UA"), so the shipped code and its test disagreed. Caught by CI shard 4/8, not locally: I reverted four test files and went to typecheck without re-running the browser suite. Also restores the accurate wording that stablyai#18749 generalised away, now that the behaviour it described is back: - browser-google-auth-ua.ts: names the Electron/Chrome-shaped UA again as what anti-fraud flags, which is the reason the auth-host switch exists at all. - docs/browser/profiles.mdx: documents the cleaned Chrome UA default and the --no-ua-spoof escape hatch, which is real again. - tests/tools/google-signin-ua-probe.cjs: comments name the live handler. Deliberately left at stablyai#18749's version, because those changes stay correct with anti-detection.ts deleted: - browser-manager-viewport.ts: its comment no longer cites the retired addScriptToEvaluateOnNewDocument injection. - browser-webauthn-profile-delete.test.ts: its added webRequest mock is REQUIRED by the restored setupClientHintsOverride, so reverting it would break the test. * fix(browser): keep restored UA hints browser-owned --------- Co-authored-by: Merge Sim <sim@local> (cherry picked from commit fb85f88)



Problem
Since v1.4.198 the embedded browser announces itself on every non-Google host as:
No browser sends that. Sites that re-check the identity holding a session reject it — reports of being signed out of x.com, LinkedIn and "most websites."
This escapes our app. One reporter was signed out of LinkedIn in their own Chrome and met LinkedIn's "Quick security check … suspicious activity" SMS flow. Orca's cookie jar cannot touch Chrome's, so that is server-side session revocation.
436ef827dd(#18749, merged Sep 4) is the cause.v1.4.197does not contain it;v1.4.198(Sep 8) is the first build that does; first report Sep 9. It is the only identity-touching commit insrc/main/browserin that window.The repo already documented the mechanism, in a comment #18749 edited without acting on (
browser-google-auth-ua.ts): copied-in cookies "sent under a UA that doesn't match a real first-party browser get flagged by anti-fraud." That is why the Google auth-host switch exists. #18749 kept it foraccounts.google.comand gave every other host an Electron identity.Not a cookie-import bug. No cookie-import file changed on main since Aug 31, and the import attaches its own debugger (
browser-cookie-clear-store.ts:142-177), independent of the attach #18749 removed. Cookies were always written correctly; servers were refusing them.Fix
Strip the
Electron/x.y.zandOrca/x.y.ztokens from the session UA. That is the whole change.This is deliberately not Chrome impersonation. Chromium's client-hint identity (
sec-ch-ua*andnavigator.userAgentData) stays browser-owned and internally consistent — the pre-#18749 code also injected synthetic "Google Chrome" brands into two headers, and that is not restored, because it made the header and JS surfaces disagree while buying nothing (see the measurement below).Kept from #18749, all independent of the UA:
anti-detection.tsstays deleted — its premises were measured false on Electron 43 and its overrides are themselves published bot signaturesRuntime.enableinto cross-origin iframesRemoves the need for #19740 (per-host Electron-token stripping for WhatsApp Web).
Measured tradeoff: this re-opens #13822, and there is no design that avoids it
Ablation on a standalone Electron 43.6.0 / Chromium 150 harness against
dash.cloudflare.com/login, 5 reps per arm, fresh profile per run. Controls re-run after the matrix with no drift.Emulation.setUserAgentOverride+ completeuserAgentMetadatauserAgentDataall agreeRuntime.enable, including into the cross-origin iframeEvery arm claiming Google Chrome failed 25/25. Every arm publishing the Electron identity passed 25/25.
A7 is the isolating control: same override, same complete metadata, differing only in which identity it publishes. So the trigger is not the debugger attach, not the Emulation override, and not client-hint shape or coherence. A "coherent Chrome identity" fix was the obvious candidate and it is measured dead — three ways (A4, A4b, A8).
Scoping that claim precisely: this rig measured Turnstile outcomes only. It shows a Chrome-claiming
identity cannot clear Turnstile. It does not measure cookie acceptance — that the Electron identity
gets sessions revoked comes from user reports and documented UA-binding, not from this matrix. So
"irreconcilable" rests on measured-Turnstile plus reported-sessions, and this is a forced choice. Taking it knowingly: a Turnstile failure is bounded and confined to our browser; session revocation damages users' real accounts and demands SMS re-verification.
The permanent fix therefore has to scope the identity rather than find a better global disguise, and the
same rig measured why that is hard.
Emulation.setUserAgentOverrideis target-wide and forward-only:it reaches only frames created after it is set, a pre-existing cross-origin iframe keeps the old identity
indefinitely, and a cross-host top-level navigation does not clear it. So switching identity on a live
page produces a split-identity page — top frame claiming Chrome while an embedded third-party frame still
says Electron — which is a sharper contradiction than either identity alone. Header-only scoping is arm A3,
which fails, and there is no per-partition or per-session seam either: CDP offers no partition-scoped
identity, and Electron's per-partition primitive (
session.setUserAgent) sets only the UA string, whichis A3. The only seam that is both coherent and enforceable is per-WebContents, set before the first
navigation and immutable for that WebContents' lifetime — identity decided at guest creation, not at
navigation time, with navigation off the host forced into a fresh WebContents carrying the default
identity. That is follow-up work, not this PR, and whether it rescues cookie acceptance at all is
unmeasured.
Incidentally, A9/A10 bear on #18749's premise that OOPIF
Runtime.enableis the Cloudflare tell. WithRuntime.enableplus aRuntime.evaluatelanded inside the challenge frame itself (verified byreading
location.hrefin the child session), the challenge still passed 3/3. That refutes thenecessity claim — removing it was not required for Turnstile to clear here — but not the weaker
claim that Cloudflare can observe it: detection is not the same as challenge failure, and it could
be weighted differently on higher-risk paths. That change is harmless and is left in place.
Tests
cleanElectronUserAgentturns it red on the Electron-token assertion.Orca/x.y.zhalf of the cleaner was never exercised and the test passed while half-testing.Caveats, stated rather than buried
identity versus 0/25 on every Chrome-claiming configuration, on
dash.cloudflare.com. For the full-pageinterstitial class, no configuration cleared it in this rig — including the shipped one, 0/44 across three
sites — but that positive control did not reproduce, and the non-reproduction is unattributed (hidden
never-focused window, fresh profile per run, or Cloudflare tightening since Sep 4 are all live). It should
not be cited as evidence that the shipped build fails interstitials for users. Earning the stronger claim
needs a visible focused window on an isolated display or CI, which the environment rules prohibit here.
So the mechanism is well-supported for the embedded-widget class and unverified for the interstitial class.