In the Predicter protocol, players can register by paying an entrance fee set by the betting protocol organizer. After registration, players have the option to cancel their registration. Also, if the number of registered players reaches the maximum limit of 30, the player can also call the cancelRegistration()
function to cancel their registration.
The current implementation has a vulnerability where Ether is sent to the player before updating the state, allowing attackers to exploit this and drain the protocol's funds through repeated registrations and cancellations.
In the ThePredicter contract, attacker can register as a player and call the cancelRegistration()
function to cancel their registration, with the intention of re-entry it since the state is updated after the transfer of the ether.
The vulnerability in the "cancelRegistration()" function poses a high risk of reentrancy attacks. If exploited, an attacker could drain the contract's funds and manipulate its state, leading to financial losses and unintended behaviour within the contract.
Manual Audit
it is best practice to apply the check->effect->interaction for reentrancy.
-- (bool success, ) = msg.sender.call{value: entranceFee}("");
-- playersStatus[msg.sender] = Status.Canceled;
++ playersStatus[msg.sender] = Status.Canceled;
++ (bool success, ) = msg.sender.call{value: entranceFee}("");
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.