Skip to content

fix(browser): reject Chromium product versions in cookie-import UA - #12811

Merged
Jinwoo-H merged 4 commits into
stablyai:mainfrom
innocarpe:fix/arc-cookie-ua-product-version
Aug 8, 2026
Merged

Jinwoo-H merged 4 commits into
stablyai:mainfrom
innocarpe:fix/arc-cookie-ua-product-version

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Description

Stop persisting broken Chrome/1.x User-Agents when importing cookies from Chromium forks (e.g. Arc) that report a product CFBundleShortVersionString.

Only engine-scale majors (>= 70) are advertised; otherwise import falls back to Electron's default UA.

Focused fix

  • In scope: isAdvertisableChromiumEngineVersion gate in getUserAgentForBrowser
  • Out of scope: reading Chromium's true engine version from alternate plists

Preserves

  • Real Chrome/Edge/Brave engine versions still build Chrome-shaped UAs
  • Non-darwin behavior unchanged (still returns null)

Evidence

  • Test: pnpm exec vitest run --config config/vitest.config.ts src/main/browser/browser-cookie-import.arc-ua.test.ts src/main/browser/browser-cookie-import.helium.test.ts (10 passed)

User-regression-tradeoffs

  • Arc import no longer sets a custom UA when only product version is available (safer default)

Fixes #12726

Do not persist Chrome/1.x User-Agents when a fork (e.g. Arc) reports its
product CFBundleShortVersionString. Only engine-scale majors (>=70) are
advertised; otherwise fall back to Electron's default UA.

Preserves Chrome-shaped UAs for real Chromium engine versions.

Fixes stablyai#12726
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a425480e-891a-47e7-8059-4c6e1b09e2fd

📥 Commits

Reviewing files that changed from the base of the PR and between 9825706 and e55737b.

📒 Files selected for processing (5)
  • src/main/browser/browser-cookie-import.arc-ua.test.ts
  • src/main/browser/browser-cookie-import.ts
  • src/main/browser/browser-session-registry.persistence.test.ts
  • src/main/browser/browser-session-registry.ts
  • src/main/browser/browser-session-ua.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/browser/browser-cookie-import.ts
  • src/main/browser/browser-session-registry.ts
  • src/main/browser/browser-session-registry.persistence.test.ts

📝 Walkthrough

Walkthrough

