Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

contract can be emptied due to a reentrancy issue in `ThePredicter::cancelRegistration`

[H-02] contract can be emptied due to a reentrancy issue in ThePredicter::cancelRegistration

Vulnerability Details

the cancelRegistration function does not follow CEI when calling an external account. this can be used to empty the contract using a smart contract account.

function cancelRegistration() public {
if (playersStatus[msg.sender] == Status.Pending) {
@> (bool success, ) = msg.sender.call{value: entranceFee}("");
require(success, "Failed to withdraw");
@> playersStatus[msg.sender] = Status.Canceled;
return;
}
revert ThePredicter__NotEligibleForWithdraw();
}

Impact

a malicous user can empty the contract using a smartContract Account,

Tools Used

Manual Reivew

Recommendations

Consider following CEI, Checks Effects Interactions:

function cancelRegistration() public {
if (playersStatus[msg.sender] == Status.Pending) {
+ playersStatus[msg.sender] = Status.Canceled;
(bool success, ) = msg.sender.call{value: entranceFee}("");
require(success, "Failed to withdraw");
- playersStatus[msg.sender] = Status.Canceled;
return;
}
revert ThePredicter__NotEligibleForWithdraw();
}
Updates

Lead Judging Commences

NightHawK Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Reentrancy in cancelRegistration

Reentrancy of ThePredicter::cancelRegistration allows a maliciour user to drain all funds.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.