Skip to content

fix(browser): align anti-detection identity signals - #14685

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-anti-detection-identity-gating
Aug 15, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-anti-detection-identity-gating

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

We were telling Google's sign-in page "I'm Firefox" while handing it Chrome-only APIs, and telling sites a permission would prompt when we were going to silently deny it. Both now tell one story.

What Changed

1. Chrome-only globals are no longer shipped under the Firefox auth UA. window.chrome, chrome.csi() and chrome.loadTimes() are gated behind !navigator.userAgent.includes('Firefox/'). The guards were previously existence checks, never UA checks, while we present a Firefox UA on accounts.google.com / accounts.youtube.com.

2. The chrome.runtime = {} stub is removed. Real Chrome reports chrome.runtime === undefined on an ordinary page — measured. The stub added to look more like Chrome made us look less like it.

3. promptPerms narrowed to camera / microphone. Those two genuinely resolve through macOS TCC, so 'prompt' is honest. geolocation, midi, idle-detection and storage-access are hard-denied by browser-session-permission-policy.ts, so reporting 'prompt' sent sites down a "the user will be asked" branch that ended in a silent denial.

Why

Measured against real Chrome 151, same Mac and page:

probe real Chrome Orca (before)
window.chrome.runtime undefined object

GH #12852 reports "Email signing fails at the anti bot verification" in the in-app browser. An identity that contradicts itself across layers is exactly what those checks key on.

The permission policy is deliberately unchanged — whether to grant storage-access is a separate product decision, and this PR only stops misreporting the current policy.

Linked Issue

Fixes #14681

Visual Proof

N/A — no visual surface; the change is observable only via JS APIs presented to pages. Live before/after measurements are in Testing.

Testing

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

Extended the existing runInNewContext harness. Verified non-vacuous: reverting the production change turns 6 of 8 tests red (Chrome globals under a Firefox identity, stub alignment with an ordinary Chrome page, and the four preserved denied states).

Gates: 643 browser tests pass · pnpm typecheck clean · oxlint clean · oxfmt --check clean.

Not verified: a live Cloudflare Turnstile challenge end to end. The public demo uses an always-passes dummy sitekey, so it proves nothing. Since these stubs exist for Turnstile (#885), that gap is called out rather than glossed.

Review

Security: only removes/gates signals presented to pages; it cannot widen what a site sees. Cross-platform: pure JS in the injected script, no platform branches. No IPC, path, or shell changes.

Checklist

  • Scope kept tight — permission policy untouched
  • No max-lines disable or baseline bump

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@brennanb2025, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0de2c6fb-084b-4417-8e2c-af1163d206c2

📥 Commits

Reviewing files that changed from the base of the PR and between e570cad and a1f3d21.

📒 Files selected for processing (2)
  • src/main/browser/anti-detection.test.ts
  • src/main/browser/anti-detection.ts

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop: CLEAN after follow-up a1f3d215be

A same-model review loop ran against this PR and found one real gap in the original fix, which is now pushed.

The gap it found

The original gate only skipped adding Chrome stubs under the Firefox UA — but Electron exposes a native window.chrome of its own, so the object was still present on the auth hosts this PR exists to clean up. "Don't add" is not "not present."

a1f3d215be deletes the native property on the Firefox path, with a fallback for the non-configurable case.

The test fixture was the reason this slipped: it started from window: {} (no chrome at all), so it could not detect a native leak. It now starts from Electron 43's real shape (window.chrome already exists) and asserts 'chrome' in window === false rather than merely undefined.

Mutation evidence

  • Reverting the full production hunk to the merge-base: 6 of 8 tests fail — Firefox Chrome-global leakage, the chrome.runtime stub, and all four falsely-prompted hard-denied permissions.
  • Reverting only the follow-up: the realistic Firefox assertion fails — window.chrome stays {} instead of becoming absent.

Both independently re-run and confirmed.

Live proof — real accounts.google.com in an Orca guest

CDP port 9336 / renderer 5176, both verified by lsof + ps to belong to this worktree; the temporary renderer-port config was reverted before commit (confirmed: the pushed head touches only the two source files).

On the rendered Google sign-in document:

  • UA Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:140.0) Gecko/20100101 Firefox/140.0
  • typeof window.chrome === 'undefined' and 'chrome' in window === false
  • chrome.runtime, chrome.csi, chrome.loadTimes all absent; navigator.webdriver === false
  • Permissions: camera/microphone prompt; geolocation, MIDI, idle-detection, storage-access denied

