Description: MysteryBox can grant a user to claim a box randomly and that user can open the box and claim the hidden rewards within using MysteryBox::claimAllRewards function.
This reward can vary from 1 ether to 0 ether. A user can buy this box using 0.1 ether and claim its rewards using the contracts protocols.But if a user gets a reward which is much more than the contract holds in it, then the contract fails to deliver that reward to the user.
Impact: A user can buy box using only 0.1 ether. And if he is lucky enough he gets a reward exceeding his bought amount (which is a rare case and most likely to happen only once),he will try to claim it using the MysteryBox::claimAllRewards function. But if the contract doesn't hold that much ether in it at that time, the user will surely fail to get this reward at that time and lose his trust in the protocol
Proof of Concept: Here is a proof of code given below along with its output
Output:
Recommended Mitigation:
By making sure that the contract holds enough eth before distributing rewards will mitigate this issue.
Adding a certain minimum timestamp before distributing rewards may also help to mitigate this .
Tools Used: Manual Review
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.