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

The winner is predictable.

Summary

The variables related to block can be checked if they are the same block, so the winnerIndex is predictable.

Vulnerability Details

The formula for the winnerIndex is as follows
uint256 winnerIndex = uint256(keccak256(abi.encodePacked(msg.sender, block.timestamp, block.difficulty))) % players.length;
Since block.timestamp and block.difficulty can be referenced for the same block, they are all predictable variables. In other words, players can predict the winner in advance, so they can add new players according to their winnerIndex (their subaddresses) and so on.

Impact

You can commit injustices that make you a winner.

Tools Used

Manual

Recommendations

Use an oracle to apply a random index to the winner

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.