ThePredicter::cancelRegistrationis prone to reentrancy attack due to playerStatuschange after low level .call for entranceFeerefund by cancellation.
ThePredicter::cancelRegistrationfunction checks whether the playersStatus of msg.sender is pending, and if so - refunds him with entranceFee. After that the playersStatus of msg.sender is set to canceled which leaves the function open for reentrancy attack and draining the protocol of its funds.
Create a new file Reentrancy.t.sol in the test folder with the following code
and a new contract in the source - Malicious.sol
Run the forge test --mt testReentrancyAttack in the VSC terminal.
The most direct impact is that an attacker can drain the contract of its funds. By repeatedly calling a function that transfers funds before the contract's state is updated, an attacker can withdraw more funds than they are entitled to. Additionally, as the prize pool consists of the entranceFee funds, it would be impossible to pay to prize to the winners.
Foundry, Manual review
Follow the 'Checks/Effects/Interactions' method by implementing the status change to canceled before the .call for entranceFee refund and/or use reentrancy guard.
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.