Skip to content

feat(desktop): resolve Chromium cookie keys on Linux - #7261

Merged
juliusmarminge merged 18 commits into
browser-import-more-sourcesfrom
browser-import-linux-windows
Sep 3, 2026
Merged

feat(desktop): resolve Chromium cookie keys on Linux#7261
juliusmarminge merged 18 commits into
browser-import-more-sourcesfrom
browser-import-linux-windows

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Aug 16, 2026

Copy link
Copy Markdown
Member

Stacked on #7260 (browser-import-more-sources). Despite the retained branch name, this PR adds Linux support only; Windows Chromium is intentionally unsupported.

Chromium cookie key handling moves into a platform-specific module:

Platform Scheme Key source
macOS v10 AES-128-CBC Login Keychain, with consent
Linux v10 AES-128-CBC Chromium’s basic-storage peanuts passphrase
Linux v11 AES-128-CBC Secret Service via secret-tool, using the browser’s application attribute

Linux requires secret-tool and a compatible Secret Service backend to import v11 records. Missing keys/tools/backend can yield a partial v10 import; skipped records are reported. Explicit permission denial or cancellation stops the import. Secret bytes are preserved apart from the tool’s output line ending.

There is no DPAPI, PowerShell, App-Bound Encryption bypass, or direct KWallet implementation. macOS keeps the existing in-process consent path.

Validation: synthetic v10/v11 decryption fixtures, mocked Secret Service subprocess results, denied/missing backend behavior, and trailing-whitespace preservation. No live Linux keyring lookup was performed during this audit.

Original implementation: Claude Code. Review fixes: GPT-5.6 Sol agents, coordinated through Codex.

Note

Add Chromium cookie key resolution for Linux and Windows imports

  • Adds the ChromiumKeys module to resolve macOS, Linux, and Windows encryption keys, replacing hardcoded macOS-only keychain logic.
  • Introduces a native C helper bundled with the Linux desktop build to read Chromium secrets from libsecret.
  • Updates the ChromiumCookies value decoder to handle v10/v11 CBC, Windows v10 GCM, and legacy cleartext, preserving partial imports when some keys are missing.
  • Adds Windows support for the Helium browser source and cookie-database running-state detection.
  • Risk: The ChromiumCookieReadReason schema in ChromiumCookies.ts replaces macOS-specific failure literals with shared ChromiumKeyFailure reasons and removes unsupportedPlatform.

Macroscope summarized 0da299e.


Note

High Risk
Changes how cookie encryption keys are obtained (keychain, libsecret subprocess, DPAPI) and ships a native helper that reads browser secrets—security- and privacy-sensitive paths with partial-import edge cases.

Overview
Enables Chromium-family browser cookie import on Linux by resolving encryption keys per platform instead of treating non-macOS Chromium as unsupported.

Key handling moves into ChromiumKeys: macOS still uses the login keychain; Linux derives v10 keys from Chromium’s keyring-free passphrase, v11 from Secret Service via a bundled t3-browser-secret helper (native libsecret, exit codes for missing/denied/unavailable), plus an empty-passphrase retry for mis-encrypted records. ChromiumCookies decrypts mixed v10/v11 CBC schemes, allows partial imports when only some keys exist, and aligns legacy unprefixed values with Chromium on Linux.

The helper is compiled at dev/build (build-browser-secret.mjs), wired through LinuxBrowserSecret, shipped under resources/browser-secret on Linux artifacts, and CI/release install libsecret-1-dev / pkg-config. Browser source definitions gain linuxSecretApplication; Helium is listed on Linux (and Windows profile paths / running detection via held cookie DBs). Contracts and the import wizard add keychainUnavailable as a retryable failure.

The diff also includes Windows DPAPI key reading and Helium-on-Windows plumbing in the same modules; other Chromium forks on Windows remain excluded in source metadata.

Reviewed by Cursor Bugbot for commit 0da299e. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a0d1595-8e5e-4594-b3da-057657d6ef1a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Aug 16, 2026
@github-actions github-actions Bot added the size:L 100-499 changed lines (additions + deletions). label Aug 16, 2026
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumCookies.ts Outdated
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.4 KiB 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.3 KiB
Codex Live turn WebSocket wire 6.4 KiB 7.8 KiB
Codex Live turn WebSocket decoded 56.2 KiB 66.4 KiB
Codex Live turn messages 8 21
Claude Total thread wire 13.5 KiB 15.1 KiB
Claude Thread snapshot wire 7.0 KiB 7.3 KiB
Claude Live turn WebSocket wire 6.5 KiB 7.8 KiB
Claude Live turn WebSocket decoded 57.8 KiB 66.4 KiB
Claude Live turn messages 8 21

Baseline: unavailable · PR result: 0da299e · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.8 KiB
  • Claude decoded thread snapshot: 114.5 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@juliusmarminge
juliusmarminge force-pushed the browser-import-linux-windows branch from 1d228da to 6a2afea Compare August 16, 2026 22:08
@github-actions github-actions Bot added the 📱 Native Change Changes the native fingerprint; merging blocks production OTAs until a new store build ships. label Aug 16, 2026
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated

@macroscopeapp macroscopeapp 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.

