Repository navigation
fix(bits): guard BitArray against malformed Bits/Elems from peer proto - #46
Open
FletcherMan wants to merge 1 commit into
Open
FletcherMan wants to merge 1 commit into
FletcherMan wants to merge 1 commit into
Conversation
A peer can send a consensus message (NewValidBlock/ProposalPOL/VoteSetBits) whose BitArray carries Bits>0 but no Elems. FromProto writes Bits unconditionally but only writes Elems when non-empty, so the decoded array is internally inconsistent. getTrueIndices then indexes Elems[-1] and panics with "index out of range [-1]", crashing the node from the catchup gossip path (reactor.go gossipDataForCatchup -> PickRandom -> getTrueIndices). Minimal, surgical hotfix on the three bit_array.go sites that index Elems based on Bits without checking len(Elems): - getTrueIndices: treat a Bits/Elems-inconsistent array as having no set bits - setIndex: bounds-check i/64 against len(Elems) - IsFull: avoid Elems[:len-1] panic on empty Elems Does not change FromProto or message ValidateBasic; a fuller validation-based fix (ported from CometBFT v0.40.0) is tracked separately. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.
Tip: disable this comment in your organization's Code Review settings.
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.
A peer can send a consensus message (NewValidBlock/ProposalPOL/VoteSetBits) whose BitArray carries Bits>0 but no Elems. FromProto writes Bits unconditionally but only writes Elems when non-empty, so the decoded array is internally inconsistent. getTrueIndices then indexes Elems[-1] and panics with "index out of range [-1]", crashing the node from the catchup gossip path (reactor.go gossipDataForCatchup -> PickRandom -> getTrueIndices).
Minimal, surgical hotfix on the three bit_array.go sites that index Elems based on Bits without checking len(Elems):
Does not change FromProto or message ValidateBasic; a fuller validation-based fix (ported from CometBFT v0.40.0) is tracked separately.
PR checklist
CHANGELOG_PENDING.mdupdated, or no changelog entry neededdocs/) and code comments, or nodocumentation updates needed