Expected bahaviour The owner should be able to burn the token amount specified as input in the burnFaucetTokens method, leaving the rest of the token balance untouched in the faucet.
Problematic bahaviour The owner burns the token amount specified as input in the burnFaucetTokens method, but in the process transfers the whole token balance to themselves, leaving the faucet completely empty.
Root cause:
Likelihood: Medium
This bug occurs whenever the owner burns tokens via the burnFaucetTokens method.
Impact: Medium
The faucet stops processing claims entirely, breaking the faucet's intented functionality.
Add the following fuzz test to the Foundry test suite and run with forge test --mt test_burnFaucetTokens_TransfersAllTokens --fuzz-runs 1000.
Get faucet contract balance before calling burn.
Owner calls the burn function with an amount lower than the totak token balance.
Get faucet contract balance again.
Assert that there are no tokens left in the faucet even though the amount to burn was lower than the faucet balance.
Assert that all subsequent calls to claimFaucetTokens revert.
To mitigate this issue
A) Do not transfer the tokens to the owner at all, and burn the required amount directly from the contract's address:
or alternatively, if the transfer to the owner is needed:
B) Transfer the amountToBurn instead of balanceOf(address(this)))
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.