The function cancelRegistration() contains a reentrancy issue because it does not confirm the Check-Effect-Interaction (CEI) pattern.
A malicious party could write a contract that poses as a player to call register()
then cancelRegistration()
to drain all the fund collected by the ThePredicter
contract. The attack is successful when the following condition holds:
The register()
call is successful.
The playersStatus
of the malicious contract is Status.Pending
All the funds in `ThePredicter` contract could be drained and thus the issue is labeled as critical (high impact, high likelihood).
Testing, manual analyses
Implement CEI pattern by changing the playersStatus to Status.Canceled
before sending the fund back.
We have an attacker contract as follows:
Then we demonstrate the issue using the following test:
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.