Use safeTransfer instead of transfer
The contract called the ERC20 transfer function without checking its return value, so a token that returns false on failure would not be detected. An attacker could exploit this to make transfers appear successful when they actually failed, potentially causing loss of funds or incorrect accounting.
Submitted by shw
Tokens not compliant with the ERC20 specification could return false from the transfer function call to indicate the transfer fails, while the calling contract would not notice the failure if the return value is not checked. Checking the return value is a requirement, as written in the EIP-20 specification:
Callers MUST handle
falsefromreturns (bool success). Callers MUST NOT assume thatfalseis never returned!
Recommend using the SafeERC20 library implementation from OpenZeppelin and calling safeTransfer or safeTransferFrom when transferring ERC20 tokens.
alcueca (Yield) confirmed and patched:
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 did not check the boolean return value of the ERC20 transfer call, violating the EIP-20 requirement to handle false returns.
Impact
A token that returns false on transfer failure could cause the contract to not notice the failure, potentially leading to incorrect state or loss of funds.
What the attacker needed
None
The fix
The fix was to use OpenZeppelin's SafeERC20 library and call safeTransfer or safeTransferFrom instead of transfer.
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 (ERC20 tokens) have a transfer function that returns a true or false value to say if the transfer worked. If a smart contract ignores that returned value, it might think a transfer succeeded even when it failed. This can lead to problems like the contract losing track of funds or allowing someone to take advantage.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.