Repository navigation
fix(browser): reject Chromium product versions in cookie-import UA - #12811
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe change adds Chromium engine-version validation for numeric major versions of at least 70. Chromium-based browser user-agent generation now uses the shared 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/browser/browser-cookie-import.ts (1)
828-845: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
path.joinfor application bundle paths.These calls construct file paths with slash-delimited literals. Build each application path with
path.joinbefore passing it toreadBrowserVersion.As per coding guidelines, “Build file paths with
path.joinor 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
📒 Files selected for processing (2)
src/main/browser/browser-cookie-import.arc-ua.test.tssrc/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.
|
Follow-up for CodeRabbit: full numeric version-token validation + path.join for macOS app paths (see thread reply). Ready for re-review. |
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
left a comment
There was a problem hiding this comment.
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
isAdvertisableChromiumEngineVersionintobrowser-session-ua.ts— it owns UA shape, and it's the only module both callers can import without a cycle (browser-cookie-importalready imports the registry). - Added
isUnadvertisableChromeUserAgentand dropped unadvertisable persisted UAs during session restore, so affected profiles self-heal on next launch and fall back to Orca's own engine UA.defaultSourceis preserved, so Settings still shows the import. - Reverted the
join('/Applications', …)change — no-op in a darwin-gated function that still concatenates/Contents/Inforight 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 touserAgent: 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.
|
Thanks @Jinwoo-H — the restore-path self-heal for already-persisted I'm good with landing this as-is; the |
# Conflicts: # src/main/browser/browser-cookie-import.ts # src/main/browser/browser-session-registry.ts
|
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. |
…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.
…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
…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>
…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
Description
Stop persisting broken
Chrome/1.xUser-Agents when importing cookies from Chromium forks (e.g. Arc) that report a productCFBundleShortVersionString.Only engine-scale majors (>= 70) are advertised; otherwise import falls back to Electron's default UA.
Focused fix
isAdvertisableChromiumEngineVersiongate ingetUserAgentForBrowserPreserves
Evidence
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
Fixes #12726