After a user is registered they can withdraw the paid entrance fee by calling ThePredicter.cancelRegistration
. The lack of playersStatus[msg.sender]
updates before calling msg.sender.call
, lead a malicious Smart contract user to reenter the function and withdraw the ThePredicter
balance.
The function ThePredicter.cancelRegistration
calls msg.sender.call{value: entranceFee}("");
and only after the call updates the player status. If the player is a Smart Contract, when receiving the entranceFee
, it can call again ThePredicter.cancelRegistration
during the same transaction (inside a receive
or fallback
function) and withdraw the ThePredicter
balance.
A registered player can withdraw the entire ThePredicter
contract balance. Other players cannot withdraw their fee by calling cancelRegistration
.
Add the following unit-test at the end of the ThePredicter.test.sol
file. In the PoC, another user (stranger
) is registered to increase the balance of the ThePredicter
account and to demonstrate that after the attack, other players are not able to withdraw the paid fee.
Manual code review
Apply the Checks-Effects-Interactions pattern:
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.