Skip to content

fix(vault): x25519 recipients can open their vault; rotate fails closed - #114

Merged
VirtualMachinist merged 1 commit into
mainfrom
jupi/geode-rekey-lockout-fix
Oct 26, 2026
Merged

VirtualMachinist merged 1 commit into
mainfrom
jupi/geode-rekey-lockout-fix

Conversation

@VirtualMachinist

Copy link
Copy Markdown
Member

Problem

An identity added with geode vault add-recipient --gpub could not use the vault. verify, list, cat, open and rotate with its .gkey all exited 2 (authentication / integrity failure). vault rotate --drop-recipient <original> --reseal, run with the original key, then reported success but left a vault that no key could read.

Root cause

crates/geode-cli/src/cmd/mod.rs:300 (load_recipients_for) only matched Recipient::Symmetric entries by key_id. An X25519 recipient was never unwrapped, so the added identity always fell through to Error::AuthFail. A second issue in the CLI rotate path made it worse: it resealed from outcome.old_ek, which rotate::plan_rotation re-derives from the operator's ISK (crates/geode-core/src/rotate.rs:139). That is only correct for the vault's original symmetric identity. A rotation run by an X25519 identity therefore produced an empty manifest and silently mis-wrapped any symmetric recipient it kept.

Fix

  • Read path: load_recipients_for now also unwraps the X25519 recipient whose public key matches the identity, using the ISK-derived X25519 secret (key::x25519_secret, shared with .gpub generation).
  • Rotate, old epoch key: reseal and policy reseal use the epoch key that was actually unwrapped (ctx.ek).
  • Rotate, fail closed:
    • Before any write, it refuses a kept symmetric recipient that isn't the operator (re-wrapping would lock it out), an unusable or low-order X25519 public key, and a kept set that no one could open.
    • It checks that the operator's own new wrap unwraps to the new epoch key.
    • Before the header commit, it checks that the new manifest authenticates and every resealed object opens. If the operator kept access, it also checks that the committed vault loads.
    • On any failure it restores recipients.json, header.json and the sealed policy, and removes the new epoch dir.
  • geode open: extracted files are written owner-only ((mode & 0o700) | 0o600, so 0644 becomes 0600). The file is created 0600 before any plaintext is written.
  • CHANGELOG Unreleased entries added. No version bump.

Tests (crates/geode-cli/tests/rotate_cli.rs)

  • add_recipient_new_key_reads: after add-recipient, the new key can verify, list and cat.
  • rotate_drop_old_reseal_new_key_still_reads: drop the original + reseal; the new key still reads, the old key exits 2, and the new key can rotate again.
  • rotate_lockout_refused_vault_unchanged: a rotate that would lock out the symmetric recipient is refused (exit 1), the vault is byte-identical afterwards, and both keys still read.
  • open_writes_plaintext_0600: a 0644 source comes out of open as 0600.

Local: fmt clean; clippy -D warnings clean both with default features and with --features test-trusted-root; cargo test --workspace --exclude geode-cli, cargo test -p geode-cli --features test-trusted-root and cargo test -p geode-cli all pass.

An identity added with `vault add-recipient --gpub` could not open the
vault: load_recipients_for only matched symmetric recipients, so the added
key got an authentication failure on verify/list/cat/open/rotate. Rotating
with the original key while dropping itself then left a vault that no key
could read.

- load_recipients_for unwraps the epoch key from the X25519 recipient whose
  public matches the identity (ISK-derived X25519 secret).
- vault rotate reseals from the epoch key it actually unwrapped instead of
  re-deriving it from the operator ISK (which reset the manifest when an
  X25519 identity rotated).
- vault rotate refuses, before any write, a kept symmetric recipient it
  cannot re-wrap, an unusable X25519 public, or a kept set nobody can open;
  verifies the new wraps, manifest and resealed objects before the header
  commit; and restores the old epoch on any failure.
- geode open writes extracted plaintext owner-only (0600 for a 0644 entry),
  created with that mode.

Regression tests: add-recipient key reads; drop old + reseal keeps the new
key and locks out the old; lockout rotate refused with the vault unchanged;
open output is 0600.
@VirtualMachinist
VirtualMachinist marked this pull request as ready for review October 26, 2026 20:22
@VirtualMachinist
VirtualMachinist merged commit 7e83935 into main Oct 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant