ThePredicter::cancelRegistration
function allows registered users that have not been upgraded to players to cancle their registration and withdraw their entrance fee. The current implementation is vulnerable to reentrancy attacks because the state update occurs after the external call to msg.sender.call
.The cancelRegistration() in the ThePredicter contract is vulnerable to reentrancy attacks. An attacker can exploit this vulnerability to withdraw more funds than intended by recursively calling cancelRegistration() within the fallback function.
call to msg.sender.call{value: entranceFee}("") allows control to be transferred to an external contract, which can recursively call cancelRegistration before playersStatus[msg.sender] is set to Status.Canceled.
Root Cause
call to msg.sender.call{value: entranceFee}("") allows control to be transferred to an external contract, which can recursively call cancelRegistration before playersStatus[msg.sender] is set to Status.Canceled.
ReentrancyAttack.sol
Test file: Reentrancy.test.sol
On the terminal Run: forge test --mt testReentrancyOnCancelReg
An attacker can drain the contract’s funds by repeatedly calling cancelRegistration, leading to significant financial loss.
Manual Review
Reentrancy of ThePredicter::cancelRegistration allows a maliciour user to drain all 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.