Raisebox Faucet

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

(Extreme Case) user cannot claim if there's one last drip in the faucet

Root + Impact

Description

  • When a user tries to claim tokens, if there's only one last drip, that is, 0.005 ether, in the faucet, then the function "claimFaucetTokens" would revert, preventing the user from claiming it.

// Root cause in the codebase with @> marks to highlight the relevant section
function claimFaucetTokens() public {
// Checks
faucetClaimer = msg.sender;
// (lastClaimTime[faucetClaimer] == 0);
if (block.timestamp < (lastClaimTime[faucetClaimer] + CLAIM_COOLDOWN)) {
revert RaiseBoxFaucet_ClaimCooldownOn();
}
if (faucetClaimer == address(0) || faucetClaimer == address(this) || faucetClaimer == Ownable.owner()) {
revert RaiseBoxFaucet_OwnerOrZeroOrContractAddressCannotCallClaim();
}
if (balanceOf(address(this)) <= faucetDrip) {
//@> should be < instead of <= to allow last drip?
revert RaiseBoxFaucet_InsufficientContractBalance();
}

Risk

Likelihood: Low

  • This will only happen when there's one last drip of token in the faucet, which is not very likely

Impact: High

  • The user won't be able to claim tokens.

Proof of Concept

1. The users make claims of tokens until there is one last drip of token in the contract's balance (0005 ether)

2. One last user tries to claim the token

3. He failed due to the balance check but he should have succeeded.

Recommended Mitigation

function claimFaucetTokens() public {
// Checks
faucetClaimer = msg.sender;
// (lastClaimTime[faucetClaimer] == 0);
if (block.timestamp < (lastClaimTime[faucetClaimer] + CLAIM_COOLDOWN)) {
revert RaiseBoxFaucet_ClaimCooldownOn();
}
if (faucetClaimer == address(0) || faucetClaimer == address(this) || faucetClaimer == Ownable.owner()) {
revert RaiseBoxFaucet_OwnerOrZeroOrContractAddressCannotCallClaim();
}
- if (balanceOf(address(this)) <= faucetDrip) {
+ if (balanceOf(address(this)) < faucetDrip) {
revert RaiseBoxFaucet_InsufficientContractBalance(); //@audit, now would be a good time to mint faucet tokens
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 13 days 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.