The function ThePredicter::cancelRegistration
is intended to allow a user who has attempted to register, but has not yet been approved by the Organizer, to cancel their registration request and receive a refund of the entranceFee
paid during the registration request. However, there is an issue in the mentioned function because the CEI (Check-Effects-Interactions) rule is not followed, which has opened up the possibility for a known reentrancy attack. Specifically, during the refund of the entranceFee
, the funds are first sent to the user, and only then is the state updated. Before this update, when the funds are refunded, the user's receive or fallback function is triggered, which a malicious user can exploit to call the same function again with the protocol state unchanged.
This type of attack will result in the malicious user draining funds that belonged to other users and the protocol.
Add the following code to the test/ThePredicter.Test.sol
file:
Follow CEI (Check, Effect, Interaction) rule!
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.