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

Predictable randomness

Summary

The generated randomness is not random as it can be predicted, hence giving a huge edge to an attacker as they would be able to know the expected outcome.

Vulnerability Details

When computing the winning index and rarity, the following variables are used:

  • msg.sender

  • block.timestamp

  • block.difficulty
    After PoS, block.difficulty is constantly 0. So it can be removed from the equation.
    block.timestamp changes at every block, but can easily be predicted based on the average block time of the chain.
    msg.sender can be any address, so a contract can be created to an expected address with create2 and use to invoke selectWinner with an address that gives a favorable outcome.

Impact

The winner can be pre-computed, so the game would be considered to be rigged and not provably fair.

Tools Used

Recommendations

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.