fix: verify merkle_root in BFT _validate_proposal against miners list#769
Merged
Scottcjn merged 1 commit intoScottcjn:mainfrom Mar 9, 2026
Merged
Conversation
Fixes Scottcjn#766 _validate_proposal checked that miner IDs in 'distribution' existed in the 'miners' list and that the total reward summed to 1.5 RTC, but it never re-computed the Merkle root from the submitted miners list and compared it to proposal['merkle_root']. A Byzantine leader could therefore recycle a valid merkle_root from a previous epoch while supplying a falsified miners list that still passes the miner-ID / total-reward checks. Honest nodes would send PREPARE messages for a proposal whose attestation data is inconsistent with the digest they are voting on. Add a Merkle root recomputation and equality check before returning True so that any mismatch between the claimed merkle_root and the actual miners data causes _validate_proposal to return False.
Scottcjn
approved these changes
Mar 9, 2026
Owner
Scottcjn
left a comment
There was a problem hiding this comment.
Important consensus security fix. Without this, a Byzantine leader could recycle a valid merkle_root from a previous epoch while submitting a falsified miners list — honest nodes would still send PREPARE. The fix correctly recomputes _compute_merkle_root(miners) and validates before accepting.
Verdict: MERGE — 50 RTC bounty (consensus security hardening).
🤖 Reviewed with GPT-5.4 + Claude Opus dual-brain analysis
createkr
pushed a commit
to createkr/Rustchain
that referenced
this pull request
Mar 22, 2026
…Scottcjn#769) Fixes Scottcjn#766 _validate_proposal checked that miner IDs in 'distribution' existed in the 'miners' list and that the total reward summed to 1.5 RTC, but it never re-computed the Merkle root from the submitted miners list and compared it to proposal['merkle_root']. A Byzantine leader could therefore recycle a valid merkle_root from a previous epoch while supplying a falsified miners list that still passes the miner-ID / total-reward checks. Honest nodes would send PREPARE messages for a proposal whose attestation data is inconsistent with the digest they are voting on. Add a Merkle root recomputation and equality check before returning True so that any mismatch between the claimed merkle_root and the actual miners data causes _validate_proposal to return False. Co-authored-by: wsimon1982 <wsimon1982@googlemail.com>
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.
Fixes #766
Problem
_validate_proposalinnode/rustchain_bft_consensus.pychecked that miner IDs indistributionexisted in theminerslist and that the total reward summed to 1.5 RTC — but it never re-computed the Merkle root from the submittedminerslist and compared it toproposal["merkle_root"].A Byzantine leader could recycle a valid
merkle_rootfrom a previous epoch while submitting a falsifiedminerslist that still passes the miner-ID / total-reward checks. Honest nodes would sendPREPAREmessages for a proposal whose attestation data is inconsistent with the digest they are voting on.Reproducer
Solution
Recompute the Merkle root from the
minerslist and assert equality: