Users might lose funds as `claimERC20Prize()` doesn't revert for no-revert-on-transfer tokens
The claimERC20Prize function does not check the return value of ERC20 transfer, so with no-revert-on-failure tokens a failed transfer still increases the user's claimed amount, making those tokens permanently unclaimable.
0xAsen Follow with 0xGoodess, 0xGusMcCrae and 47 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-04-footium-judging/issues/86
Found by
0xAsen, 0xGoodess, 0xGusMcCrae, 0xPkhatri, 0xRobocop, 0xStalin, 0xeix, 0xmuxyz, 0xnirlin, 14si2o_Flint, 8olidity, ACai7, AlexCzm, BAHOZ, Bauchibred, Bauer, Cryptor, DevABDee, Diana, GimelSec, J4de, Koolex, MiloTruck, PRAISE, PTolev, Phantasmagoria, Piyushshukla, PokemonAuditSimulator, Polaris_tow, Proxy, Quantish, R-Nemes, SanketKogekar, Sulpiride, TheNaubit, Tricko, __141345__, abiih, alliums8520, ast3ros, berlin-101, cergyk, ctf_sec, cuthalion0x, dacian, ddimitrov22, deadrxsezzz, djxploit, favelanky, georgits, holyhansss, innertia, jasonxiale, josephdara, jprod15, kiki_dev, l3r0ux, lewisbroadhurst, nzm_, oot2k, oualidpro, peanuts, ravikiran.web3, sach1r0, santipu_, sashik_eth, shaka, shame, thekmj, tibthecat, tsvetanovv, whoismatthewmc1, wzrdk3lly, yy
Summary
Users can call claimERC20Prize() without actually receiving tokens if a no-revert-on-failure token is used, causing a portion of their claimable tokens to become unclaimable.
Vulnerability Detail
In the FootiumPrizeDistributor contract, whitelisted users can call claimERC20Prize() to claim ERC20 tokens. The function adds the amount of tokens claimed to the user's total claim amount, and then transfers the tokens to the user:
FootiumPrizeDistributor.sol#L128-L131
if (value > 0) {
totalERC20Claimed[_token][_to] += value;
_token.transfer(_to, value);
}
As the the return value from transfer() is not checked, claimERC20Prize() does not revert even when the transfer of tokens to the user fails.
This could potentially cause users to lose assets when:
_tokenis a no-revert-on-failure token.- The user calls
claimERC20Prize()withvaluehigher than the contract's token balance.
As the contract has an insufficient balance, transfer() will revert and the user receives no tokens. However, as claimERC20Prize() succeeds, totalERC20Claimed is permanently increased for the user, thus the user cannot claim these tokens again.
Impact
Users can call claimERC20Prize() without receiving the token amount specified. These tokens become permanently unclaimable for the user, leading to a loss of funds.
Code Snippet
Tool used
Manual Review
Recommendation
Use safeTransfer() from Openzeppelin's SafeERC20 to transfer ERC20 tokens. Note that transferERC20() in FootiumEscrow.sol also uses transfer() and is susceptible to the same vulnerability.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
Users could lose funds because claimed tokens become permanently unclaimable.
What the attacker needed
A no-revert-on-failure token; claim value exceeds contract balance
The fix
Use SafeERC20's safeTransfer to transfer ERC20 tokens, and apply the same fix to transferERC20 in FootiumEscrow.sol.
How it was found
- A no-revert-on-failure token is used.
- The user calls claimERC20Prize with a value higher than the contract's token balance.
- The transfer fails but does not revert, so the claimed amount is increased and the user receives no tokens.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some tokens do not revert when a transfer fails; they just return false. The contract ignores that false and still records the claim as successful, so the user cannot try again.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.