Reentrancy can occur in the PuppyRaffle::refund
function
A reentrancy issue can happen in the refund
function when the entranceFee
is sent to the participant. Basically, we are transferring the fee amount to the msg.sender
and after that, we are setting the address of the msg.sender
to zero in the players array. This is an issue since we are not using the CEI pattern and not updating the players array before transferring the value.
This will cause loss of funds for the protocol
Manual Review
The best practice here is to apply correctly the CEI pattern (Checks Effects Interactions): update the players array by removing the player from the array, and do not set its initial address value to zero. Also, here it is better to use .call{value: entranceFee}("");
instead of '.sendValue(entranceFee)', and after that check the status of the call with a require statement. You can also consider adding a nonReentrant
modifier.
reentrancy in refund() function
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.