Vault: a lost vault_keys row routes the operator to /setup, which conceals the loss #143
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lz/agent-nexus#143
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found in the
/pr-reviewpass overfeat/mcp.isSetupComplete(auth/vault-store.ts) answers yes if amasterprincipal exists, else falls back tometa.kdf_saltto recognise a pre-envelope install. That fallback was added deliberately (commit2081490) to stop/setupwriting a fresh DEK over a legacy vault.But a fresh envelope install writes no
metarows at all —setupMasterPassphraseonly writes the principal. So the guard covers legacy installs and not envelope ones. If the singlevault_keysrow is lost (restore from a backup predating migration 0020, a manualDELETE,0020.down(), a partial table restore),isSetupCompletereturns false,/api/statereportsneeds-setup,PHASE_ROUTEforces/setup, and setup succeeds silently with a brand-new random DEK.Severity: this conceals data loss, it does not cause it
Worth being precise, because the first framing overstated it.
wrapped_dekis the only copy of the data key — the moment that row vanishes, everyencrypted_*value is already unrecoverable./setupre-keying destroys nothing that was still readable.What it costs is the diagnostic and the restore window: the operator is told they have a fresh install, reconnects providers, re-enters env vars, and never learns that restoring
vault_keysfrom a backup would have recovered everything.Suggested fix
Make the predicate "sealed data exists but no principal does" an explicit refusal rather than letting it fall through to setup:
connectionsorrepo_env_varsrow exists and no principal does → refuse setup with "this instance holds sealed data but its vault key is missing; restorevault_keysfrom a backup".That generalises the
meta.kdf_saltfallback, which only approximates the same condition for legacy installs.