fix: replace random with secrets for cryptographically secure validator selection#4189
Closed
BossChaos wants to merge 2 commits intoScottcjn:mainfrom
Closed
fix: replace random with secrets for cryptographically secure validator selection#4189BossChaos wants to merge 2 commits intoScottcjn:mainfrom
BossChaos wants to merge 2 commits intoScottcjn:mainfrom
Conversation
Owner
|
Closing per first-poster ruling (2026-05-10). @508704820 submitted the same finding class earlier today:
Per the Self-Audit Credit Check policy, the earliest poster of a finding earns the bounty. @508704820 has been paid 40 RTC for both. Your implementation work is real, but not first. If your fix is materially better (more complete, better tests, edge cases the first-poster missed), please comment on @508704820 PR with the specific delta — that earns review-credit if it adds value. — auto-triage 2026-05-10 |
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.
Summary
Wallet:
RTC6d1f27d28961279f1034d9561c2403697eb55602Vulnerability Fixed
Non-Cryptographic Random in Validator Selection (HIGH)
File:
rips/rustchain-core/consensus/poa.py,select_validator()Bug: Uses
random.uniform()andrandom.choice()for consensus validator selection. Python'srandommodule is NOT cryptographically secure — the Mersenne Twister sequence is predictable after observing ~624 outputs.Attack: An attacker monitoring block production can:
Fix: Replace
randomwithsecretsmodule (cryptographically secure):random.uniform(0, total_as)→secrets.randbelow(int(total_as * 1_000_000)) / 1_000_000random.choice(proofs)→proofs[secrets.randbelow(len(proofs))]Local Testing
python test_poa_consensus_security.py # PASS: Validator selection uses cryptographically secure randomness (secrets)Related