fix: prevent attestation cache poisoning on key rotation (#5)#43
Merged
JamesEjembi merged 1 commit intoJun 24, 2026
Merged
Conversation
…bs#5) The verification cache keyed a validator's public key by id alone and cleared it on rotation. During the 3-5s on-chain finality gap a verify reloaded the stale OLD key, re-cached it, and rejected every attestation signed with the NEW key for the whole window. Fix combines two-phase rotation, a key-generation counter, and a multi-key versioned cache: - KeyRegistry: rotate_key bumps key_gen and keeps the prior key as previous_key, valid for ROTATION_WINDOW_LEDGERS - VerificationCache: versioned by key_gen; a verify whose registry generation is newer than the cached one reloads, so a stale entry is never reused; the reloaded entry holds both new and (in-window) old key - verify_with_rotation accepts if any currently-valid key matches, so late old-key and new-key attestations both verify; old key drops after the window - attestation/key_registry.rs: KeyRegistry, VerificationCache, verify_with_rotation - tests: rotation-window accepts old+new, old key expires after window, concurrent rotation-and-verify batch, unknown validator, property test
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.
Fix #5 — Attestation Verification Cache Poisoning via Concurrent Key Rotation
Closes #5
Changes
src/attestation/key_registry.rsKeyRegistry(register/rotate_key/snapshot),VerificationCache(key-gen-versioned),verify_with_rotationsrc/attestation/mod.rspub mod key_registrytests/attestation_key_rotation_test.rs