Skip to content

fix(vault): refuse no-reseal rotate that would hide entries; strict restore - #115

Merged
VirtualMachinist merged 1 commit into
mainfrom
jupi/geode-rotate-noreseal-manifest
Oct 26, 2026
Merged

VirtualMachinist merged 1 commit into
mainfrom
jupi/geode-rotate-noreseal-manifest

Conversation

@VirtualMachinist

@VirtualMachinist VirtualMachinist commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

F-1: rotate without --reseal emptied the vault

vault rotate without --reseal committed an empty new-epoch manifest (commit_rotation lays one down and nothing replaced it), and the header moved to that epoch. Every entry disappeared from list / cat / open, even though the old objects were still on disk.

Design choice: refuse, don't carry forward

Entries can't be carried forward correctly without a format change:

  • Objects are sealed per epoch. The epoch is in the object's AEAD associated data and in its path (epochs/<N>/objects/…).
  • A manifest is MAC'd under its own epoch's manifest key and names objects of that epoch only. read_object and open_object are always called with the vault's current epoch and its key.

A new-epoch manifest that pointed at old-epoch objects would need a per-entry epoch field, plus an old-epoch-key lookup on every read path (CLI, TUI, mount, agent). That is a format change, and a riskier one than this fix.

So rotate now refuses to run without --reseal while the vault holds entries:

  • It exits 1 with rotate without --reseal would hide the vault's N entries (objects are sealed per epoch); re-run with --reseal.
  • The check runs before anything is written, so the vault stays byte-identical.
  • A vault with no entries still rotates without --reseal, since an empty manifest is exact there. The documented "drop without reseal is incomplete revocation" behavior is unchanged for that case.

N-1

Replaced the wrong comment ("Without reseal the new epoch starts from the current entries") with what actually happens. The --reseal / --drop-recipient / rotate help text now says --reseal is required when the vault holds entries.

N-2: strict restore

  • RotateBackup now records whether the old-epoch recipients.json snapshot already existed. If this rotate created it, restore removes it. A snapshot that was already there is kept.
  • restore attempts every step and returns the first error, including the path it hit.
  • finish_or_restore returns the original error when restore succeeds. If restore also fails, it returns rotate failed: <original>; restoring the previous epoch ALSO failed: <restore error> … with a nonzero exit.

Tests

  • rotate_cli::rotate_without_reseal_refused_when_vault_has_entries:
    • with and without --drop-recipient, it exits 1, names --reseal, and leaves the vault byte-identical;
    • list still shows the entry, and verify / list / cat still open it.
  • rotate_cli::rotate_failure_restores_vault_and_removes_snapshot:
    • a corrupted object makes --reseal fail after the snapshot and the new epoch were written (exit 2);
    • the snapshot and the new epoch dir are removed, the vault is byte-identical, and the header is still at epoch 1.
  • Unit tests in cmd::vault::rotate_restore_tests:
    • restore_undoes_snapshot_and_new_epoch
    • restore_keeps_preexisting_snapshot
    • restore_error_is_reported_with_original: a non-empty directory in place of header.json makes restore fail. The message carries both errors and the exit is nonzero.
    • restore_ok_returns_original_error

CHANGELOG Unreleased entries added. No version bump.

…estore

A rotate without --reseal committed an empty new-epoch manifest, so every
entry disappeared from list/cat/open. Objects are sealed per epoch (epoch
in the AEAD AD and in the object path) and a manifest only names objects of
its own epoch, so entries cannot simply be carried forward without a format
change. Rotate now refuses to run without --reseal while the vault holds
entries (exit 1, nothing written); empty vaults rotate as before.

The failed-rotate restore now also removes the old-epoch recipients
snapshot it created, attempts every restore step, and reports a restore
failure together with the original error instead of discarding it.

Also corrects the misleading comment about no-reseal behavior and the
--reseal / --drop-recipient help text.
@VirtualMachinist
VirtualMachinist marked this pull request as ready for review October 26, 2026 20:50
@VirtualMachinist
VirtualMachinist merged commit d2b2a02 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