Mystery Box

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

Predictable implementation of randomness can result in guaranteed 1 ETH rewards for users

Summary

The randomness implementation in the contract is predicatable and can be manipulated in favour of rewards for users.

Vulnerability Details

The randomValue variable is predictable.

Users can observe the block.timestamp and their own address (msg.sender), and since the hashing function keccak256 is deterministic, they can predict the result of the random number before calling openBox().

Impact

Users are able to manipulate the rewards in their favour, resulting in a guaranteed 1 ether for every 0.1 ether purchase of a mystery box.

Tools Used

Manual review

Recommendations

Consider using a more secure source of randomness, such as Chainlink VRF (Verifiable Random Function), to avoid predictability

Updates

Lead Judging Commences

inallhonesty Lead Judge
12 months ago

Appeal created

inallhonesty Lead Judge 11 months 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.