Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(spaces-desktop): keep Chromium out of the macOS keychain so its prompt can't freeze the app (#5209)

ddupont70594e84ca16
diff --git a/apps/cua-spaces-desktop/src/chromium-keychain.ts b/apps/cua-spaces-desktop/src/chromium-keychain.ts
new file mode 100644
index 0000000000..440c3b6c8f
--- /dev/null
+++ b/apps/cua-spaces-desktop/src/chromium-keychain.ts
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+// macOS: Chromium keeps its own key for encrypting cookies in the login
+// keychain ("Cua Spaces Safe Storage"). A build whose code signature the
+// item's access list doesn't name (in practice every update) makes macOS ask
+// for the login keychain password. While that prompt is up, Security holds
+// its process-wide lock, so the app's own keychain reads on the main thread
+// (auth status) wait behind it and the whole app stops responding until the
+// prompt is answered.
+//
+// The app keeps nothing secret in Chromium's storage: sign-in and Keyvault
+// secrets live in the cua keychain items, read by the Rust core, and the
+// pages only store the theme, the checklist and onboarding progress (in
+// localStorage, which Chromium never encrypts anyway). So Chromium gets a
+// fixed key instead (`--use-mock-keychain`) and never touches the keychain.
+// No Electron here.
+
+/** The command-line switches that keep Chromium out of the keychain on `platform`. */
+export function chromiumKeychainSwitches(platform: NodeJS.Platform): string[] {
+ return platform === "darwin" ? ["use-mock-keychain"] : [];
+}
+
+/** Applies them to Electron's command line (before the app is ready). */
+export function applyChromiumKeychainSwitches(commandLine: { appendSwitch(name: string): void }, platform: NodeJS.Platform): void {
+ for (const name of chromiumKeychainSwitches(platform)) commandLine.appendSwitch(name);
+}
diff --git a/apps/cua-spaces-desktop/src/main.ts b/apps/cua-spaces-desktop/src/main.ts
index 6115eb7b48..bfc4e0ff63 100644
--- a/apps/cua-spaces-desktop/src/main.ts
+++ b/apps/cua-spaces-desktop/src/main.ts
@@ -10,6 +10,7 @@ import { createBridge } from "./bridge";
import { hasBrowser } from "./browser";
import { appBuild } from "./bundle-version";
import { ELECTRON_EVENT_CHANNEL } from "./channels";
+import { applyChromiumKeychainSwitches } from "./chromium-keychain";
import { installGlobalShortcut, type GlobalShortcut } from "./global-shortcut";
import { applyVideoDecodeSwitches } from "./gpu";
import { menuItems, realSpaces, startHost } from "./bridge/host-start";
@@ -59,6 +60,8 @@ if (process.platform === "linux") {
if (process.env.CUA_SPACES_USER_DATA) app.setPath("userData", process.env.CUA_SPACES_USER_DATA);
// The page decodes Spaces' video with WebCodecs: on the GPU where it can (gpu.ts).
applyVideoDecodeSwitches(app.commandLine, process.platform, process.env);
+// macOS: Chromium's cookie key stays out of the keychain, so its prompt can't freeze the app (chromium-keychain.ts).
+applyChromiumKeychainSwitches(app.commandLine, process.platform);
const VIDEO_BENCH = videoBenchEnv(process.env);
// The Spaces' viewer windows ("Open in window"); the bench's own placement is never remembered.
const viewers = createViewerWindows({ remember: !VIDEO_BENCH.bench });
diff --git a/apps/cua-spaces-desktop/test/chromium-keychain.test.ts b/apps/cua-spaces-desktop/test/chromium-keychain.test.ts
new file mode 100644
index 0000000000..e2833d33ee
--- /dev/null
+++ b/apps/cua-spaces-desktop/test/chromium-keychain.test.ts
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+import { describe, expect, it } from "vitest";
+import { applyChromiumKeychainSwitches, chromiumKeychainSwitches } from "../src/chromium-keychain";
+
+describe("chromiumKeychainSwitches", () => {
+ it("keeps Chromium out of the macOS keychain", () => {
+ expect(chromiumKeychainSwitches("darwin")).toEqual(["use-mock-keychain"]);
+ });
+
+ it("changes nothing elsewhere", () => {
+ expect(chromiumKeychainSwitches("win32")).toEqual([]);
+ expect(chromiumKeychainSwitches("linux")).toEqual([]);
+ });
+
+ it("appends the switches to the command line", () => {
+ const added: string[] = [];
+ applyChromiumKeychainSwitches({ appendSwitch: (name) => added.push(name) }, "darwin");
+ expect(added).toEqual(["use-mock-keychain"]);
+ });
+});