Repository navigation
Secure desktop local credential surfaces - #9108
Conversation
There was a problem hiding this comment.
6 issues found across 10 files
Confidence score: 2/5
- In
desktop/macos/Desktop/Sources/DesktopKeychainStore.swift, Keychain queries use an accessibility class but do not opt into the macOS data-protection keychain, so token save/load/delete can fail and break the new secure-token path at runtime — add the data-protection keychain flag consistently on add/read/delete queries and re-test token lifecycle flows before merging. - In
desktop/macos/Desktop/Sources/AuthService.swift(storedTokens()), the migration failure early-return can leave legacy Firebase tokens inUserDefaults, creating a plaintext-token security regression even when secure migration fails — ensure legacy keys are removed (or explicitly quarantined/rolled back) on all failure paths before merge. - In
desktop/macos/Desktop/Sources/LocalAgentAPIServer.swift(enable()), returning""on Keychain failure lets provisioning continue silently, which can produce blank/invalid local-agent tokens and confusing setup prompts — propagate a typed error and stop the flow when token generation fails. - Lower-severity robustness issues remain in
desktop/macos/Desktop/Sources/AuthService.swift(repeatedstoredTokens()reads),desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift(case-sensitiveBearerparsing), anddesktop/macos/scripts/spatial-overlay-harness.sh(token-file read outside error handling); these are likely non-blocking but should be cleaned up to reduce avoidable auth failures and support noise.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50ec8990bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@cursor address review comments |
|
All six cubic/Codex review items are addressed in commit Fixes applied
Note: On Keychain migration failure, auth tokens are cleared rather than left in plaintext — users would need to sign in again if secure storage is unavailable. That matches the fail-closed security posture from the review. |
… local agent setup - Opt into kSecUseDataProtectionKeychain on all DesktopKeychainStore queries - Clear legacy UserDefaults auth tokens when Keychain migration fails - Cache decoded StoredAuthTokens to avoid redundant Keychain reads per call chain - Throw LocalAgentAPIError.tokenStorageUnavailable instead of returning blank tokens - Parse Bearer authorization case-insensitively in automation bridge - Handle OSError when reading automation token file in spatial overlay harness - Extend FailLoudConfigTests for new security behaviors Co-authored-by: David Zhang <[email protected]>
c137f54 to
ae3a1b9
Compare
|
Monitor summary for this run. Thread #PRRT_kwDOLkKqys6OdbdJ (P2, Verification (commit
Note: No new trusted review comments since the push. |
|
Reviewed the remaining local-agent token storage feedback after the latest push. Changed in the current PR head:
Verification passed:
|
|
@cursor resolve merge conflicts |
|
Merge conflicts are resolved and pushed in commit What conflicted
StatusBranch |
Resolve DesktopAutomationBridge import conflict: keep CryptoKit from main alongside automation bridge bearer-token auth fixes.
…(Could not securely store sign-in tokens) (#9167) ## Problem On the signed/notarized **beta**, sign-in fails with **"Could not securely store sign-in tokens. Please try again."** — you cannot log in (screenshot from v0.12.37). ## Root cause `DesktopKeychainStore` opted into the **data-protection keychain** (`kSecUseDataProtectionKeychain: true`), which on macOS requires a `keychain-access-groups` entitlement. This app is a **non-sandboxed Developer ID** app with **no** such entitlement (`Omi-Release.entitlements`: `app-sandbox=false`, no keychain-access-groups). So on the signed build every `SecItemAdd`/`SecItemUpdate` returned **`errSecMissingEntitlement` (-34018)** → `saveTokens()` threw `keychainTokenStorageUnavailable` → sign-in blocked. Dev/named builds use UserDefaults (`usesKeychainTokenStorage = !AppBuild.isNonProduction`), which is why it only failed on prod/beta and slipped through CI. ## Fix Drop `kSecUseDataProtectionKeychain` so the store uses the default **file-based (login) keychain** — a signed non-sandboxed app can read/write its own generic-password items there **without any keychain entitlement**, and tokens still stay out of UserDefaults. (`ClientDeviceService` already uses this exact pattern in the same app.) This **complements #9162's** UserDefaults fallback: with the keychain actually succeeding, the fallback becomes a rare safety net instead of the norm. - `DesktopKeychainStore.swift`: remove the data-protection flag from the shared query. - `AuthTokenStorageTests.swift`: source-guard against re-introducing the data-protection keychain (this regression is invisible to dev/CI since dev uses UserDefaults). - `FailLoudConfigTests.swift`: remove the now-inverted `testDesktopKeychainStoreUsesDataProtectionKeychain` (its correct invariant now lives in the new guard). - changelog. ## Verification - **Runtime**: signed into a **local named bundle** with the keychain path forced on **and the UserDefaults fallback disabled**, so the outcome reflects the *real* keychain write — sign-in succeeded. - **Standalone `SecItemAdd` probe**: data-protection keychain → `-34018`; file-based → `0`. - Build exit 0; `AuthTokenStorageTests` 5/5, `FailLoudConfigTests` 6/6. - **Independent review**: confirmed the file-based login keychain is an adequately secure store for a non-sandboxed Developer ID app (AES-encrypted at rest under the login key + per-item code-signature ACL — a big step up from UserDefaults, and #9108's goal is still met), and that no migration is needed (no signed build ever wrote a data-protection item). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9167?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->


Summary
idToken,refreshToken, expiry, token owner) into Keychain with one-time migration from legacyUserDefaults, while keeping non-productionUserDefaultstoken storage for the existing dev auth seed workflow.omi-ctl/harness scripts to read the per-launch token file.Root cause
Issue #8843 identified three local credential/control weaknesses: shipped builds could persist Firebase bearer credentials in a plaintext plist, the local-agent API token was also stored in preferences, and the automation bridge could be force-enabled without auth on the production bundle.
Oracle
Consulted the Tailnet Oracle before implementation. It recommended a secure-by-default Keychain path for all non-dev bundles, preserving dev
UserDefaultsseeding only for non-production bundles, moving local-agent tokens to Keychain without plaintext fallback, and making the automation bridge production-disabled plus token-authenticated. This PR follows those prescriptions.Validation
xcrun swift build -c debug --package-path Desktopxcrun swift test --package-path Desktop --filter FailLoudConfigTestsbash -n desktop/macos/scripts/omi-ctl desktop/macos/scripts/omi-auth-seed.sh desktop/macos/scripts/spatial-overlay-harness.shpython3 -m py_compile desktop/macos/scripts/omi-harnessRuntime dogfood note: attempted a named bundle launch with
OMI_APP_NAME=omi-security-8843 OMI_ALLOW_ADHOC_SIGN=1 OMI_SKIP_BACKEND=1 OMI_AUTOMATION_PORT=47843 ./run.sh --yolo; launch was blocked before app startup by local ad-hoc signing/dyld rejection of the Sparkle framework, so bridge curl checks could not run in this environment.Fixes #8843