The refund
function is vulnerable to reentrancy attacks, as it can invoke the sendValue
function multiple times.
The refund
function does not adhere to the checks-effects-interactions pattern, which could allow an attacker to steal funds from the contract.
This vulnerability allows anyone to create a malicious smart contract that can invoke the refund
function multiple times using the fallback
or receive
functions. Because the refund
function doesn't follow the checks-effects-interactions pattern, the contract can send the entranceFee
multiple times without changing the state of players[playerIndex]
to address(0)
.
Manual Review
To fix the bug and ensure the function follows the checks-effects-interactions pattern, move the line players[playerIndex] = address(0);
before the line payable(msg.sender).sendValue(entranceFee);
.
Implement the use of ReentrancyGuard.sol
and apply the nonReentrant
modifier to protect the function from reentrancy attacks.
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.