Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: high
Valid

Malicious miners can predict the raffle result

Summary

Malicious miners can predict the raffle result

Vulnerability Details

selectWinner uses block.timestamp and block.difficulty to determine the winner.

uint256 winnerIndex =
uint256(keccak256(abi.encodePacked(msg.sender, block.timestamp, block.difficulty))) % players.length;

While the block variables may be unpredictable, it is still determined by the miners who are adding blocks to the blockchain, and an attacker may be able to influence the difficulty and predict the output of this function.

Impact

Malicious miners will keep trying to generate Randomness until they acquire the desired result, with which they will then broadcast a block or an attacker may be able to influence the difficulty and predict the output of this function.

Tools Used

Manual review.

Recommendations

Increase randomness and unpredictability by generating random numbers through the participation of multiple parties or by using an oracle.

Updates

Lead Judging Commences

Hamiltonite Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

weak-randomness

Root cause: bad RNG Impact: manipulate winner

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.