Description: In MysteryBox::claimSingleReward function, there is a reentrancy vulnerability which can be exploited by a bad actor.
Impact: MysteryBox contract can end up losing all the funds if this vulnerability is exploited.
Proof of Concept:
Attacker buys a Mystery box via an attack contract.
Attacker claims the mystery box and manages to score a reward with non zero ETH.
Attacker calls MysteryBox::claimSingleReward from their attack contract, draining the contract balance.
Proof of Code
For the sake of demonstraction, set the Coal reward value in the MysteryBox::constructor and MysteryBox::openBox function to 0.1 ether
Place the folowing into TestMysteryBox.t.sol
And this contract as well.
Recommended Mitigation: Update the state of MysteryBox::rewardsOwned variable before initiating the external call to transfer funds
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.