ERC20 tokens with no return value will fail to transfer
The contract uses the standard ERC20 transfer function, which expects a boolean return value. Many tokens, including USDT, do not return a value, so the transfer call reverts even when the transfer would succeed, causing the contract to fail to transfer those tokens.
Submitted by ych18, also found by wuwe1
Vulnerability details
Although the ERC20 standard suggests that a transfer should return true on success, many tokens are non-compliant in this regard (including high profile, like USDT) . In that case, the .transfer() call here will revert even if the transfer is successful, because solidity will check that the RETURNDATASIZE matches the ERC20 interface.
Recommendation
Consider using OpenZeppelin’s SafeERC20
sofianeOuafir (Joyn) confirmed and commented:
duplicate of #52
deluca-mike (judge) commented:
Actually not a duplicate of #52, since it pertains to return data size handling causing an issue, rather than failure to handle a true/false return at all. Still, same solution (use SafeERC20).
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
Root cause
The contract calls the ERC20 transfer function directly, which assumes the token returns a boolean, but many tokens do not return any data, causing the call to revert.
Impact
The contract cannot transfer tokens that do not return a boolean, so any functionality relying on such transfers will fail.
What the attacker needed
Contract holds or handles non-standard ERC20 tokens
The fix
The contract should use OpenZeppelin's SafeERC20 library, which handles tokens that do not return a boolean.
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 digital tokens (like USDT) don't follow the full ERC20 standard: when you ask them to transfer, they don't send back a 'yes' or 'no' answer. The contract here expects that answer, so it treats the missing answer as an error and cancels the transfer. This means the contract can't handle those tokens at all.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.