This also proves the UA is already Firefox when the new-document script evaluates, so the gate does not fail open on normal navigation.

live proof

Residual risk — needs an explicit accept before merge

Turnstile was tested against a real sitekey (0x4AAAAAADogn3t3_JKwKkgS), not the always-pass dummy family. The widget rendered and input was dispatched, but cf-turnstile-response stayed empty — on both merge-base behavior and HEAD. So this run shows no evidence that removing the chrome.runtime stub caused a regression, but it also does not demonstrate a Turnstile pass.

Impact would be high for Turnstile-protected sign-ins; likelihood unknown. The removal is aligned with measured Chrome 151 behavior (chrome.runtime === undefined on an ordinary page), which is the argument for it.

Filed separately, deliberately not fixed here

#14698 — on a cold app start the first guest can receive no anti-detection injection at all. Pre-existing, unrelated to this change, kept out of scope.

@brennanb2025
brennanb2025 merged commit 0f7707b into main Aug 15, 2026
44 checks passed
brennanb2025 added a commit that referenced this pull request Aug 15, 2026
Rebased onto main after #14685 landed in the same file. Both changes coexist:
#14685's Firefox gating and narrowed promptPerms are preserved untouched, and
this change replaces only the query-override implementation.

The previous Proxy bound every callable property, which broke three observable
things:
- onchange assignment threw "Illegal invocation" — the native setter received
  the proxy rather than the branded target.
- Listeners were delivered with the real target and the NATIVE state, so on a
  real permission change event.target.state read 'granted' while the returned
  status still read 'prompt'.
- Method reads returned a new bound function each time, so name became
  'bound addEventListener', toString lost its name, and identity was unstable.

Separately, the notifications state was captured once as a string, so an
already-returned status went stale after requestPermission updated it.

Shadow only 'state' on the genuine PermissionStatus with a lazy provider. The
object the site holds IS the real one, so identity, brand checks, method
fingerprints and native event delivery survive with nothing to keep in sync.

Verified against real Chromium (Chrome 151) rather than only the vm stand-in,
because the stand-in cannot show whether defineProperty succeeds on a branded
instance: the instance is extensible, the prototype 'state' accessor is
configurable, defineProperty succeeds, instanceof survives, addEventListener
keeps its native name and referential stability, and onchange assignment works.

New tests live in their own file rather than merged into anti-detection.test.ts,
whose harness diverged on main. The fallback test targets 'camera' because
#14685 narrowed the intercepted set, so a name outside it never reaches the
fallback.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Turnstile residual: RESOLVED — no regression

The residual flagged before merge is now settled with a real before/after, so no revert is indicated.

Method

Isolated Orca dev builds from current origin/main (68ca17e) and from this PR's immediate parent (34eca1e) — verified as the parent of merge commit 0f7707b146. Worktree-owned CDP and renderer ports verified via lsof+ps, fresh profiles, identical live navigations on both sides.

Sites tested (all live, Cloudflare-protected)

claude.ai · canva.com · cloudflare.com · discord.com

All four reached HTTP 200 real content both before and after the merge.

after-discord.png

Guest signals confirmed

signal before after
typeof chrome.runtime object undefined (the intended change)
typeof window.chrome object object (retained)
typeof chrome.csi function function (retained)
navigator.webdriver false false

So the one signal this PR meant to change did change, the signals Turnstile actually probes were retained, and no protected site regressed.

Why the pre-merge test was inconclusive

The earlier attempt dispatched CDP-synthesized clicks at an interactive widget. Turnstile is explicitly designed not to solve for synthetic input, so an empty cf-turnstile-response was the expected outcome on a healthy browser — which is exactly why merge-base behaved identically. That run was a harness artifact and proved nothing either way.

Testing the non-interactive challenge path instead — the common user path — is automatable, and it passes.

Verdict: PASS. Consistent with the original justification, which was measured on real Chrome 151: chrome.runtime === undefined on an ordinary page, so the {} stub was itself the anomaly.

brennanb2025 added a commit that referenced this pull request Aug 17, 2026
…14684)

* fix(browser): shadow PermissionStatus state instead of proxying it

Rebased onto main after #14685 landed in the same file. Both changes coexist:
#14685's Firefox gating and narrowed promptPerms are preserved untouched, and
this change replaces only the query-override implementation.

The previous Proxy bound every callable property, which broke three observable
things:
- onchange assignment threw "Illegal invocation" — the native setter received
  the proxy rather than the branded target.
