Mystery Box

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

`MysteryBox::openBox` use a on-chain random number, it's not really random

Summary

In uint256 randomValue = uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 100; looks like this protocol use timestamp & msg.sender to keccak a hash, then make it a range between 0 to 99.

Vulnerability Details

remix example
refer

Impact

It actually not really random, miner can calculate the outcome, then decide to mine the block or not.
They will mine the block until the rarity reach the biggest reward, so that they can easily make profit.

Tools Used

slither

Recommendations

Do not use on-chain data as random number, use protocol such as chainLink.

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!