security: replace java.util.Random with SecureRandom (5 sites)#17
Merged
QuickMythril merged 1 commit intoMay 28, 2026
Merged
Conversation
Five call sites used the non-cryptographic java.util.Random: Q4 - P2P request IDs (ArbitraryDataFileListManager x2, ArbitraryMetadataManager): Predictable IDs allow a malicious peer to preemptively spoof responses to in-flight QDN file-list and metadata requests. Q5 - Online account / block minting nonces (OnlineAccountsManager, Block): new Random() nonces are seeded from system time, making the 500 000- element nonce space partially predictable by an observer. Replace all five sites with SecureRandom. Add explicit java.security.SecureRandom imports where the wildcard java.util.* import did not cover it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e3a8009 to
882b98d
Compare
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
Five call sites used non-cryptographic
java.util.Random(seeded from system time) in places where unpredictability matters.Q4 - P2P request IDs (3 sites)
ArbitraryDataFileListManager (x2) and ArbitraryMetadataManager (x1) generated request IDs with
new Random().nextInt(). These IDs are broadcast to all peers. A malicious peer who can observe network timing can predict upcoming IDs and preemptively send spoofed responses, causing the node to accept fabricated file-list or metadata replies.Q5 - Online account / block minting nonces (2 sites)
OnlineAccountsManager and Block generated MemPoW nonces with
new Random().nextInt(500000). Seeding from a predictable RNG reduces the effective entropy of the starting nonce.Changes
No functional behaviour changes - only the RNG source is upgraded.
u{1F916} Security fix identified and patched by Claude Code (https://claude.ai/claude-code)