The claimFaucetTokens function is designed to allow users to claim a fixed amount of tokens (1000) and, for first-time claimers, drip 0.005 ETH from the contract, updating state variables like hasClaimedEth and dailyClaimCount afterward.
* The specific issue is that the low-level call to send ETH occurs before state updates, enabling an attacker to reenter the function via a malicious contract, claiming additional tokens before the state is fully updated, effectively doubling their claims per transaction.
Likelihood:
Deployment of a malicious contract interacting with the faucet
Execution of the claim function by an attacker with reentrancy logic
Impact:
Doubling of token claims per transaction, accelerating faucet depletion
Could lead to significant financial loss if the contract holds substantial ETH or tokens, bypassing the intended drip limit (0.005 ETH per claim).
By adding these onto the test suite we can see this outcome:
We get this output by doing forge test --mt testClaimFaucetReentracy -vvv:
Signifying that a Reentrancy is possible and that the function is not properly protected.
These are the recommended mitigations:
Additionally, ensure all state-changing operations (e.g., hasClaimedEth, dailyClaimCount) are completed before any external calls to prevent partial state updates.
Consider adding a checks-effects-interactions pattern by moving the ETH transfer after all state updates and using a pull-over-push mechanism for ETH distribution to avoid direct calls.
Implement a maximum claim limit per address or transaction to cap potential damage from reentrancy exploits.
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.