Mystery Box

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

[H-2]: Weak randomness in `MysteryBox::openBox` allows users to predict or influence the random value and influence the winnings amount

Summary

Hashing block.timestamt and msg.sender together is creating a predictable final number that malicious users may manipulate or know them ahead of time. Both values are known and hashing them creates an output that can be known in advance.

Vulnerability Details

Any user can influence the rarity of the coin they receive. This can damage the protocol as the funds allocated for winnings may quickly run dry.

Proof-of-Concept

  1. Validators know ahead of time the block.timestamp and know the msg.sender value that will be used to generate the MysteryBox::openBox randomValue variable.

  2. Users can mine or manipulate their msg.sender so the result gives a desired value to get the largest winnings

  3. Users can also revert their transaction if they do not like the winnings

Tools Used

Static analysis

Recommendations

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

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.