Skip to content

fix: prevent attestation cache poisoning on key rotation (#5)#43

Merged
JamesEjembi merged 1 commit into
VeriNode-Labs:mainfrom
real-venus:fix/attestation-key-rotation
Jun 24, 2026
Merged

fix: prevent attestation cache poisoning on key rotation (#5)#43
JamesEjembi merged 1 commit into
VeriNode-Labs:mainfrom
real-venus:fix/attestation-key-rotation

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

Fix #5 — Attestation Verification Cache Poisoning via Concurrent Key Rotation

Closes #5

Changes

File Purpose
src/attestation/key_registry.rs KeyRegistry (register/rotate_key/snapshot), VerificationCache (key-gen-versioned), verify_with_rotation
src/attestation/mod.rs Registers pub mod key_registry
tests/attestation_key_rotation_test.rs Rotation/cache tests

…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

@JamesEjembi JamesEjembi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JamesEjembi JamesEjembi merged commit acd5edd into VeriNode-Labs:main Jun 24, 2026
1 check 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.

Attestation Signature Verification Cache Poisoning via Concurrent Key Rotation

2 participants