A critical vulnerability has been discovered in the ThePredicter
smart contract that allows a re-entrancy attack. This vulnerability occurs in the cancelRegistration
function, where an external call to transfer Ether back to the user is made before updating the user's status, potentially allowing the attacker to recursively call the function and withdraw funds multiple times.
The re-entrancy attack is possible due to the order of operations in the cancelRegistration
function. Specifically, the contract attempts to transfer Ether back to the user via an external call before updating the user's status. This allows a malicious contract to exploit the re-entrancy vulnerability by recursively calling cancelRegistration
during the execution of the external call.
Number of instances : 1
This is the test code of reentrancy attack.
To test this code:
Input this code to new test solidity file: test/Attack.test.sol
.
Then run this command:
forge test --match-path test/Attack.test.sol --match-test testAttack -vvvv
The result is:
The exploitation of this vulnerability can lead to:
Unauthorized Fund Withdrawals: An attacker can repeatedly withdraw the entrance fee, draining the contract’s funds.
Financial Loss: Significant financial loss for the contract owner and other participants.
Loss of Trust: Users may lose confidence in the security of the platform.
Manual code review
Just follow CEI pattern and wrap register()
function and cancelRegistration()
with nonReentrant
modifier.
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.