Skip to content

feat: improve cookie import robustness and cross-platform support - #736

Merged
Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/cookie-improve
Apr 17, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/cookie-improve

Conversation

@Jinwoo-H

Copy link
Copy Markdown
Contributor

Summary

  • Fix logged-out-after-import bugs: copy WAL/SHM sidecars, probe Network/Cookies path (Chrome 96+), discover multi-profile setups from Local State JSON
  • Replace sqlite3 CLI with node:sqlite: eliminates text-parsing corruption, shell injection surface, and dependency on system sqlite3 binary
  • Add Firefox + Safari: Firefox reads plaintext moz_cookies table; Safari parses Cookies.binarycookies binary format with clear EPERM guidance for Full Disk Access
  • Add Windows + Linux: Windows uses DPAPI master key + AES-256-GCM; Linux uses GNOME secret-tool with peanuts fallback for v10 cookies
  • Skip Google integrity cookies (SIDCC, AEC, __Secure-*PSIDCC) that cause CookieMismatch when imported into a different browser
  • Handle bigint timestamps: Chromium expires_utc values exceed Number.MAX_SAFE_INTEGER; source DB opened with readBigInts: true

Test plan

  • Import cookies from Chrome/Edge on macOS — verify sites stay logged in
  • Import from a non-Default Chrome profile
  • Import from Firefox on macOS
  • Attempt Safari import — verify clear FDA permission error message
  • Verify 31 failed cookies are picked up after app restart (staging DB)
  • Smoke test on Windows (DPAPI path) and Linux (secret-tool path) if available

Fix logged-out-after-import bugs and expand browser/platform coverage:

- Copy WAL/SHM sidecars so fresh auth tokens aren't missed when the
  source browser is running
- Probe Network/Cookies path (Chrome 96+) with legacy fallback
- Discover multi-profile setups from Chrome's Local State JSON
- Replace sqlite3 CLI shell-outs with node:sqlite DatabaseSync
- Add Firefox support (plaintext SQLite, moz_cookies table)
- Add Safari support (binary cookie parser, EPERM guidance for FDA)
- Add Windows decryption (DPAPI master key + AES-256-GCM)
- Add Linux decryption (GNOME secret-tool / peanuts fallback)
- Platform-aware browser root paths (macOS/Windows/Linux)
- Skip Google integrity cookies (SIDCC, AEC, __Secure-*PSIDCC)
- Handle Chromium timestamps exceeding Number.MAX_SAFE_INTEGER
- Fix SameSite mapping: use chromiumSameSite() for Chromium DB, firefoxSameSite() for Firefox DB
- Sanitize browserProfile IPC param to prevent path traversal
- Strip cookiesPath/keychainService/keychainAccount from detectBrowsers response
- Remove cookie value context from diag log to prevent data leakage
- Fix replace() → replaceAll() for Linux keyring lookup
- Handle non-Uint8Array encrypted_value gracefully
- Clamp Safari binary cookie size to buf.length to prevent OOB reads
- Stop leaking error internals to renderer in failure messages
- Add Safari page bounds checks for pageCount and cookieCount
- Fix readCString to accept valid offset 0
@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/cookie-improve branch from 591469c to 98b3213 Compare April 17, 2026 03:24
@Jinwoo-H
Jinwoo-H merged commit 961f507 into main Apr 17, 2026
1 check 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
…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.

1 participant