The refund function follows an incorrect Checks-Effects-Interactions pattern. It sends ETH to the caller before updating the state (removing the player from the array).
A malicious contract can implement a receive() or fallback() function that calls refund() again as soon as it receives the first payment. Because the player has not yet been removed from the players list, the contract believes they are still eligible for a refund and sends the ETH again. This loop continues until the raffle's total balance is exhausted.
Any developer with basic knowledge of Solidity exploits can deploy an attacking contract.
No special permissions are required to enter and then call refund().
Total loss of funds: An attacker can steal all the ETH deposited by every other participant in the raffle.
An attacker creates a contract that enters the raffle and then triggers the refund.
Ensure the state is updated before the external call, or use OpenZeppelin's ReentrancyGuard
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.