The cancelRegistration
function in ThePredicter
Contract contains a potential reentrancy vulnerability. This vulnerability allows an attacker to repeatedly call the function and drain the contract balance by exploiting the order of Logic in the function, leading to a significant financial loss for the contract.
This statement msg.sender.call{value: entranceFee}("") transfers Ether to the caller.
If the caller is a contract with a fallback
function, this fallback
function can call cancelRegistration
again before the initial call completes.
Since the status is updated only after the Ether is sent, the fallback
function can repeatedly call cancelRegistration
and receive multiple transfers of entranceFee
.till it drain the contract's Balance.
Exploit Scenario
An attacker deploys a malicious contract with a fallback
function that calls cancelRegistration
.
The attacker registers with the vulnerable contract and then calls cancelRegistration
to initiate the withdrawal.
The fallback function in the attacker's contract reenters cancelRegistration
before the status update.
This loop continues until the contract's balance is drained.
POC (use this code in ThePredicter.test.sol
)
The reentrancy vulnerability in the cancelRegistration function can have severe financial consequences, including:
Drain Contract Balance: An attacker can repeatedly withdraw the entranceFee amount, draining the contract's balance.
Disruption of Service: Legitimate users may be unable to interact with the contract as intended, leading to loss of trust and potential legal issues.
Manual Review
Use OZ ReentrancyGuard
Follow CEI Pattern as Following
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.