In MysteryBox.sol, when a user wants to open a box using openBox() function, a randomValuewill define what prize a user will get. The problem is that randomValuedepends on block.timestampso it can be predicted by deploying a malicious contract that will do the same calculation and delegate the call to `MysteryBox` if `randomValue >= 99` .
Attacker buy a box on `MysteryBox`
Attacker deploys Malicious smart contract that does the guessing of `randomValue`, and if the encode gives a Gold box, it forwards the attacker call to MysteryBox with a delegatecallto keep msg.sender
Attacker calls malicious contract until a guaranteed Gold box is earned
Attacker redeem the value of the box
This attack can be replayed indefinitely and deplete all funds from `MysteryBox`
Malicious contract that will open a box only if it's Gold
An attacker can deplete all the funds without taking any risk by being granted a Gold reward every time he opens a box.
Manual
Do not use block.timestamp to generate a randomNumber
Instead, use chainlink VRF https://chain.link/vrf
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.