Repository navigation
fix(browser): present Electron's own user agent so Cloudflare Turnstile clears - #18749
Conversation
…le clears Orca rewrote every browser session's UA to look like plain Chrome by stripping the Electron and app tokens. That rewrite is what Cloudflare rejects: a Chrome UA that ships no client hints reads as a spoof and Turnstile returns 600010, while the same binary on the same IP clears every challenge with its stock UA. PR #885 added the rewrite to fix 600010 and was treating a symptom it created; issue #11518 later found the same rewrite is what broke Google sign-in. - Keep the stock Electron UA on every partition. The webRequest handler now only owns the host-scoped Google auth Firefox switch, which stays unchanged. - Delete the anti-detection script. Measured on Electron 43: plugins are already a real PluginArray, window.chrome exists, and navigator.webdriver is false even with the debugger attached, so three of its four premises were wrong, and the overrides it installed (instance-level webdriver, non-native Permissions.query, stubbed chrome.csi/loadTimes) are themselves published bot signatures. - Stop attaching a CDP debugger to every browsing guest. Only the auth-UA detach listener remains, because a detach clears Chromium's standing UA override. - Stop sending Runtime.enable into cross-origin iframes when the agent bridge auto-attaches. The challenge widget is one, nothing reads iframe Runtime events, and the Runtime domain's serialization side effect is the documented Cloudflare CDP tell. - Add a real-Electron test proving the wire identity: stock UA to ordinary hosts, Firefox with no client hints to accounts.google.com. Verified in the dev build: dash.cloudflare.com/login no longer shows "There was a problem with verification" and scrapingcourse.com's managed challenge clears, both failing deterministically before. Fixes #13822
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (32)
💤 Files with no reviewable changes (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change removes anti-detection script injection and related debugger reattachment. Browsing guests now track debugger detach events to clear authentication user-agent state. Session and viewport handling preserve Electron’s user agent outside Google authentication hosts, where requests use a Firefox identity without client hints. Tests, fixtures, documentation, and reliability assertions were updated. Merge Risk: ⚪ Minimal · up to The browser identity changes preserve Electron identity outside the scoped Google authentication override, and the updated lifecycle and network behavior are covered by focused tests. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 25 files. (2 skipped: 2 unsupported.)
✨ 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.
✅ No new issues found.
Reviewed changes
This PR removes Orca's user-agent rewrite and the anti-detection script so the embedded browser presents Electron's stock UA everywhere except Google auth hosts, which Cloudflare Turnstile rejects (600010) when the UA is Chrome-shaped but ships no client hints.
- Delete the UA-cleaning layer —
cleanElectronUserAgent/setupClientHintsOverrideinbrowser-session-ua.tsare replaced bysetupGoogleAuthUserAgentOverride, which now only owns the host-scoped Google auth Firefox switch (Firefox UA + stripsec-ch-ua*on auth hosts, strip hints on cross-host Firefox-UA requests). - Stop spoofing at the session level —
browser-session-partition-policies.tsno longer callssess.setUserAgent(cleanUA); both install paths now only register the Google switch for non-nativeprofiles. - Delete the anti-detection script and its tests —
anti-detection.ts(andanti-detection*.test.ts) are removed, including thenavigator.webdriver,plugins,window.chrome,Permissions.query, andNotification.permissionoverrides. - Stop attaching a debugger to browsing guests —
browser-manager-state.tsreplacesinjectAntiDetectionwithtrackDebuggerDetachForAuthUserAgent(adetachlistener that clears the confirmed auth-UA override record), and the CDPPage.addScriptToEvaluateOnNewDocumentinjections are dropped fromcdp-debugger-channel.ts/cdp-debugger-lifecycle.ts. - Stop
Runtime.enableinto cross-origin iframes —cdp-debugger-events.tskeeps onlyDOM.enable/Accessibility.enable. - Add a real-Electron wire test —
browser-session-ua-wire-identity.electron.test.tscapturesonSendHeadersas headers leave the network stack: stock Electron UA to ordinary hosts, Firefox with zero client hints toaccounts.google.com.
I verified the affected unit suites (117 tests) and the new Electron test pass, and confirmed there are no remaining production references to the deleted exports. The change is internally consistent: browser-manager-navigation.ts and the viewport builder now resolve the session's own stock UA as the base identity, and applyGoogleAuthUserAgent's restore path (guest.session.getUserAgent()) agrees with it.
ℹ️ Nitpicks
config/reliability-gates.jsonc:3397— the gatesummarystill describes a browsing guest's machinery as including "anti-detection over the debugger", which this PR removes (theoracleat line 2858 was updated, this prose summary was not). Harmless but stale.browser-session-ua-wire-identity.electron.test.ts:170— thenavigatorUserAgent === sessionUserAgentassertion is read after the fixture has navigated toaccounts.google.com. Since the fixture installs only the header-level switch (not the CDP-levelapplyGoogleAuthUserAgentthat the real product uses), this asserts the fixture's own behavior rather than a product invariant — in the shipped appnavigator.userAgenton the auth host is Firefox. The wire-header assertions are the load-bearing part; this line is a soft sanity check.
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.
…19927) * fix(browser): restore the Chrome-shaped browser identity (STA-7147) #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. * fix(browser): finish the identity revert in the files CI caught 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. * fix(browser): keep restored UA hints browser-owned --------- Co-authored-by: Merge Sim <sim@local>
…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)
…le clears (stablyai#18749) Orca rewrote every browser session's UA to look like plain Chrome by stripping the Electron and app tokens. That rewrite is what Cloudflare rejects: a Chrome UA that ships no client hints reads as a spoof and Turnstile returns 600010, while the same binary on the same IP clears every challenge with its stock UA. PR stablyai#885 added the rewrite to fix 600010 and was treating a symptom it created; issue stablyai#11518 later found the same rewrite is what broke Google sign-in. - Keep the stock Electron UA on every partition. The webRequest handler now only owns the host-scoped Google auth Firefox switch, which stays unchanged. - Delete the anti-detection script. Measured on Electron 43: plugins are already a real PluginArray, window.chrome exists, and navigator.webdriver is false even with the debugger attached, so three of its four premises were wrong, and the overrides it installed (instance-level webdriver, non-native Permissions.query, stubbed chrome.csi/loadTimes) are themselves published bot signatures. - Stop attaching a CDP debugger to every browsing guest. Only the auth-UA detach listener remains, because a detach clears Chromium's standing UA override. - Stop sending Runtime.enable into cross-origin iframes when the agent bridge auto-attaches. The challenge widget is one, nothing reads iframe Runtime events, and the Runtime domain's serialization side effect is the documented Cloudflare CDP tell. - Add a real-Electron test proving the wire identity: stock UA to ordinary hosts, Firefox with no client hints to accounts.google.com. Verified in the dev build: dash.cloudflare.com/login no longer shows "There was a problem with verification" and scrapingcourse.com's managed challenge clears, both failing deterministically before. Fixes stablyai#13822

Summary
Cloudflare Turnstile fails inside Orca's embedded browser ("Verification failed" / error 600010) while the same sites pass in Chrome. The cause is Orca's own user-agent rewrite: stripping the
Electron/xandorca/xtokens to present a plain-Chrome UA is what Cloudflare rejects, because a Chrome UA that ships no client hints reads as a spoof. The same Electron binary, machine and IP clears every challenge with its stock UA.PR #885 introduced that rewrite specifically to fix 600010, so it was treating a symptom it created. Issue #11518 later found the same rewrite is what broke Google sign-in.
Changes
webRequesthandler now only owns the host-scoped Google auth Firefox switch, which is unchanged.PluginArray,window.chromeexists, andnavigator.webdriverisfalsewith the debugger attached. Three of its four premises were false, and the overrides it installed (instance-levelwebdriver, non-nativePermissions.prototype.query, stubbedchrome.csi/loadTimes) are themselves published bot signatures.Runtime.enableinto cross-origin iframes when the agent bridge auto-attaches. The Turnstile widget is one, nothing reads iframe Runtime events, and that domain's serialization side-effect is the documented Cloudflare CDP tell.browser-session-ua-wire-identity.electron.test.ts) that captures headers as they leave the network stack: stock UA to ordinary hosts, Firefox with zero client hints toaccounts.google.com. Reintroducing the rewrite turns it red.Evidence
Deterministic A/B, same binary, fresh partition per run, interleaved:
sec-ch-uaheaders addeduserAgentMetadatamatching headersTLS (JA4) and HTTP/2 fingerprints are byte-identical to real Chromium, so the network layer is not involved. Verified in the dev build after the change: the dashboard login form renders with no verification error and Sign in enabled, and the managed challenge reports bypassed.
Regression considerations
/v3/signin/rejectedwhile the stock UA completed and stayed usable. The Firefox auth-host switch is kept as-is.--no-ua-spoof) now behave like every other profile except that they also skip the Google switch. The setting is retained for wire compatibility.Electron/token will now see it. That is the trade every comparable embedded-browser app makes; a per-host allowlist can be added if a specific site turns up.setPermissionCheckHandler(geolocation/midi currently reportdenied), which the deleted script tried and failed to paper over from the page side.Test plan
pnpm tcpnpm exec vitest run src/main/browser(166 files, 1643 tests) plussrc/main/windowand runtime browser tests*.electron.test.tspasses, and fails when the UA rewrite is reintroducedcheck:code-quality:changedandcheck:react-doctor:changedcleandash.cloudflare.com/loginandscrapingcourse.com/cloudflare-challengeFixes #13822