Repository navigation
feat(antigravity): read native macOS credentials safely - #21784
Conversation
|
Independent verification (2026-09-20):
Verdict: approve scoped to native macOS account storage/switching. Windows/Linux native backends and remote account scopes remain unverified; #21797 and #21798 should remain stacked above it. No merge performed. |
ELI5 / evidence / trade-offs auditELI5: Orca can recognize an existing Antigravity account on this Mac instead of making the user set it up again. Proof: Native macOS credential/account tests and CI pass; visual proof is covered by the dependent detected-account UI work. User-facing trade-off: macOS-only behavior; secure credential availability still depends on the host keychain. This note scopes the claim to the evidence above; it does not claim untested remote, SSH, WSL, or vendor combinations. |
There was a problem hiding this comment.
Important
The account-switch path mutates the live macOS Keychain item before verifying and never rolls back, and the Antigravity section renders on platforms whose IPC handlers do not exist. Both have concrete user-visible fallout — details inline.
Reviewed changes
- Keychain read/write for agy —
native-macos-credentials.tsreads thegemini/antigravitygeneric password via/usr/bin/security, distinguishes not-found from denied/timeout/truncated reads, and writes throughsecurity -istdin with a 4096-byte guard plus readback verification. - Bounded credential codec —
native-credential-codec.tsdecodes go-keyringbase64/hex/plain wrappers, validates the agy JSON shape, and exposes only verified Google identity claims while preserving the exact native blob. All errors are fixed and secret-free. - Encrypted multi-account vault and switching —
native-account-service.tsadds/list/selects/removes accounts keyed bysha256(contents), derives the active account from the live credential, and refuses plaintext fallback in the store. - Desktop IPC, preload, and renderer surface — handlers registered only on darwin, preload bridges, a web stub, and an
AntigravityAccountsSectionwired intoAccountsPanewith native quota display.
ℹ️ Nitpicks
selectAccount's readback atnative-account-service.ts:97repeats the verification already performed insidewriteAntigravityMacOSCredential, so it can only add a failure window, not strengthen the guarantee.native-macos-credentials.ts:57caps writes at 4096 bytes while the codec accepts reads up to 64 KB, so a large credential could be stored by "Add current" but never selected.- The
AntigravityAccountStateshape is declared both insrc/preload/api/agent-account-api.tsandnative-account-service.ts; the two can drift. - The IPC
select/removehandlers destructureargs.accountIdwithout checkingargsis an object, so a malformed call surfaces aTypeErrorrather than a domain error.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| await this.credentialBackend.write(selected.credentials) | ||
| const readback = await this.credentialBackend.read() | ||
| if (readback?.contents !== selected.credentials) { | ||
| throw new Error('Antigravity account switching could not be verified.') | ||
| } | ||
| this.activeAccountId = id | ||
| return { accounts: accounts.map(summary), activeAccountId: id } |
There was a problem hiding this comment.
The live Keychain item is replaced before verification and never restored, so any throw after this write (timeout, readback mismatch, transient security failure) leaves the native agy login changed while activeAccountId still points at the previous account. removeAccount at line 110 then trusts that stale field, so the user can delete the record for the account that is actually live — after which knownActiveAccount cannot match it and the vault reports no active account.
Technical details
# Account switch is not transactional; removal guard trusts stale in-memory state
## Affected sites
- `src/main/antigravity/native-account-service.ts:96` — writes the selected credential into the live Keychain before any re-verification.
- `src/main/antigravity/native-account-service.ts:97-100` — verification after the mutation; a throw skips `activeAccountId = id` with no restore.
- `src/main/antigravity/native-macos-credentials.ts:61-66` — `security -i` may have already applied the update when it throws, and the non-zero/timed-out branch does not read back at all.
- `src/main/antigravity/native-account-service.ts:110` — `removeAccount` compares against the in-memory `activeAccountId` instead of the live credential the way `listAccounts:117-123` does.
- `src/renderer/src/components/settings/AntigravityAccountsSection.tsx:35-43` — a failed `select` only toasts; the displayed active account is not refreshed, so `Remove` stays offered for the account that is now live.
## Required outcome
- After any throw following the Keychain mutation, the service's reported active account and the live credential must not disagree, and a removal must not be able to delete the record whose bytes are currently live.
## Suggested approach (optional)
- Capture the prior `contents` before `write` and restore it when post-write verification fails, or
- derive the removal/active guard from a fresh `credentialBackend.read()` comparison rather than the cached `activeAccountId`, and
- drop the redundant service-level readback now that `writeAntigravityMacOSCredential` already verifies.| } | ||
|
|
||
| function accountId(contents: string): string { | ||
| return `antigravity-${createHash('sha256').update(contents).digest('hex').slice(0, 16)}` |
There was a problem hiding this comment.
Because the id is sha256 of the entire native blob, a routine agy access-token refresh rewrites contents, changing the id. knownActiveAccount (line 122) then no longer recognizes the account that is still signed in, listAccounts reports activeAccountId: null, and addCurrentAccount stores a second entry for the same Google identity. Is byte-exact identity intentional, or should the account be keyed off the stable Google sub so a refresh is recognized as the same account?
| !isRemoteAccountScope ? ( | ||
| <AntigravityAccountsSection key="antigravity" quota={antigravityRateLimits} /> | ||
| ) : null, |
There was a problem hiding this comment.
This section renders on every desktop platform and in the web client, but the antigravityAccounts IPC handlers are only registered when state.antigravityAccounts exists, which is macOS-only. On Windows, Linux, and web the list() rejection is swallowed and the Add/Use/Remove buttons always error. It also bypasses matchesSettingsSearch and is missing from getAccountsPaneSearchEntries, unlike every neighbouring section, so it stays visible for unrelated searches. Suggest gating on macOS and adding search entries alongside the other sections.
Technical details
# Unsupported platforms expose non-functional Antigravity controls; section ignores settings search
## Affected sites
- `src/renderer/src/components/settings/AccountsPane.tsx:374-376` — renders `AntigravityAccountsSection` for any non-remote scope with no platform check.
- `src/main/startup/main-process-account-services.ts:79-86` — service (and therefore the IPC handlers in `register-core-handlers.ts:153-161`) is constructed only when `process.platform === 'darwin'`.
- `src/renderer/src/components/settings/accounts-search.ts:219-227` — `getAccountsPaneSearchEntries` omits Antigravity.
- `src/renderer/src/web/preload-api/web-agent-accounts-api.ts:54-64` — web stub rejects `add`/`select`/`remove` while `list` resolves empty, so the section still renders with active buttons.
## Required outcome
- The section should only expose controls whose backing handler exists, and participating in accounts search like the other sections.
## Suggested approach (optional)
- Gate the render on a macOS signal (the pane already platform-gates elsewhere, e.g. `navigator.userAgent.includes('Windows')` around lines 115-121) and add `getAccountsAntigravitySearchEntries` to `getAccountsPaneSearchEntries`.
ELI5
Antigravity's Mac login is stored in one Keychain item. Orca now reads that exact item, understands the wrapper agy uses, remembers multiple native accounts safely, and switches the live login only after verifying the result.
What Changed
Why
The existing account work reads an obsolete token-file location and can borrow an email from legacy Gemini state. That cannot detect or switch the native agy session observed on this Mac. This uses the current agy storage contract and never logs token material.
Linked Issue
Fixes #19587
Related #17345
Visual Proof
UI added; live Electron/CDP visual proof is still pending before merge recommendation.
Testing
ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/antigravity/native-account-service.test.ts src/main/antigravity/native-credential-codec.test.ts src/main/antigravity/native-macos-credentials.test.ts(30 passed)pnpm tc:nodeReview
Draft. This implements the native credential and account-switching core. The desktop IPC/preload surface is wired; a dedicated Accounts renderer section and Windows/Linux backends remain before this can be merged as the complete multi-platform Accounts feature.
Notes
No token values are returned to renderer or wire APIs. Windows and Linux account backends still need corresponding native implementations before cross-platform account switching is complete.
Visual Proof
The rendered Accounts page shows the native Antigravity section and the signed-in account after clicking “Add current agy account”:
Verified through hidden Electron/CDP on macOS; no window was brought to the foreground.