cancelRegistration
FunctionSummary:
The ThePredicter:cancelRegistration
function does not follow the C-E-I pattern, making this contract vulnerable to a Re-Entrancy Attack.
Vulnerability Details:
The ThePredicter:cancelRegistration
function makes an external call without updating the state. A malicious contract can be deployed to join as a player and then cancel its participation, which sends entrance fees to the contract's receive function where it can again call the cancelRegistration
function until the contract is drained.
Proof of Concept:
A test was conducted to demonstrate the issue:
Step 1: Create an Attacker contract
Step 2: Deploy Attacker and call the attack function
After calling the attack, the contract registers itself as a user and then cancels in the same call, so the organizer can't approve its registration. If the organizer approves the transaction, the attacker can't withdraw.
Impact:
High
Tools Used:
Manual review
Foundry
Recommendations:
Follow the Checks-Effects-Interactions (C-E-I) design pattern:
Remove the following:
Add the 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.