fix(internal/consensus/reactor.go): reject oversized proposals#5309
fix(internal/consensus/reactor.go): reject oversized proposals#5309arsushi wants to merge 4 commits intocometbft:mainfrom
Conversation
| } | ||
| switch msg := msg.(type) { | ||
| case *ProposalMessage: | ||
| maxBytes := conR.conS.state.ConsensusParams.Block.MaxBytes |
There was a problem hiding this comment.
Is there a way we can test this?
almk-dev
left a comment
There was a problem hiding this comment.
Can you explain the -1/+1 logic in a comment?
It is based on the validation in cometbft/internal/consensus/state.go Lines 2075 to 2082 in 88e9ea6 |
Co-authored-by: Abdul Malek <me@almk.dev>
|
@arsushi looks like we have some CI failing! |
|
@arsushi can we also get a changelog entry for this? |
| } | ||
| proposal.Signature = p.Signature | ||
|
|
||
| go sendProposalAndParts(height, round, cs, targetPeer, proposal, block, block.Hash(), blockParts) |
There was a problem hiding this comment.
I'm not sure this test case is actually testing anything. This looks to me that it creates the oversized proposal, and then sends the proposal and parts to the peer (where it will be rejected), but it doesnt actually asset that the peer rejected it, it returns before anything is asserted about the peer state.
--- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here #5309, but reopened since the contributor stopped replying. #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments --------- Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com>
--- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here #5309, but reopened since the contributor stopped replying. #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments --------- Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com> (cherry picked from commit 9ff47d0)
…5407) --- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here #5309, but reopened since the contributor stopped replying. #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments <hr>This is an automatic backport of pull request #5324 done by [Mergify](https://mergify.com). Co-authored-by: Alex | Interchain Labs <alex@cosmoslabs.io> Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com>
…#5324) (cometbft#5407) --- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here cometbft#5309, but reopened since the contributor stopped replying. #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments <hr>This is an automatic backport of pull request cometbft#5324 done by [Mergify](https://mergify.com). Co-authored-by: Alex | Interchain Labs <alex@cosmoslabs.io> Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com>
…#5324) (cometbft#5407) --- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here cometbft#5309, but reopened since the contributor stopped replying. - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments <hr>This is an automatic backport of pull request cometbft#5324 done by [Mergify](https://mergify.com). Co-authored-by: Alex | Interchain Labs <alex@cosmoslabs.io> Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com>
…#5324) (cometbft#5407) --- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here cometbft#5309, but reopened since the contributor stopped replying. - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments <hr>This is an automatic backport of pull request cometbft#5324 done by [Mergify](https://mergify.com). Co-authored-by: Alex | Interchain Labs <alex@cosmoslabs.io> Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com>
* fix(bits): prevent BitArray.UnmarshalJSON from crashing on 0 bits in the JSON (backport cometbft#2774) (cometbft#2778) This change fixes a bug in which BitArray.UnmarshalJSON hadn't accounted for the fact that invoking NewBitArray(<=0) returns nil and hence when dereferenced would crash with a runtime nil pointer dereference. This bug was found by my security analysis and fuzzing too. Author: @odeke-em Fixes cometbft#2658 --- - [x] Tests written/updated - [x] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] ~~Updated relevant documentation (`docs/` or `spec/`) and code comments~~ - [x] Title follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec <hr>This is an automatic backport of pull request cometbft#2774 done by [Mergify](https://mergify.com). --------- Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com> * fix(consensus/reactor): reject oversized proposals (backport cometbft#5324) (cometbft#5407) --- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here cometbft#5309, but reopened since the contributor stopped replying. - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments <hr>This is an automatic backport of pull request cometbft#5324 done by [Mergify](https://mergify.com). Co-authored-by: Alex | Interchain Labs <alex@cosmoslabs.io> Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com> * Merge commit from fork * add VaidateBasic to BitArray to ensure Bits and len(Elems) are valid * call ValidateBasic on BitArrays when receiving as a msg from exteranl nodes * enfore SetIndex is not setting out of bounds * add guard to getNumTrueIndices getNumTrueIndices will index out of bounds if Bits and Elems have a mismatch where len(elems) != (bits+63)/64, this guard makes it simply return 0 if this mismatch is present * changelog * fix missing import for v0.38.x * update changelog for release of v0.38.19 * remove duplicate bug fixes from unreleased * fix changelog date * fix lint * fix expected error string in test * add necessary test constants --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com> Co-authored-by: Alex | Interchain Labs <alex@cosmoslabs.io> Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com> Co-authored-by: Matt Acciai <matt@cosmoslabs.io>
…#5324) (cometbft#5407) --- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here cometbft#5309, but reopened since the contributor stopped replying. #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments <hr>This is an automatic backport of pull request cometbft#5324 done by [Mergify](https://mergify.com). Co-authored-by: Alex | Interchain Labs <alex@cosmoslabs.io> Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com>
--- Updates the consensus reactor to validate that a received proposal will not contain more parts than the amount of chunks that it would take to build a block whos size is equal to `ConsensusParams.Block.MaxBytes`. Original PR is here #5309, but reopened since the contributor stopped replying. #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments --------- Co-authored-by: arsushi <richie@asymmetric.re> Co-authored-by: Abdul Malek <me@almk.dev> Co-authored-by: Matt Acciai <matt@skip.money> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com>
PR checklist
.changelog(we use unclog to manage our changelog)docs/orspec/) and code comments