fix: cache slot in check_block_relevancy to prevent TOCTOU#8776
Open
radik878 wants to merge 4 commits intosigp:unstablefrom
Open
fix: cache slot in check_block_relevancy to prevent TOCTOU#8776radik878 wants to merge 4 commits intosigp:unstablefrom
radik878 wants to merge 4 commits intosigp:unstablefrom
Conversation
Co-Authored-By: hopinheimer <knmanas6@gmail.com> Co-Authored-By: hopinheimer <48147533+hopinheimer@users.noreply.github.com> Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu> Co-Authored-By: Michael Sproul <michael@sigmaprime.io> Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>
Closes sigp#8681 Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
|
|
1 similar comment
|
|
Member
|
#Sounds reasonable, can you please rebase on unstable? |
Member
|
I've changed the base branch on github but you will need to push a rebased commit for CI to pass. Please also sign the CLA |
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.
Why
check_block_relevancycalledchain.slot()?twice — once for the comparison and once inside theFutureSloterror. Sincechain.slot()lighthouse/beacon_node/beacon_chain/src/block_verification.rs
Lines 1247 to 1249 in edba56b
present_slotin the error to be higher thanblock_slot, which is logically contradictory for a "future slot" error and can mislead logging and peer scoring.Every other FutureSlot check in the codebase (gossip blocks, blobs, data columns, attestations, sync committees) already caches the slot in a local variable. This was the only place that didn't.
What
Store
chain.slot()?in a local variable and reuse it for both the comparison and the error construction, consistent with the rest ofthe codebase.