Description: The mystery box costs 0.1 ether to buy and the highest reward as per the default configuration is 0.5 ether. Additionally, owner of the contract can also draw funds out from the contract. This leads to a scenario where the reward value can be greater than the available funds. This will cause the MysteryBox::claimAllRewards and MysteryBox::claimSingleReward functions to fails.
Impact: Shortage of funds will cause MysteryBox::claimAllRewards and MysteryBox::claimSingleReward functions to fails.
Proof of Concept:
Contract owner deploys the contract.
User A buys a mystery box for 0.1 ether.
They call MysteryBox::openBox and win a Gold Coin reward which is equivalent to 1 ether.
User A proceeds to withdraw the funds by calling either MysteryBox::claimAllRewards or MysteryBox::claimSingleReward function.
The call will fail as the contract currently has 0.2 ether in total. 0.1 from the contract deployment and 0.1 from the box fee that User A paid.
Recommended Mitigation: Add a check to verify that the balance of the MysteryBox contract is enough to make the payment.
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.