Description
The MysteryBox#withdrawFunds() function allows the owner to withdraw all the ETH stored in the contract, including the funds intended for user rewards. While the function checks that the caller is the owner, it does not differentiate between the contract's operational funds and the reward pool, allowing the owner to withdraw the entire contract balance. This leaves users, who have earned rewards but have not yet claimed them, unable to withdraw their rightful rewards, as the contract's balance would be drained.
Impact
The contract owner can withdraw all the ETH from the contract by calling withdrawFunds(), depleting the funds needed for user rewards. As a result, users who have won rewards but have not claimed them will be unable to withdraw their winnings, leading to a complete loss of trust in the system and financial loss for participants.
Proof of Concept
The MysteryBox the contract starts with a balance of 1 ETH.
Hundreds of users buy mystery boxes and open them, generating rewards like Coal, Bronze Coin, Silver Coin, or Gold Coin.
The contract's balance grows to 1000 ETH, but users have not yet claimed their rewards.
The owner then calls withdrawFunds() and drains the entire 1000 ETH from the contract.
Now, the contract has a zero balance, and users who have unclaimed rewards are left with nothing, as there are no funds left to honour their reward withdrawals.
Proof of Concept (Code Test)
For testing purposes, update this line since the Coal prize does not provide any significant reward, and the chances of getting better rewards are very low.
Recommendation
To prevent the owner from draining the reward pool, it is recommended to:
Separate Operational Funds and Reward Pool: Implement logic to maintain distinct balances for operational funds and user rewards.
Restrict withdrawFunds(): Ensure that the owner can only withdraw operational funds and not funds set aside for rewards.
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.