Repository navigation
fix(browser): align anti-detection identity signals - #14685
Conversation
|
Warning Review limit reached
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 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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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 |
Review loop: CLEAN after follow-up
|
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.
Turnstile residual: RESOLVED — no regressionThe residual flagged before merge is now settled with a real before/after, so no revert is indicated. MethodIsolated Orca dev builds from current Sites tested (all live, Cloudflare-protected)
All four reached HTTP 200 real content both before and after the merge. Guest signals confirmed
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 inconclusiveThe earlier attempt dispatched CDP-synthesized clicks at an interactive widget. Turnstile is explicitly designed not to solve for synthetic input, so an empty 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: |
…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
|
thanks for reporting. looking into it |
…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
* fix(browser): align anti-detection identity signals * fix(browser): hide native Chrome global for Firefox
…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


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()andchrome.loadTimes()are gated behind!navigator.userAgent.includes('Firefox/'). The guards were previously existence checks, never UA checks, while we present a Firefox UA onaccounts.google.com/accounts.youtube.com.2. The
chrome.runtime = {}stub is removed. Real Chrome reportschrome.runtime === undefinedon an ordinary page — measured. The stub added to look more like Chrome made us look less like it.3.
promptPermsnarrowed tocamera/microphone. Those two genuinely resolve through macOS TCC, so'prompt'is honest.geolocation,midi,idle-detectionandstorage-accessare hard-denied bybrowser-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:
window.chrome.runtimeundefinedobjectGH #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-accessis 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
Extended the existing
runInNewContextharness. 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 typecheckclean ·oxlintclean ·oxfmt --checkclean.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
max-linesdisable or baseline bump