fix: bound attestation slot against head and store clock#1020
Merged
tcoratger merged 3 commits intoJun 14, 2026
Merged
Conversation
The gossip attestation validator fed the unbounded wire field attestation_data.slot straight into the interval conversion, which multiplies it by the intervals-per-slot count and wraps the product in a range-checked unsigned 64-bit constructor. A crafted gossip attestation with a near-2**64 slot raised a pydantic validation error that escaped the gossip handler's rejection-only catch and crashed the node, a one-message remote denial of service. The root cause is that the slot was never tied to the head it claims. This change adds two checks after the topology checks: - The vote's slot must not precede the slot of the head block it claims to have seen, surfaced as a new ATTESTATION_SLOT_BEFORE_HEAD rejection. This anchors the wire slot from below by a known block and enforces the 3SF attestation semantics where the slot records when the head was seen. - The future-time gate now compares in slot units with plain-int arithmetic before constructing any interval, so a near-ceiling slot is rejected cleanly instead of overflowing. The integer comparison is equivalent to the previous interval comparison. Adds two negative consensus vectors: one for a slot at the unsigned 64-bit ceiling rejected without overflow, and one for a slot preceding its head. All 115 fork-choice vectors still fill green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Split multi-clause sentences onto their own lines and replace code-identifier-style names (intervals_per_slot, horizon) in the head-consistency and time-check comments with plain English, per the documentation rules. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cut the head-consistency and time-check comments to their essential reason (two lines each) and shorten the new rejection-reason docstring. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
pablodeymo
pushed a commit
to lambdaclass/ethlambda
that referenced
this pull request
Jun 18, 2026
## What Ports the head-consistency guard from [leanSpec PR #1020](leanEthereum/leanSpec#1020) into `validate_attestation_data`. A gossip attestation's slot records *when* the head was observed, so it cannot precede the slot of the head block it claims to have seen. We did not enforce this lower bound: the wire `slot` field was untethered from any real block, free to be set arbitrarily relative to the observed head. ## Why | Property | Risk without the guard | |----------|------------------------| | Soundness | An unbounded slot violates 3SF attestation semantics: the slot is meant to anchor when the head was seen. | | Liveness (spec context) | In leanSpec a crafted near-`2**64` slot overflowed the slot→interval constructor and crashed the node (remote DoS). | **Note on the overflow half:** ethlambda's time check already uses `saturating_mul` (`data.slot.saturating_mul(INTERVALS_PER_SLOT)`), so a near-`u64::MAX` slot saturates to `u64::MAX` and is rejected cleanly as too-far-in-future rather than panicking. The Rust port was never crashable the way the unchecked Python constructor was, so no change to the time-check arithmetic is needed; the spec's switch to slot-unit comparison is mathematically equivalent to the existing interval comparison. This PR adds the genuinely missing piece: the semantic lower bound. ## Change - New `StoreError::AttestationSlotBeforeHead { attestation_slot, head_slot }` rejection. - Check `data.slot < data.head.slot` after the ancestry checks, before the time check (mirrors the spec's ordering). - Two unit tests: a vote whose slot precedes its head (rejected as `AttestationSlotBeforeHead`), and a `u64::MAX` ceiling slot (rejected as `AttestationTooFarInFuture`, confirming no overflow). Applies to both gossip paths via the shared `validate_attestation_data` (`on_gossip_attestation` and `on_gossip_aggregated_attestation`). ## Testing ``` cargo test -p ethlambda-blockchain --lib validate_attestation # 5 passed cargo fmt --all && cargo clippy -p ethlambda-blockchain --lib # clean ``` https://claude.ai/code/session_018pvnQJkom3DobK9oSbK42T
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.
Hazard
The gossip attestation validator fed the unbounded wire field
attestation_data.slotstraight into the slot-to-interval conversion, which multiplies the slot by the intervals-per-slot count and wraps the product in a range-checked unsigned 64-bit constructor. A crafted gossip attestation with a near-2**64slot raised apydantic.ValidationErrorthat escapes the gossip handler's rejection-only catch and crashes the importing node. One crafted message downs a node, a remote denial of service.The deeper cause is that the slot was never tied to the head checkpoint it claims to have seen, so it could be set to an arbitrary value relative to the observed head.
Property at risk
Fix
Two checks are added after the topology checks in attestation validation:
ATTESTATION_SLOT_BEFORE_HEADrejection. This anchors the wire slot from below by a known block and enforces the head-consistency invariant.slot * intervals_per_slot > horizonis the same asslot > horizon // intervals_per_slot.Adds two negative consensus vectors: a slot at the unsigned 64-bit ceiling rejected without overflow, and a slot preceding its head. All 115 fork-choice vectors still fill green.
🤖 Generated with Claude Code