The openBox
function in the MysteryBox
contract relies block.timestamp for calculating the random value. This approach is insecure as the block timestamp is both predictable and manipulatable.
Relevant code - Randomness
The openBox
function generates randomness using two predictable values: block.timestamp
and msg.sender
. An attacker can exploit this by calculating the same hash in advance. By testing various block.timestamp
values, they can determine when the most valuable rewards will be triggered. Additionally, by monitoring the mempool, the attacker can observe pending transactions and compute the potential outcomes before they are mined, allowing them to know market impacts beforehand and take advantage.
In existing test suite, add following test
By eliminating the “luck” factor associated with reward distribution, attackers can effectively choose any reward they want.
Manual Review, Foundry
Use ChainLink's VRF to get random values.
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.