Mystery Box

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

`randomValue` in `MysteryBox::openBox` is not random

Relevant GitHub Links

https://github.com/Cyfrin/2024-09-mystery-box/blob/main/src/MysteryBox.sol#L47

Summary

The MysteryBox::openBox function uses block.timestamp and msg.sender to calculate a random value. These values can be manipulated by an attacker to increase their rewards.

Impact

An attacker can manipulate the inputs used for random value calculation, allowing them to receive higher rewards.

Recommendations

Integrate Chainlink VRF for secure random value generation. Implement two functions: one to request the random value (by calling requestRandomWords on the VRF Coordinator contract), and another to store the random value, triggered by the oracle (fulfillRandomWords).

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.