Repository navigation
fix(serve): report secrets unavailable instead of hanging on an unreachable macOS keychain - #27441
Conversation
…chable macOS keychain
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to Serve’s keychain timeout path is correctly guarded. The remaining test gap does not show a current secrets failure, but the ratchet should cover permitted import forms to protect future changes. Pre-merge checks |
|
…eychain, ratchet direct safeStorage imports
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/host/safe-storage-import-ratchet.test.ts (1)
24-26: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winMake the ratchet cover permitted Electron access forms.
The test claims that only two files may access
electron.safeStorage, but its regex matches only one named-import spelling.require('electron')is already used insrc/main, so arequire-basedsafeStorageaccess can bypass the ratchet. Namespace imports can bypass it as well. The quote-only fix handles only double-quoted named imports. Extend the check to all permitted access forms, preferably with an AST-based check.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4fe6d1ec-1024-4ceb-b4ab-2ca15a50d165
📒 Files selected for processing (6)
src/main/host/macos-keychain-reachability.test.tssrc/main/host/macos-keychain-reachability.tssrc/main/host/safe-storage-import-ratchet.test.tssrc/main/host/serve-keychain-guard.test.tssrc/main/host/serve-keychain-guard.tssrc/main/startup/main-process-ready-foundation.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
ELI5
On a Mac,
orca servecan be started where no one is logged into the desktop: over SSH, or by a LaunchAgent after a reboot. In that case, asking the macOS keychain for Orca's encryption key can wait forever on a password prompt that nobody can see. Orca asked inline before it reported ready, so the server never came up. Now Orca first asks the keychain from a separate, short-lived process that is killed after 5 seconds. If the keychain cannot answer, Orca says secrets are unavailable for this run and starts anyway.What Changed
orca serveon macOS calledsafeStorageon the main thread before readiness. With no default keychain (a freshHOME, [Bug]:orca servehangs at startup on macOS when HOME is a fresh directory, so mobilestart:emulatorcannot pair #25453) or a keychain that needs a prompt, that call blocked forever, and the server never printed its ready line. The same call could also freeze a running server the first time any feature read a stored credential./usr/bin/security show-keychain-infoin a child process with a 5 s kill.safeStoragecall goes throughguardedSafeStorageand reports "unavailable" instead of blocking.securityis missing or prints something unexpected. Today's behavior is kept.Mechanism: the six modules that imported
electron.safeStorage(the secret store, cloud session, zcode, minimax, plugin secrets and API-key file stores) now importguardedSafeStoragefromsrc/main/host/safe-storage-availability.ts. It is a pass-through until something withholds the keychain.Why
Owner decision D1 Q10: the Electron fallback for
orca serveis chosen automatically for every profile with SSH targets, so a headless Mac without a GUI session is a normal case.safeStorageis synchronous, and a timer in the same process cannot interrupt it. The probe runs in a child that can be killed.show-keychain-info: it reads keychain settings, never a secret, so it cannot raise the prompt it is checking for. It is the same pattern as the existing Linux secret-service probe.Linked Issue
Fixes #25453 (a fresh
HOMEhas no default keychain, so serve now starts and reports secrets unavailable). #25517 still applies its isolated-profile switches for E2E profiles.Visual Proof
N/A: headless startup only. The visible change is that
orca servereaches its ready line within about 5 s, with a[secrets] Secrets are unavailable for this run: …log line, where before it hung.Testing
macos-keychain-reachability.test.ts: covers eachsecurityoutcome.HOME: exit 37) is unavailable.safe-storage-availability.test.ts: covers the following.secrets_unavailable.serve-keychain-guard.test.ts: covers the following.orcad-secret-protection-gap.test.ts: the per-platform wording.pnpm tc,pnpm lintandpnpm run check:code-quality:changedpass.Review
Agent skill upstream boundary
Notes
safeStorageafter the probe says the keychain is reachable. Examples: a login keychain whose settingssecuritycan read without a prompt, or an "Orca Safe Storage" item whose access list no longer matches the app's signature. The probe never reads the item, because reading it is exactly what could prompt. The 5 s timeout catches asecuritythat itself waits.securitymissing) keeps today's inline behavior.--use-mock-keychain(E2E and isolated sidecars), because a mock keychain never prompts.electron.safeStoragedirectly.Checklist
N/Afor visuals with reasonpnpm lint,pnpm typecheck, and focused tests pass locally; CI covers the rest