Mystery Box

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

Users can get more rewards via the predictable randomValue

Summary

Users can get more rewards via the predictable randomValue

Vulnerability Details

In MysteryBox, users can open box, generate one random value. Users can get some related rewards according to the random value. But the problem is that the random value is calculated base on timestamp & msg.sender's address.
Users can pre-calculate the random value, and choose to open this box in one specific timestamp to get the maximum rewards.

function openBox() public {
require(boxesOwned[msg.sender] > 0, "No boxes to open");
// Generate a random number between 0 and 99
// @audit the random value can be calculated. Users can open box in one specific timestamp to get one higher value to get more rewards.
// randomeValue's range is from 0 - 99.
uint256 randomValue = uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 100;

Impact

Random value is predictable. Users can always win this game.

Tools Used

Manual

Recommendations

Consider to user VRF to generate one random value.

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!