Repository navigation
fix(vault): refuse no-reseal rotate that would hide entries; strict restore - #115
Merged
Merged
Conversation
…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
marked this pull request as ready for review
October 26, 2026 20:50
This was referenced Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
F-1: rotate without
--resealemptied the vaultvault rotatewithout--resealcommitted an empty new-epoch manifest (commit_rotationlays one down and nothing replaced it), and the header moved to that epoch. Every entry disappeared fromlist/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:
epochs/<N>/objects/…).read_objectandopen_objectare 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
--resealwhile the vault holds entries:rotate without --reseal would hide the vault's N entries (objects are sealed per epoch); re-run with --reseal.--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/rotatehelp text now says--resealis required when the vault holds entries.N-2: strict restore
RotateBackupnow records whether the old-epochrecipients.jsonsnapshot already existed. If this rotate created it, restore removes it. A snapshot that was already there is kept.restoreattempts every step and returns the first error, including the path it hit.finish_or_restorereturns the original error when restore succeeds. If restore also fails, it returnsrotate 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:--drop-recipient, it exits 1, names--reseal, and leaves the vault byte-identical;liststill shows the entry, andverify/list/catstill open it.rotate_cli::rotate_failure_restores_vault_and_removes_snapshot:--resealfail after the snapshot and the new epoch were written (exit 2);cmd::vault::rotate_restore_tests:restore_undoes_snapshot_and_new_epochrestore_keeps_preexisting_snapshotrestore_error_is_reported_with_original: a non-empty directory in place ofheader.jsonmakes restore fail. The message carries both errors and the exit is nonzero.restore_ok_returns_original_errorCHANGELOG
Unreleasedentries added. No version bump.