claimTokenFaucets is vulnerable to front-running attacks due to predictable state checksExpected bahaviour Token claims should be processed in a sequential, deterministic way (first-come first-serve basis). It should not be possible front-runners observing the mempool to bypass a submitted transaction when the daily ETH cap (dailySepEthCap) or daily count limit (dailyClaimCount) is about to be reached.
Problematic bahaviour Front-runners can monitor the state variables dailyDrips and dailyClaimCount. Once the claim limit is about to be exhausted (dailySepEthCap, dailyClaimCount) they can front-run an existing transaction in the mempool so that they receive the remaining ETH / tokens before the threshold is reached.
Root cause
The root cause of the front-running vulnerability is the predictability of the checks and the final state variable values in the claimFaucetTokens function:
Likelihood: High
This exploit can happen on a daily basis when the faucet is about to reach the daily thresholds. It is a technically simple attack to carry out.
Impact: Medium
The front-running attacks will impact user experience at times when the daily thresholds are about to be reached.
Legitimate user transactions will be rejected (DoS).
Unfair advantage to sophisticated actors.
Given that Foundry processes transactions sequentially and a PoC will not be able to simulate a real front-running scenario, consider the following thought experiment:
The daily faucet token claim limit is 100.
99 users successfully submit their token claims.
The 100th user calls claimFaucetTokens and their transaction sits in the mempool.
Front-runner sees this pending transaction and observes that there is only one remaining allowed token claim.
They submits their own transaction with higher gas fees.
Since validators prioritize higher gas fees, the front-runner's transaction is executed first.
Front-runner receives tokens.
The legitimate user's transaction is reverted with the error RaiseBoxFaucet_DailyClaimLimitReached (denied service).
A Request-based system with onlyOwner protection in processBatch method could be used to mitigate front-running attacks:
Other solutions include commit-reveal schemes or using a private mempool.
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.