Mystery Box

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

[EVMN] Pseudo-random Prone To Precalculation

Summary

Generating a random value from on-chain information allows a user to pre-calculate a preferable value for them.

Vulnerability Details

The code on line 47 below is prone to user pre-calculation.

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

A user can pre-calculate the randomValue to get the number they prefer before calling function openBox(). The user can either time their function call or use the right sender address.

Impact

The randomValue can be guessed so the user always gets the maximum reward.

Tools Used

Manual review.

Recommendations

Consider using a verifiable random function (VRF) service to generate a 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!