The change adds Chromium engine-version validation for numeric major versions of at least 70. Chromium-based browser user-agent generation now uses the shared chromeShapedUa helper. The helper handles unsupported versions and the Edge suffix while preserving existing browser shapes. Persisted user agents with unsupported Chrome versions are cleared during session restoration. Tests cover validation, user-agent generation, and persisted session cleanup.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fix and test evidence but omits the required Summary, Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes sections. Use the repository template and add all required sections, including completed test checkboxes, cross-platform AI review, security audit, and visual-change notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix: rejecting invalid Chromium product versions during cookie-import UA generation.
Linked Issues check ✅ Passed For [#12726], the PR rejects invalid Chromium versions, migrates persisted Chrome/1.x UAs, preserves valid behavior, and adds regression tests.
Out of Scope Changes check ✅ Passed All changes support [#12726], including UA validation, cookie-import handling, persisted-session cleanup, and regression coverage.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/browser/browser-cookie-import.ts (1)

828-845: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use path.join for application bundle paths.

These calls construct file paths with slash-delimited literals. Build each application path with path.join before passing it to readBrowserVersion.

As per coding guidelines, “Build file paths with path.join or Electron/Node path utilities; never assume / or \.”

Proposed change
+import { join } from 'node:path'
+
-      return chromeShapedUa(readBrowserVersion('/Applications/Google Chrome.app'))
+      return chromeShapedUa(readBrowserVersion(join('/Applications', 'Google Chrome.app')))

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7cdcfca8-9b55-4af0-a0fe-1c0921287dbe

📥 Commits

Reviewing files that changed from the base of the PR and between 79896cb and a1f18df.

📒 Files selected for processing (2)
  • src/main/browser/browser-cookie-import.arc-ua.test.ts
  • src/main/browser/browser-cookie-import.ts

Validate every numeric component before advertising Chrome/… so values
like 70.not-a-version fall back instead of polluting the UA. Also build
macOS app paths with path.join per coding guidelines.
@innocarpe

Copy link
Copy Markdown
Contributor Author

Follow-up for CodeRabbit: full numeric version-token validation + path.join for macOS app paths (see thread reply). Ready for re-review.

@Jinwoo-H Jinwoo-H self-assigned this Aug 6, 2026
The version gate stops new fork imports from writing Chrome/1.x, but profiles imported before it keep the broken UA in browser-session-meta.json and replay it on every launch, so affected users stay blocked with no in-app recovery.

Move the gate into browser-session-ua (the module that owns UA shape, and the one both callers can import without a cycle) and drop an unadvertisable persisted UA during restore so the profile falls back to Orca's own engine UA.

@Jinwoo-H Jinwoo-H left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks — the version gate is the right call, and rejecting malformed tokens like 70.not-a-version was a good catch.

One gap I pushed a follow-up commit for: the gate stops new fork imports from writing Chrome/1.x, but profiles imported before it keep the broken UA in browser-session-meta.json and replay it through session.setUserAgent() on every launch. Since the import path only acts if (ua), returning null for Arc leaves the stored value untouched — an affected user would install this, re-import, and still be blocked, with hand-editing JSON as the only recovery. That's ask #2 in the issue.

What I added:

  • Moved isAdvertisableChromiumEngineVersion into browser-session-ua.ts — it owns UA shape, and it's the only module both callers can import without a cycle (browser-cookie-import already imports the registry).
  • Added isUnadvertisableChromeUserAgent and dropped unadvertisable persisted UAs during session restore, so affected profiles self-heal on next launch and fall back to Orca's own engine UA. defaultSource is preserved, so Settings still shows the import.
  • Reverted the join('/Applications', …) change — no-op in a darwin-gated function that still concatenates /Contents/Info right after.

Verified in a real dev build against an isolated profile seeded with the exact broken meta from the issue (no Arc install needed):

  • Before: guest reports Chrome/1.158.1
  • After: Chrome/150.0.7871.47, meta healed to userAgent: null / userAgentByPartition: {}
  • No regression: a legitimate Edge 151 UA is still replayed and kept on disk
  • Accept path also exercised unmocked against a real installed bundle (Edge 151.0.4129.59)

All four new regression tests fail when the gate is neutered. src/main/browser 565/565, typecheck and lint clean.

Two things worth knowing post-merge: the >= 70 threshold is a hardcoded assumption with no alarm on it, and Brave/Helium were silently broken the same way, so they also stop being impersonated — an improvement, but a behavior change for users who never filed a bug.

@innocarpe

Copy link
Copy Markdown
Contributor Author

Thanks @Jinwoo-H — the restore-path self-heal for already-persisted Chrome/1.x (and peers) is the right completion of the gate. Your follow-up commit looks good to me: shared UA helper, drop unadvertisable stored UAs on session load while keeping defaultSource, and the regression coverage around Edge legit UA + Arc broken meta.

I'm good with landing this as-is; the >= 70 threshold / Brave+Helium impersonation stop are reasonable post-merge notes.

# Conflicts:
#	src/main/browser/browser-cookie-import.ts
#	src/main/browser/browser-session-registry.ts
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Jinwoo-H
Jinwoo-H merged commit 84e7ca5 into stablyai:main Aug 8, 2026
45 checks passed
brennanb2025 added a commit that referenced this pull request Aug 9, 2026
…port (STA-3514)

Delete the import-time UA synthesis entirely instead of patching its version
detection. The session now always keeps the engine-derived UA the registry
sets at startup (clean or native), for imported and non-imported profiles
alike.

Why deletion is the fix:
- The synthesis read CFBundleShortVersionString, which on forks is a
  marketing version — Arc imports presented Chrome/1.x and sites rejected
  the browser as ancient (STA-3514).
- Its stated purpose (keep Google-bound cookies valid) is handled by
  isGoogleSourceBoundCookie excluding those cookies since #736, and #12884
  measured that Google rejects re-transplants regardless of UA identity.
- #12608 measured the synthesized Chrome-shaped UA reaching
  /v3/signin/rejected while the engine UA reached account lookup.

Persisted userAgent/userAgentByPartition meta is no longer read; legacy keys
drop off on the next meta write. The #12811 gate existed only to catch bad
synthesized values, so it leaves with the synthesis.
brennanb2025 added a commit that referenced this pull request Aug 10, 2026
…port (STA-3514) (#12849)

* fix(browser): stop impersonating the source browser's UA on cookie import (STA-3514)

Delete the import-time UA synthesis entirely instead of patching its version
detection. The session now always keeps the engine-derived UA the registry
sets at startup (clean or native), for imported and non-imported profiles
alike.

Why deletion is the fix:
- The synthesis read CFBundleShortVersionString, which on forks is a
  marketing version — Arc imports presented Chrome/1.x and sites rejected
  the browser as ancient (STA-3514).
- Its stated purpose (keep Google-bound cookies valid) is handled by
  isGoogleSourceBoundCookie excluding those cookies since #736, and #12884
  measured that Google rejects re-transplants regardless of UA identity.
- #12608 measured the synthesized Chrome-shaped UA reaching
  /v3/signin/rejected while the engine UA reached account lookup.

Persisted userAgent/userAgentByPartition meta is no longer read; legacy keys
drop off on the next meta write. The #12811 gate existed only to catch bad
synthesized values, so it leaves with the synthesis.

* test(browser): catch source UA impersonation regression
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#12811)

* fix(browser): reject Chromium product versions in cookie-import UA

Do not persist Chrome/1.x User-Agents when a fork (e.g. Arc) reports its
product CFBundleShortVersionString. Only engine-scale majors (>=70) are
advertised; otherwise fall back to Electron's default UA.

Preserves Chrome-shaped UAs for real Chromium engine versions.

Fixes stablyai#12726

* fix(browser): reject malformed Chromium version tokens in UA

Validate every numeric component before advertising Chrome/… so values
like 70.not-a-version fall back instead of polluting the UA. Also build
macOS app paths with path.join per coding guidelines.

* fix(browser): drop already-persisted Chrome/1.x UAs on session restore

The version gate stops new fork imports from writing Chrome/1.x, but profiles imported before it keep the broken UA in browser-session-meta.json and replay it on every launch, so affected users stay blocked with no in-app recovery.

Move the gate into browser-session-ua (the module that owns UA shape, and the one both callers can import without a cycle) and drop an unadvertisable persisted UA during restore so the profile falls back to Orca's own engine UA.

---------

Co-authored-by: Jinwoo-H <Jinwoo-H@users.noreply.github.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…port (STA-3514) (stablyai#12849)

* fix(browser): stop impersonating the source browser's UA on cookie import (STA-3514)

Delete the import-time UA synthesis entirely instead of patching its version
detection. The session now always keeps the engine-derived UA the registry
sets at startup (clean or native), for imported and non-imported profiles
alike.

Why deletion is the fix:
- The synthesis read CFBundleShortVersionString, which on forks is a
  marketing version — Arc imports presented Chrome/1.x and sites rejected
  the browser as ancient (STA-3514).
- Its stated purpose (keep Google-bound cookies valid) is handled by
  isGoogleSourceBoundCookie excluding those cookies since stablyai#736, and stablyai#12884
  measured that Google rejects re-transplants regardless of UA identity.
- stablyai#12608 measured the synthesized Chrome-shaped UA reaching
  /v3/signin/rejected while the engine UA reached account lookup.

Persisted userAgent/userAgentByPartition meta is no longer read; legacy keys
drop off on the next meta write. The stablyai#12811 gate existed only to catch bad
synthesized values, so it leaves with the synthesis.

* test(browser): catch source UA impersonation regression
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: Arc cookie import persists User-Agent Chrome/1.x (product version) — sites mark browser incompatible

2 participants