Mystery Box

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

Bad random generator

Summary

The random value generation in the openBox function is easily predicatble making it an easy target for malicious users

Vulnerability Details

In the function openBox there is the randomvalue that is being generated by the following line of code:

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

A malicious user could easily predict with his address at what timestamp they should call the function to get thge maximum rewards

Impact

Since the logic of the contract depends on that randomness i would say that the impact on the trust and the logic of the contract is huge.

Tools Used

Manual

Recommendations

There are a few good way to create random values but i would recommend finding another way to chose between rewards and not through randomness.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago

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!