ThePredicter::cancelRegistration
The vulnerability exists within the cancelRegistration function in the following code segment:
The function first sends entranceFee
to msg.sender
using a low-level call, and then updates the player's status to Status.Canceled
. This sequence of actions is problematic because the external call to msg.sender
can potentially trigger malicious fallback functions that reenter the cancelRegistration
function before the player's status is set to Status.Canceled
. This reentrancy could allow attackers to repeatedly withdraw the entranceFee
.
If exploited, the reentrancy vulnerability could drain the contract of its funds, as attackers would be able to withdraw the entranceFee
multiple times. This would result in significant financial loss for the protocol and its users.
Below is a proof of concept using Foundry to test the vulnerability:
In this test:
To mitigate the reentrancy vulnerability, the player's status should be updated before making the external call. This ensures that even if a reentrant call is made, the player's status will already be set to Status.Canceled
, preventing further withdrawals. Here is the updated function:
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.