Skip to content

Make embedded sessions identify as Firefox from startup#437

Merged
Cheggin merged 3 commits into
mainfrom
reagan/fix-bot-detection
May 17, 2026
Merged

Make embedded sessions identify as Firefox from startup#437
Cheggin merged 3 commits into
mainfrom
reagan/fix-bot-detection

Conversation

@Cheggin
Copy link
Copy Markdown
Collaborator

@Cheggin Cheggin commented May 16, 2026

Summary

  • centralize the embedded browser identity as a Firefox-compatible profile from app startup
  • apply the Firefox UA to app fallback, default session requests, and BrowserPool views
  • strip Chromium UA client hints and remove the JS-level webdriver shim/navigation-time identity switching path

Testing

  • cd app && npm run test -- tests/unit/sessions/browserIdentity.test.ts
  • task typecheck

Notes

  • User manually reported this path worked for the Google sign-in block.
  • The worktree still has unrelated dirty files that are intentionally not included in this PR.

Summary by cubic

Make embedded sessions present as Firefox from startup to avoid Google sign‑in blocks and bot detection. Identity is applied app‑wide and we reduced other detection surfaces (CDP port and cookie import).

  • Bug Fixes

    • Centralized Firefox identity in browserIdentity (UA, language, platform). Applied at startup via app.userAgentFallback, session.defaultSession (UA + Accept-Language), webRequest.onBeforeSendHeaders, and per‑view in BrowserPool.
    • Stripped Chromium UA Client Hints on all requests with withBrowserIdentityHeaders. Disabled AutomationControlled and UA Client Hints; enabled WebShare.
    • Moved default CDP port to a random high port (away from 9222). Updated verifyCdpOwnership to accept the app UA.
    • Fixed Chrome cookie import with electronCookieDetailsForImport to preserve host‑only cookies and empty values.
    • Removed UA cleaning and the navigator.webdriver shim. Added unit tests for identity, headers, cookies, CLI port logic, and BrowserPool.
  • Refactors

    • Merged latest main and kept chatfile protocol and preview parking updates alongside identity hardening.

Written for commit 2f29c6e. Summary will update on new commits. Review in cubic

Google sign-in rejected the embedded Electron browser when identity was changed late or exposed Chromium/Electron client hints. This centralizes the browser identity in main/session startup, removes the renderer-level webdriver override, and strips UA client hints from outgoing requests so Google sees a consistent Firefox-compatible profile before navigation begins.

Constraint: Google blocks Electron-style and automation-like sign-in surfaces
Rejected: Navigation-time CDP user-agent switching | crashed during auth redirects and changed identity too late
Rejected: JavaScript navigator.webdriver shims | user explicitly wanted no JS-level spoofing
Confidence: medium
Scope-risk: moderate
Directive: Do not reintroduce Google-specific navigation-time identity switching without reproducing auth redirects and crash behavior
Tested: cd app && npm run test -- tests/unit/sessions/browserIdentity.test.ts
Tested: task typecheck
Not-tested: Full manual Google sign-in in a freshly restarted packaged app by this agent
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

Cheggin added 2 commits May 16, 2026 16:33
Bring the feature/chat-view baseline into the bot-detection branch while preserving the Firefox-compatible browser identity from startup. The conflict resolution keeps main's chatfile protocol and preview parking changes alongside the branch's UA/header hardening, and updates CDP ownership verification to accept the intentional app-level UA.

Constraint: PR branch must be refreshed against origin/main before review

Rejected: Rebase | branch is already pushed and has an open PR

Confidence: medium

Scope-risk: moderate

Tested: yarn install --frozen-lockfile

Tested: task typecheck

Tested: task lint (0 errors, 91 warnings)

Tested: npm run test -- tests/unit/startup/cli.test.ts tests/unit/sessions/browserIdentity.test.ts tests/unit/sessions/BrowserPool.test.ts tests/unit/protocols/chatfile.test.ts tests/unit/sessions/SessionScreencast.test.ts

Not-tested: Full app runtime Google sign-in after merge
Move the default CDP listener off the conventional 9222 debugging port, keep the Firefox user-agent behavior covered in BrowserPool tests, and preserve imported Google cookies whose host-only or empty-value shape matters for sign-in continuity.

Constraint: Google sign-in is sensitive to embedded-browser and automation surfaces

Rejected: Keep 9222 as the default CDP port | it is the conventional Chrome debugging port and easy for detection scripts or local Chrome collisions to probe

Rejected: Always set Electron cookie domain | host-only __Host cookies become invalid when a domain attribute is supplied

Confidence: medium

Scope-risk: moderate

Tested: npm run test -- tests/unit/chrome-import/cookies.test.ts tests/unit/startup/cli.test.ts tests/unit/sessions/BrowserPool.test.ts tests/unit/sessions/browserIdentity.test.ts

Tested: task typecheck

Not-tested: Full live Google sign-in flow by this commit author
@Cheggin Cheggin merged commit 01b9742 into main May 17, 2026
10 checks passed
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.

1 participant