Skip to content

[desktop/macos] Security: auth tokens in UserDefaults + unauthenticated automation bridge #8843

Closed

Description

@Git-on-my-level

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

  1. Store idToken/refreshToken in 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 keeps scripts/omi-auth-dump.sh / omi-auth-seed.sh working for dev).
  2. Move the local-agent token to Keychain, or scope-limit what it can do.
  3. Make the bridge's isEnabled require AppBuild.isNonProduction unconditionally (flag/env can only disable or configure, never enable on prod), and require a per-launch token like LocalAgentAPIServer does.

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

  1. added
    bug
    on Jul 2, 2026
  2. added
    memory
    p2
    on Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Securitybugmemoryp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions