https://github.com/Cyfrin/2024-09-mystery-box/blob/main/src/MysteryBox.sol#L92-L101
The MysteryBox::claimSingleReward
function does not follow the CEIFREI-PI principles, and, as a result, enables participants to drain the contract balance.
In the current implementation of MysteryBox::claimSingleReward
, rewards are transferred first, and only then is rewardsOwned[msg.sender][_index]
reset.
A malicious player who has participated in the prediction could have a fallback
or receive
function that triggers the MysteryBox::claimSingleReward
function again, allowing them to claim multiple refunds. They could repeat this process until the contract’s balance is completely drained.
All the funds paid by players could be stolen by a malicious actor.
To resolve this issue, the MysteryBox::claimSingleReward
function should update the rewardsOwned
array before making any external calls:
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.