Reviewed the new ChromiumKeys module and its call sites against the Effect service conventions. Imports, Effect.fn.Return requirement typing, and dependency acquisition (yield* FileSystem.FileSystem, ChildProcessSpawner surfaced in the requirement channel and threaded through BrowserImport's captured context) all look right. Two error-modelling issues in ChromiumKeys.ts: an underlying failure is discarded instead of being preserved as cause, and the Windows DPAPI path can turn a real failure into a silently empty key reported under a misleading reason.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
@juliusmarminge
juliusmarminge marked this pull request as ready for review August 16, 2026 22:18
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces a substantial cross-platform browser credential and cookie-import capability, including native keyring access and sensitive-data handling, rather than a small isolated change. An unresolved runtime concern about the bundled helper path, plus a universal-architecture build issue and newly added static-analysis suppressions, requires human review.

Not approved because:

  • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity

No code changes detected at 4bc257e. Prior analysis still applies.

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge
juliusmarminge force-pushed the browser-import-linux-windows branch from 6a2afea to 65f945a Compare August 16, 2026 22:53

@macroscopeapp macroscopeapp 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.

One finding: a typed ChromiumKeyError is re-wrapped at a translation boundary in ChromiumKeys.ts, losing its reason and nesting the error inside itself.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
@juliusmarminge
juliusmarminge force-pushed the browser-import-linux-windows branch from 65f945a to 0ad3689 Compare August 16, 2026 22:58
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
@juliusmarminge
juliusmarminge force-pushed the browser-import-linux-windows branch from 0ad3689 to 032f5da Compare August 16, 2026 23:10
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Aug 16, 2026

@macroscopeapp macroscopeapp 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.

Reviewed the new ChromiumKeys module and its call sites in ChromiumCookies/BrowserImport against the Effect service conventions. Two findings on error modelling in ChromiumKeys.ts; the layer/import/dependency-acquisition side looks fine (resolveChromiumKeys takes FileSystem/ChildProcessSpawner from the environment and scopes the child process locally).

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
@juliusmarminge
juliusmarminge force-pushed the browser-import-linux-windows branch from 032f5da to cfbd7b7 Compare August 16, 2026 23:14
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumCookies.ts Outdated
@juliusmarminge
juliusmarminge force-pushed the browser-import-linux-windows branch from cfbd7b7 to 5896abd Compare August 16, 2026 23:22
@juliusmarminge
juliusmarminge force-pushed the browser-import-linux-windows branch from 2eff79b to 268598a Compare August 29, 2026 07:53
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated

@macroscopeapp macroscopeapp 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.

One finding, on the new test file's diagnostic suppression. The rest of the change — the ChromiumKeys module layout, ChromiumKeyError structure with preserved cause, ChildProcessSpawner/HostProcessEnvironment acquired from the environment, requirements surfaced through Effect.fn.Return, and the now-uniform ChromiumKeyMaterial key shape with focused mixed v10/v11 coverage — matches the conventions.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.test.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumCookies.ts Outdated
Comment thread apps/desktop/src/preview/BrowserImport/BrowserImport.ts
Comment thread apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts Outdated
Comment thread scripts/build-desktop-artifact.ts
Comment thread apps/desktop/src/main.ts

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is ON, but a cloud agent failed to start.

Reviewed by Cursor Bugbot for commit a771eb6. Configure here.

Comment thread apps/desktop/src/preview/BrowserImport/Sources.ts
Comment thread scripts/build-desktop-artifact.ts
Comment thread native/browser-secret/main.c
Comment thread apps/desktop/src/main.ts
juliusmarminge and others added 18 commits September 3, 2026 23:21
macOS derives the OSCrypt key from a single keychain secret. Linux is looser: a
database can mix `v10` records (a hardcoded `peanuts` passphrase, used when no
keyring is present) and `v11` records (a libsecret/kwallet secret), so both keys
are derived up front and the record's prefix picks between them. A locked or
absent keyring is not fatal — those `v11` records are skipped and the rest still
import.

Key acquisition moves into its own `ChromiumKeys` module; `ChromiumCookies` now
decrypts each record by the scheme its prefix names and skips any it holds no
key for, so a partial result is reported honestly rather than failing the whole
import.

Windows is deliberately left out: since Chrome 127 its cookies are encrypted to
the browser's own identity (App-Bound Encryption) and cannot be read by another
process, so those forks are not offered there at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… key

Some Linux clients encrypted OSCrypt data with a key derived from an empty
passphrase (crbug.com/1195256). Chromium retries every failed v10/v11 record
with that key, so records it can still read were being skipped here. The key
material now carries the empty-passphrase key on Linux and the decryptor
retries with it when a record's own key fails — and only then, matching
Chromium: a record whose own key is missing entirely stays skipped.

Also drops an unexplained diagnostics suppression from ChromiumKeys.test.ts
that had nothing to suppress.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
An unprefixed cookie blob is legacy data stored in the clear, and Chromium's
OSCrypt returns it as-is on both macOS and Linux (os_crypt_mac.mm and
os_crypt_linux.cc alike: "old data saved as clear text"). The reader only
honoured that on macOS, so a Linux import counted those rows as undecryptable
and dropped otherwise readable cookies. The fallback now applies on Linux as
well; Windows stays excluded, since its app-bound blobs also lack the prefix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…x key

secret-tool matched on the application attribute alone, so any other
Secret Service item carrying application=chrome would supply the wrong
passphrase and every v11 cookie would be skipped as undecryptable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant