Mystery Box

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

[H-04] Weak randomness in MysteryBox::openBox allows players to influence or game the system to guarantee rare rewards

Summary

Randomness seed is generated from hashing msg.sender & block.timestamp. Both of these parameters are deterministic and can therefore be predicted to ensure the box is opened at an optimal time to gain a valuable reward.

Vulnerability Details

Overview:
Using onchain values as a randomness seed is a well documented attack vector in the blockchain space.

Proof of Code:

  1. Validators can know ahead of time the block.timestamp and can use this information to know when they should open their mystery box to gain the best possible reward.

  2. Players can mine/manipulate their msg.sender value to ensure that they will roll the correct value to earn a rare reward.

  3. Users can revert their MysteryBox::openBox transaction if they don't like the result of the reward the mystery box revealed.

Impact

Any player can predict when they should open their mystery box to guarantee a rare and valuable reward. Players will be able to turn 0.1 eth into a 0.5 or 1 eth reward consistently. Therefore, the protocol will be guaranteed to lose money, as the desired functionality of player's spending 0.1 ether and earning no reward 75% of the time is invalidated.

Tools Used

Manual review & Slither

Recommended Mitigation

Consider using a cryptographically provably 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.

Give us feedback!