Repository navigation
Description
Area: Security / credential storage
Problem
Three related weaknesses in how the desktop app handles credentials and local control surfaces:
1. Firebase tokens persisted to UserDefaults on every build, including prod.
Desktop/Sources/AuthService.swift:1598-1606 (saveTokens) writes idToken and refreshToken to UserDefaults.standard unconditionally. The section is commented "UserDefaults keys for auth persistence (dev builds with ad-hoc signing)" (AuthService.swift:355) but there is no build/bundle gate — production users' long-lived refresh tokens sit in a plaintext plist readable by any same-user process and included in unencrypted backups.
2. Local agent API token also in UserDefaults.
Desktop/Sources/LocalAgentAPIServer.swift:8-12 — the code itself acknowledges: "token is still readable by same-user processes; use Keychain if this scope [grows]".
3. DesktopAutomationBridge has no auth and can be enabled on the production bundle.
Desktop/Sources/DesktopAutomationBridge.swift:11-22 — the comment says the listener "is never enabled on the production bundle", but isEnabled returns true if --automation-bridge or OMI_ENABLE_LOCAL_AUTOMATION=1 is present regardless of bundle; only the auto-enable path checks AppBuild.isNonProduction. The bridge binds loopback but, unlike LocalAgentAPIServer, requires no token, and its actions include fetching the user's live auth header and calling authenticated APIs (DesktopAutomationBridge.swift:373-381) plus exporting memory data. Any local process can drive it.
Suggested fix
- Store
idToken/refreshTokenin Keychain when the bundle is production/beta (AppBuild.isProductionBundle); keep the UserDefaults path only for dev/ad-hoc bundles where Keychain doesn't persist (this also keepsscripts/omi-auth-dump.sh/omi-auth-seed.shworking for dev). - Move the local-agent token to Keychain, or scope-limit what it can do.
- Make the bridge's
isEnabledrequireAppBuild.isNonProductionunconditionally (flag/env can only disable or configure, never enable on prod), and require a per-launch token likeLocalAgentAPIServerdoes.
Open questions
- Do the auth seed scripts (
scripts/omi-auth-*.sh) need updating in the same PR? (They read/write the UserDefaults keys and are load-bearing for the named-bundle test workflow.)
Activity
Secure desktop local credential surfaces (#9108)