MysteryBox
contract is vulnerable to reentrancy attacks. This is because it first sends Ether to msg.sender and then updates the state of the contract. A malicious contract could re-enter the function before the state is updated.
The functions claimAllRewards
and claimSingleReward
doesn't have any mechanism to prevent a reentrancy attack and doesn't follow the Check-effects-interactions pattern.
If exploited, this vulnerability could allow a malicious contract to drain Ether from the MysteryBox
contract, leading to loss of funds for the contract and its users.
We create a malicious contract that buys a box and then uses its receive function to repeatedly claims reward before the MysteryBox
contract has a chance to update its state.
To mitigate the reentrancy vulnerability, you should follow the Checks-Effects-Interactions pattern. This pattern suggests that you should make any state changes before calling external contracts or sending Ether.
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.