Skip to content

fix(browser): improve Cloudflare Turnstile compatibility - #885

Merged
Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/browser-cloudflare
Apr 21, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/browser-cloudflare

Conversation

@Jinwoo-H

Copy link
Copy Markdown
Contributor

Summary

  • Fix blob: URL blocking in navigation guard that prevented Turnstile from loading challenge resources in iframes
  • Fix anti-detection script injection timing — switch from broken executeJavaScript on did-start-navigation (runs on old page) to CDP Page.addScriptToEvaluateOnNewDocument (persists across navigations, runs before page JS)
  • Expand anti-detection signals: chrome.csi(), chrome.loadTimes(), Notification.permission, navigator.languages
  • Mask CDP proxy identifiers (Orca/CdpWsProxy → Chrome/Headless)
  • Strip Electron/app tokens from default UA even without imported sessions
  • Widen passive permission checks so bot detectors see a normal browser fingerprint
  • Extract UA/Client-Hints helpers to browser-session-ua.ts

Context

Cloudflare Turnstile challenges fail with error 600010 ("bot behavior detected") in Orca's embedded browser (issue #107). This was caused by multiple detection vectors: blocked blob: URLs, missing anti-detection overrides due to injection timing, leaked Electron identifiers, and suspicious permission fingerprints.

Note: Turnstile uses deep runtime fingerprinting that no public Electron app has reliably bypassed. These fixes address the most impactful detection vectors but may not fully resolve all Turnstile challenges — the error may also be influenced by site-side Turnstile configuration (e.g., PropelAuth's security level).

Test plan

  • pnpm run typecheck passes
  • pnpm run test passes (209/210, 1 pre-existing flaky test in codex-accounts)
  • Navigate to https://auth.propelauth.com/challenge in embedded browser and attempt Turnstile verification
  • Verify blob: URL navigations in iframes are not blocked
  • Verify anti-detection overrides persist across page navigations
  • Verify CDP proxy reports Chrome/Headless instead of Orca/CdpWsProxy
  • Verify User-Agent does not contain "Electron" or app name

…browser

Cloudflare Turnstile challenges fail with error 600010 ("bot behavior
detected") in Orca's embedded browser. Multiple detection vectors
contribute to this:

1. Navigation guard blocks blob: URLs that Turnstile uses to load
   challenge resources inside iframes.
2. Anti-detection script injection via executeJavaScript on
   did-start-navigation runs on the OLD page context — overrides are
   never present when the new page loads.
3. CDP proxy endpoints leak "Orca/CdpWsProxy" and "Orca/Electron"
   identifiers.
4. User-Agent contains "Electron/X.X.X" and the app name even without
   an imported browser session.
5. Permission check handler returns false for all non-clipboard
   permissions, making the fingerprint look bot-like.

Fixes:
- Allow blob: URLs through the navigation guard
- Switch to CDP Page.addScriptToEvaluateOnNewDocument for reliable
  pre-page-JS injection (re-attaches after debugger detach)
- Extract shared anti-detection script with expanded signals:
  navigator.webdriver, plugins, chrome.csi/loadTimes, Notification
  permission, navigator.languages
- Mask CDP proxy identifiers as Chrome/Headless
- Strip Electron/app tokens from default UA and non-default partitions
- Widen passive permission checks to reduce bot-detection signal
- Extract UA/Client-Hints helpers to browser-session-ua.ts
- Add disposed flag and cleanup function to injectAntiDetection to
  prevent re-attach after guest teardown; wire cleanup into
  policyCleanupByGuestId
- Increase re-attach delay from 100ms to 500ms to avoid racing with
  CDP proxy/bridge mid-restart
- Tighten blob: URL passthrough to require http(s) origin, blocking
  blob:null and other opaque-origin blobs
- Replace "Chrome/Headless" with real Chromium version from
  process.versions.chrome in CDP proxy endpoints
- Revert widened setPermissionCheckHandler (returns 'granted' not
  'prompt'); move permission masking to anti-detection script where
  Permissions.prototype.query can return the correct 'prompt' state
- Switch from dynamic require to top-level import for anti-detection
  module in browser-manager
@Jinwoo-H
Jinwoo-H merged commit 55e935f into main Apr 21, 2026
2 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/browser-cloudflare branch April 21, 2026 05:36
@AmethystLiang

Copy link
Copy Markdown
Contributor

looking into it

@OrcaWin OrcaWin mentioned this pull request Aug 12, 2026
Jinwoo-H added a commit that referenced this pull request Sep 5, 2026
…le clears (#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 #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
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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
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.

2 participants