Mystery Box

First Flight #25
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

Random numbers are generated in a predictable way.

Summary

Random numbers are generated in MysteryBox::openBoxin a weak and predictable way. Therefore, a user can predict what is in his box and consistently get the desired reward each time he opens his box.

Vulnerability Details

The random number is generated by hashing block.timestamp and wallet address of the caller as shown below. Both values are deterministics, predictable and publicly available data. Anyone can predict the random number.

uint256 randomValue = uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 100;

Impact

A user can consistently get the Gold Coin since he can predict it.

Tools Used

Manual review

Recommendations

Use Chainlink VRF random number generator to generate random numbers.

Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Weak Randomness

Support

FAQs

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

Give us feedback!