Description:
Reentrancy is a vulnerability in smart contracts where an attacker is able to repeatedly call and re-enter a function within a vulnerable contract, altering the vulnerable contracts state or draining its funds. This vulnerability was found within ThePredicter::cancelRegistration()
function where post registration and prior to being approved as a player, a user is able to maliciously re-enter the function.
Impact:
In this case, being able to re-enter ThePredicter::cancelRegistration()
allows a malicious user to drain smart contract funds.
Tooling:
In this case, reentrancy can be detected using static code analysis tools such as Slither. It is always recommended to supplement the automated tool analysis with a manual code review as it is not guaranteed that more complex instances of this vulnerability will be automatically detected.
Proof of Concept:
The following test function & Attacker contract can be added to ThePredicter.test.sol
to show reentrancy present in ThePredicter::cancelRegistration()
. Use command forge test --match-path test/ThePredicter.test.sol --mt test_reentrancy -vvv
to run the test.
Remediation:
It is recommended to structure code following CEI (Checks - Effects - Interactions). Here, this means rearranging the code in ThePredicter.sol::cancelRegistration()
as follows:
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.