fix: reject fake p2p epoch distributions with valid self-hash#2122
Merged
Scottcjn merged 1 commit intoScottcjn:mainfrom Apr 6, 2026
Merged
Conversation
Contributor
Author
|
For bounty payout, please use RTC wallet: RTC1d48d848a5aa5ecf2c5f01aa5fb64837daaf2f35. |
Owner
|
Reviewed. Closes the epoch proposal self-validation flaw — merkle check only proved internal consistency, not that recipients were legitimately attested. Now cross-references distribution recipients against Payment: 65 RTC — P2P fake epoch distribution rejection (High severity) Merging. Thank you createkr. |
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.
Fix P2P epoch proposal merkle self-validation flaw
Problem
_handle_epoch_propose()inrustchain_p2p_gossip.pyonly verified that the merkle root in an epoch proposal was internally consistent with the provided distribution data. It never checked whether distribution recipients were actually attested miners. A malicious epoch leader could send a self-paying distribution with a correctly computed merkle root, and all peers would vote "accept".Fix
After the merkle internal-consistency check, the handler now queries
miner_attest_recentand rejects any proposal whose distribution includes recipients not present in the locally attested miner set. DB errors are handled fail-safe (reject).Changes
node/rustchain_p2p_gossip.py: Added attested-miner cross-reference validation in_handle_epoch_propose()and extracted_reject_epoch_vote()helper.node/tests/test_epoch_proposal_merkle_validation.py: 8 new tests covering self-paying distributions, partial unattested recipients, valid distributions, merkle mismatch, empty distributions, invalid leaders, miner removal between epochs, and DB error fail-safe.Tests
8/8 new tests pass. No existing tests affected.