fix(storage): let OverlayBackend's InventoryStore capability show through#96
Open
bootc wants to merge 1 commit into
Open
fix(storage): let OverlayBackend's InventoryStore capability show through#96bootc wants to merge 1 commit into
bootc wants to merge 1 commit into
Conversation
…ough OverlayBackend (used whenever ca_cert_file/ca_key_file is configured) wraps its base backend in a plain field rather than embedding it, so it never satisfied the InventoryStore interface itself even when the SQL backend beneath it does. StorageService picks its inventory-integrity scheme (O(1) hash chain vs. whole-blob HMAC) via a type assertion on s.backend, so wrapping a SQL backend silently downgraded it to the whole-blob scheme. This only surfaces once two callers disagree on the scheme for the same database: `openvox-ca-ctl migrate` has no reason to set ca_cert_file/ ca_key_file (it never touches per-subject keys), so it writes a hash-chain baseline via RebuildInventoryHMAC. A server configured with ca_key_file then opens the same database through OverlayBackend, falls back to a whole-blob HMAC, and fails to start with "inventory file integrity check failed: HMAC mismatch (possible tampering)". Add OverlayBackend.Unwrap() and an asInventoryStore() helper that walks through wrapper backends before the capability check, and use it at every call site that previously asserted s.backend.(InventoryStore) directly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
OverlayBackend(used wheneverca_cert_file/ca_key_fileis configured) wraps its base backend in a plain field rather than embedding it, so it never satisfiedInventoryStoreitself even when the SQL backend beneath it does.StorageServicepicks its inventory-integrity scheme (O(1) hash chain vs. whole-blob HMAC) via a type assertion ons.backend, so wrapping a SQL backend silently downgraded it to the whole-blob scheme.openvox-ca-ctl migratehas no reason to setca_cert_file/ca_key_file(it never touches per-subject keys), so it writes a hash-chain baseline viaRebuildInventoryHMAC. A server configured withca_key_filethen opens the same database throughOverlayBackend, falls back to a whole-blob HMAC, and fails to start withinventory file integrity check failed: HMAC mismatch (possible tampering).OverlayBackend.Unwrap()and anasInventoryStore()helper that walks through wrapper backends before the capability check, used at every call site that previously asserteds.backend.(InventoryStore)directly.Reproduced end-to-end against real Redis + PostgreSQL containers driving the actual
openvox-ca/openvox-ca-ctlbinaries (same error text as reported), then distilled into a regression test.Test plan
InventoryMigrationRoundTripOverlayDestinationininternal/storage/sql_inventory_test.go: migrates into a bare SQL backend, then opens the same database through anOverlayBackend(mirroring aca_key_fileserver) and callsInitHMAC— fails withErrInventoryTamperedbefore the fix, passes after.go test ./...passes.🤖 Generated with Claude Code