Raisebox Faucet

First Flight #50
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Locked Faucet Balance Due to Incorrect Comparison Operator in Token Balance Check

Root + Impact

Description

Normal behavior:
The claimFaucetTokens() function should allow users to claim tokens as long as the faucet contract holds a sufficient token balance equal to or greater than the drip amount (faucetDrip). When the faucet’s remaining token balance exactly equals the claim amount, the claim should succeed, and the faucet should become empty.

Issue:
The current implementation uses the condition balanceOf(address(this)) <= faucetDrip, which incorrectly reverts when the contract balance is exactly equal to the claim amount. As a result, the faucet can become permanently locked with a remaining token balance equal to faucetDrip, preventing the final legitimate claim from being executed.

if (balanceOf(address(this)) <= faucetDrip) { // @> Incorrect operator prevents final valid claim
revert RaiseBoxFaucet_InsufficientContractBalance();
}

Risk

Likelihood:

  • This occurs every time the faucet token balance is exactly equal to the faucetDrip amount.

  • The condition will be met naturally as the faucet balance depletes over time through normal usage.

Impact:

  • The faucet becomes permanently locked with a leftover token balance equal to one full drip.

  • Final users are unable to claim tokens, resulting in poor user experience and inefficient token utilization.

Proof of Concept

// Assume faucet balance = 1000 tokens
// faucetDrip = 1000 tokens
// Function call:
claimFaucetTokens();
// Expected: Successful claim, faucet becomes empty
// Actual: Function reverts due to (balanceOf(address(this)) <= faucetDrip)

Recommended Mitigation

- if (balanceOf(address(this)) <= faucetDrip) {
+ if (balanceOf(address(this)) < faucetDrip) {
revert RaiseBoxFaucet_InsufficientContractBalance();
}

Changing the condition to < allows the last valid claim to execute successfully when the faucet’s token balance equals the drip amount, preventing unnecessary token locking and improving contract usability.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 2 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Off-by-one error in `claimFaucetTokens` prevents claiming when the balance is exactly equal to faucetDrip

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!