The claimFaucetTokens function makes an external call to transfer ETH before completing all state updates, violating the Checks-Effects-Interactions (CEI) pattern. This creates a reentrancy vulnerability that allows malicious contracts to drain tokens and ETH from the faucet.
The normal and secure behavior following the CEI pattern is to complete ALL state changes before making any external calls. This prevents reentrancy attacks where the called contract can call back into the function before state is finalized.
The critical issue occurs when the function transfers ETH via .call{value} at line 197, but crucial state variables like lastClaimTime[faucetClaimer] (line 226) and dailyClaimCount (line 227) are only updated AFTER this external call. This means during the external call, the contract state still reflects the old values, allowing a malicious contract's receive/fallback function to reenter claimFaucetTokens and potentially claim multiple times before the cooldown is set.
Likelihood:
An attacker must deploy a malicious smart contract with a crafted receive() or fallback() function
The attacker's contract must be called as a first-time claimer to receive the ETH drip
The attack is technically straightforward for anyone with Solidity knowledge
Requires some setup but is easily achievable
Impact:
Attacker can bypass the 3-day cooldown period through reentrancy
Can potentially claim tokens multiple times in a single transaction
Daily claim limits could be circumvented
Could drain the faucet's entire token supply and ETH balance
Complete loss of funds for the protocol
Faucet becomes unusable for legitimate users
This demonstrates a reentrancy attack that bypasses the cooldown and claims tokens multiple times in one transaction.
Implement OpenZeppelin's ReentrancyGuard to prevent reentrancy attacks. This adds a mutex lock that prevents a function from being called again while it's still executing.
Alternatively, strictly follow the Checks-Effects-Interactions pattern by moving ALL state updates before external calls.
Additionally, consider moving state updates before external calls:
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.