-
Notifications
You must be signed in to change notification settings - Fork 5.3k
feat(desktop): resolve Chromium cookie keys on Linux #7261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliusmarminge
merged 18 commits into
browser-import-more-sources
from
browser-import-linux-windows
Sep 3, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6df3337
feat(desktop): resolve Chromium cookie keys on Linux
juliusmarminge 99abc41
fix(desktop): read Linux Chromium secrets from libsecret
juliusmarminge a9599d2
fix(desktop): preserve Linux Chromium secret whitespace
juliusmarminge 5b71d0a
fix(desktop): preserve Linux keyring denial
juliusmarminge cfe9f55
fix(desktop): preserve Chromium cookie formats
juliusmarminge 5f6dc48
refactor(desktop): require Chromium key material
juliusmarminge 260103a
fix(desktop): drain secret tool output concurrently
juliusmarminge 62654c1
test(desktop): cover mixed Chromium Linux keys
juliusmarminge 039e6b2
style(desktop): format Chromium key reader
juliusmarminge 85d0aa8
fix(desktop): stabilize secret tool errors
juliusmarminge 6124d03
refactor(desktop): inject secret tool environment
juliusmarminge 08b41dc
fix(desktop): recover Linux cookies written with the empty-passphrase…
juliusmarminge 6a4f2a1
fix(desktop): read legacy cleartext Chromium cookies on Linux too
juliusmarminge 1446db0
fix(desktop): match Chromium's libsecret schema when reading the Linu…
juliusmarminge 262c9c3
fix(desktop): enable Helium browser import on Linux
juliusmarminge 7e4788b
fix(desktop): bundle the Linux browser keyring reader
juliusmarminge 756d99d
feat(desktop): import Helium cookies on Windows
juliusmarminge 0da299e
fix(desktop): detect running Helium on Windows
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import * as NodeChildProcess from "node:child_process"; | ||
| import * as NodeFS from "node:fs"; | ||
| import * as NodeOS from "node:os"; | ||
| import * as NodePath from "node:path"; | ||
| import * as NodeURL from "node:url"; | ||
| import { afterAll, beforeAll, describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| // oxlint-disable-next-line t3code/no-global-process-runtime -- The native compiler targets the actual host; this script has no Effect runtime. | ||
| const hostArch = process.arch; | ||
| // oxlint-disable-next-line t3code/no-global-process-runtime -- Native compilation only runs on the actual Linux host. | ||
| const hostPlatform = process.platform; | ||
|
|
||
| describe.skipIf(hostPlatform !== "linux")("bundled libsecret helper", () => { | ||
| let directory; | ||
| let executable; | ||
| beforeAll(() => { | ||
| directory = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-browser-secret-test-")); | ||
| executable = NodePath.join(directory, "t3-browser-secret"); | ||
| const root = NodeURL.fileURLToPath(new URL("../../../native/browser-secret/", import.meta.url)); | ||
| const flags = NodeChildProcess.execFileSync( | ||
| "pkg-config", | ||
| ["--cflags", "--libs", "libsecret-1"], | ||
| { | ||
| encoding: "utf8", | ||
| }, | ||
| ) | ||
| .trim() | ||
| .split(/\s+/); | ||
| NodeChildProcess.execFileSync( | ||
| process.env.CC || "cc", | ||
| [ | ||
| "-std=c11", | ||
| "-Wall", | ||
| "-Wextra", | ||
| "-Werror", | ||
| NodePath.join(root, "main.c"), | ||
| NodePath.join(root, "test.c"), | ||
| "-Wl,--wrap=secret_service_search_sync", | ||
| "-Wl,--wrap=secret_item_get_locked", | ||
| "-Wl,--wrap=secret_item_get_secret", | ||
| "-o", | ||
| executable, | ||
| ...flags, | ||
| ], | ||
| { stdio: "pipe" }, | ||
| ); | ||
| }); | ||
| afterAll(() => { | ||
| if (directory) NodeFS.rmSync(directory, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| const run = (args) => | ||
| NodeChildProcess.spawnSync(executable, args, { | ||
| env: { ...process.env, DBUS_SESSION_BUS_ADDRESS: "unix:path=/unused-test-bus" }, | ||
| }); | ||
|
|
||
| it("builds an executable for the requested architecture into a staged resource directory", () => { | ||
| const output = NodePath.join(directory, "resources", "browser-secret", "t3-browser-secret"); | ||
| NodeChildProcess.execFileSync(process.execPath, [ | ||
| NodeURL.fileURLToPath(new URL("./build-browser-secret.mjs", import.meta.url)), | ||
| "--arch", | ||
| hostArch, | ||
| "--output", | ||
| output, | ||
| ]); | ||
| const header = NodeFS.readFileSync(output).subarray(0, 20); | ||
| expect(header.toString("hex", 0, 6)).toBe("7f454c460201"); | ||
| expect(header.readUInt16LE(18)).toBe({ x64: 62, arm64: 183 }[hostArch]); | ||
| expect(NodeFS.statSync(output).mode & 0o111).not.toBe(0); | ||
| // Invalid arguments exit before the real executable could contact a keyring. | ||
| expect(NodeChildProcess.spawnSync(output, []).status).toBe(64); | ||
| }); | ||
|
|
||
| it("preserves the exact secret bytes with no added or removed delimiter", () => { | ||
| const result = run(["success"]); | ||
| expect(result.status).toBe(0); | ||
| expect(result.stdout).toEqual(Buffer.from("secret\0with whitespace \t\r\n")); | ||
| expect(result.stderr.length).toBe(0); | ||
| }); | ||
|
|
||
| for (const [scenario, code] of [ | ||
| ["missing", 2], | ||
| ["empty", 2], | ||
| ["locked", 3], | ||
| ["cancelled", 3], | ||
| ["denied", 3], | ||
| ["unavailable", 4], | ||
| ["unloaded", 4], | ||
| ]) { | ||
| it(`reports ${scenario} without emitting a secret`, () => { | ||
| const result = run([scenario]); | ||
| expect(result.status).toBe(code); | ||
| expect(result.stdout.length).toBe(0); | ||
| }); | ||
| } | ||
| it("rejects invalid arguments before accessing the keyring", () => { | ||
| for (const args of [[], [""], ["chrome", "extra"]]) { | ||
| const result = run(args); | ||
| expect(result.status).toBe(64); | ||
| expect(result.stdout.length).toBe(0); | ||
| } | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import * as NodeChildProcess from "node:child_process"; | ||
| import * as NodeFS from "node:fs"; | ||
| import * as NodePath from "node:path"; | ||
| import * as NodeURL from "node:url"; | ||
| import * as NodeUtil from "node:util"; | ||
|
|
||
| // oxlint-disable-next-line t3code/no-global-process-runtime -- The native compiler targets the actual host; this script has no Effect runtime. | ||
| const hostArch = process.arch; | ||
| // oxlint-disable-next-line t3code/no-global-process-runtime -- Native compilation only runs on the actual Linux host. | ||
| const hostPlatform = process.platform; | ||
|
|
||
| const { values } = NodeUtil.parseArgs({ | ||
| options: { output: { type: "string" }, arch: { type: "string", default: hostArch } }, | ||
| }); | ||
|
|
||
| if (hostPlatform === "linux") { | ||
| const machine = { x64: 62, arm64: 183 }[values.arch]; | ||
| if (machine === undefined) throw new Error(`Unsupported Linux architecture: ${values.arch}`); | ||
| const root = NodeURL.fileURLToPath(new URL("../../../native/browser-secret/", import.meta.url)); | ||
| const source = NodePath.resolve(root, "main.c"); | ||
| const output = values.output ?? NodePath.resolve(root, "build", values.arch, "t3-browser-secret"); | ||
| const matchesArchitecture = (file) => { | ||
| const header = NodeFS.readFileSync(file).subarray(0, 20); | ||
| return header.toString("hex", 0, 6) === "7f454c460201" && header.readUInt16LE(18) === machine; | ||
| }; | ||
| let current = false; | ||
| try { | ||
| current = | ||
| NodeFS.statSync(output).mtimeMs >= | ||
| Math.max( | ||
| NodeFS.statSync(source).mtimeMs, | ||
| NodeFS.statSync(NodeURL.fileURLToPath(import.meta.url)).mtimeMs, | ||
| ) && matchesArchitecture(output); | ||
| } catch { | ||
| /* The first build has no output yet. */ | ||
| } | ||
| if (!current) { | ||
| let flags; | ||
| try { | ||
| flags = NodeChildProcess.execFileSync("pkg-config", ["--cflags", "--libs", "libsecret-1"], { | ||
| encoding: "utf8", | ||
| }) | ||
| .trim() | ||
| .split(/\s+/); | ||
| } catch (cause) { | ||
| throw new Error( | ||
| "Building the Linux browser import helper requires pkg-config and libsecret development headers (Ubuntu/Debian: libsecret-1-dev).", | ||
| { cause }, | ||
| ); | ||
| } | ||
| NodeFS.mkdirSync(NodePath.dirname(output), { recursive: true }); | ||
| const temporary = `${output}.${process.pid}.tmp`; | ||
| try { | ||
| NodeChildProcess.execFileSync( | ||
| process.env.CC || "cc", | ||
| ["-std=c11", "-O2", "-Wall", "-Wextra", "-Werror", source, "-o", temporary, ...flags], | ||
| { stdio: "inherit" }, | ||
| ); | ||
| if (!matchesArchitecture(temporary)) | ||
| throw new Error(`C compiler did not produce a Linux ${values.arch} executable.`); | ||
| NodeFS.renameSync(temporary, output); | ||
| } finally { | ||
| NodeFS.rmSync(temporary, { force: true }); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.