- Listeners were delivered with the real target and the NATIVE state, so on a
  real permission change event.target.state read 'granted' while the returned
  status still read 'prompt'.
- Method reads returned a new bound function each time, so name became
  'bound addEventListener', toString lost its name, and identity was unstable.

Separately, the notifications state was captured once as a string, so an
already-returned status went stale after requestPermission updated it.

Shadow only 'state' on the genuine PermissionStatus with a lazy provider. The
object the site holds IS the real one, so identity, brand checks, method
fingerprints and native event delivery survive with nothing to keep in sync.

Verified against real Chromium (Chrome 151) rather than only the vm stand-in,
because the stand-in cannot show whether defineProperty succeeds on a branded
instance: the instance is extensible, the prototype 'state' accessor is
configurable, defineProperty succeeds, instanceof survives, addEventListener
keeps its native name and referential stability, and onchange assignment works.

New tests live in their own file rather than merged into anti-detection.test.ts,
whose harness diverged on main. The fallback test targets 'camera' because
#14685 narrowed the intercepted set, so a name outside it never reaches the
fallback.

* test(browser): cover intercepted PermissionStatus identity
@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…tablyai#14684)

* fix(browser): shadow PermissionStatus state instead of proxying it

Rebased onto main after stablyai#14685 landed in the same file. Both changes coexist:
stablyai#14685's Firefox gating and narrowed promptPerms are preserved untouched, and
this change replaces only the query-override implementation.

The previous Proxy bound every callable property, which broke three observable
things:
- onchange assignment threw "Illegal invocation" — the native setter received
  the proxy rather than the branded target.
- Listeners were delivered with the real target and the NATIVE state, so on a
  real permission change event.target.state read 'granted' while the returned
  status still read 'prompt'.
- Method reads returned a new bound function each time, so name became
  'bound addEventListener', toString lost its name, and identity was unstable.

Separately, the notifications state was captured once as a string, so an
already-returned status went stale after requestPermission updated it.

Shadow only 'state' on the genuine PermissionStatus with a lazy provider. The
object the site holds IS the real one, so identity, brand checks, method
fingerprints and native event delivery survive with nothing to keep in sync.

Verified against real Chromium (Chrome 151) rather than only the vm stand-in,
because the stand-in cannot show whether defineProperty succeeds on a branded
instance: the instance is extensible, the prototype 'state' accessor is
configurable, defineProperty succeeds, instanceof survives, addEventListener
keeps its native name and referential stability, and onchange assignment works.

New tests live in their own file rather than merged into anti-detection.test.ts,
whose harness diverged on main. The fallback test targets 'camera' because
stablyai#14685 narrowed the intercepted set, so a name outside it never reaches the
fallback.

* test(browser): cover intercepted PermissionStatus identity
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(browser): align anti-detection identity signals

* fix(browser): hide native Chrome global for Firefox
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#14684)

* fix(browser): shadow PermissionStatus state instead of proxying it

Rebased onto main after stablyai#14685 landed in the same file. Both changes coexist:
stablyai#14685's Firefox gating and narrowed promptPerms are preserved untouched, and
this change replaces only the query-override implementation.

The previous Proxy bound every callable property, which broke three observable
things:
- onchange assignment threw "Illegal invocation" — the native setter received
  the proxy rather than the branded target.
- Listeners were delivered with the real target and the NATIVE state, so on a
  real permission change event.target.state read 'granted' while the returned
  status still read 'prompt'.
- Method reads returned a new bound function each time, so name became
  'bound addEventListener', toString lost its name, and identity was unstable.

Separately, the notifications state was captured once as a string, so an
already-returned status went stale after requestPermission updated it.

Shadow only 'state' on the genuine PermissionStatus with a lazy provider. The
object the site holds IS the real one, so identity, brand checks, method
fingerprints and native event delivery survive with nothing to keep in sync.

Verified against real Chromium (Chrome 151) rather than only the vm stand-in,
because the stand-in cannot show whether defineProperty succeeds on a branded
instance: the instance is extensible, the prototype 'state' accessor is
configurable, defineProperty succeeds, instanceof survives, addEventListener
keeps its native name and referential stability, and onchange assignment works.

New tests live in their own file rather than merged into anti-detection.test.ts,
whose harness diverged on main. The fallback test targets 'camera' because
stablyai#14685 narrowed the intercepted set, so a name outside it never reaches the
fallback.

* test(browser): cover intercepted PermissionStatus identity
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]: Anti-detection ships Chrome-only globals under the Firefox auth UA and misreports denied permissions

3 participants