Mystery Box

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

Weak randomness in `MysteryBox::openBox` function.

Summary

Hashing block.timestamp and msg.sender together results in a predictable number. This number is not a good choice for a random number as malicious actors can manipulate it and determine it well ahead of time to choose the rarest reward possible.

Vulnerability Details

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

Impact

Any user could influence the reward they could win, thus trying to win the rarest reward possible.

Tools Used

VS Code

Recommendations


Consider using cryptographically provable random number generator such as Chainlink VRF.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago

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.