The ThePredictor::cancelRegistration
function doesn't have any mechanism to prevent a reentrancy attack and doesn't follow the Checks-Effects-Interactions pattern. Thus it is potentially vulnerable to reentrancy attacks. This is because it first refunds the entrance fee to the msg.sender
and then updates the status of the User. A malicious User contract could re-enter the cancelRegistration
function, manipulate the state before the function execution is completed (before the User's status is updated).
This vulnerability could allow a malicious User contract to drain Ether from the ThePredictor.sol
contract, resulting in a loss of funds for the contract and its users.
VSCode, manual review
To mitigate the reentrancy vulnerability, the Checks-Effects-Interactions pattern should be followed. This pattern advises making all state changes before calling external contracts or sending Ether. In addition consider implementing mutexes or locks, such as a reentrancy guard by OpenZeppelin^[https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol].
Consider making the following changes to the ThePredicter::cancelRegistration
function:
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.