transfer return value is ignored
The smart contracts use the ERC20 transfer and transferFrom functions without checking their return values. Some tokens return false instead of reverting on failure, so a failed transfer could go unnoticed, potentially leading to loss of funds.
Submitted by robee, also found by 0x1f8b, cmichel, csanuragjain, defsec, hyh, leastwood, sirhashalot, and WatchPug
Need to use safeTransfer instead of transfer. As there are popular tokens, such as USDT that transfer/transferFrom method doesn’t return anything. The transfer return value has to be checked (as there are some other tokens that returns false instead revert), that means you must
- Check the transfer return value
Another popular possibility is to add a whiteList. Those are the appearances (solidity file, line number, actual line):
NFTXStakingZap.sol, 401, IERC20Upgradeable(vault).transfer(to, minTokenIn-amountToken);
NFTXStakingZap.sol, 474, IERC20Upgradeable(token).transfer(msg.sender, IERC20Upgradeable(token).balanceOf(address(this)));
PalmNFTXStakingZap.sol, 190, pairedToken.transferFrom(msg.sender, address(this), wethIn);
PalmNFTXStakingZap.sol, 195, pairedToken.transfer(to, wethIn-amountEth);
PalmNFTXStakingZap.sol, 219, pairedToken.transferFrom(msg.sender, address(this), wethIn);
PalmNFTXStakingZap.sol, 224, pairedToken.transfer(to, wethIn-amountEth);
PalmNFTXStakingZap.sol, 316, IERC20Upgradeable(vault).transfer(to, minTokenIn-amountToken);
XTokenUpgradeable.sol, 54, baseToken.transfer(who, what);
NFTXFlashSwipe.sol, 51, IERC20Upgradeable(vault).transferFrom(msg.sender, address(this), mintFee + targetRedeemFee);
0xKiwi (NFTX) confirmed, but disagreed with high severity and commented:
Disagreeing with the severity, but will make sure I stick to safeTransferFrom, thank you.
LSDan (judge) decreased severity to medium and commented:
This is medium risk, not high. Loss of funds requires external factors.
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 code calls transfer and transferFrom without verifying the boolean return value, so a false return is ignored.
Impact
A failed token transfer could go unnoticed, potentially leading to loss of funds, though the judge noted this requires external factors.
What the attacker needed
Token returns false on failure
The fix
The contracts should use safeTransfer and safeTransferFrom, or otherwise check the return value of transfer calls.
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 report success or failure by returning a true or false value. If a contract ignores that value, it might think a transfer worked when it actually failed. This could cause tokens to be lost or accounting to be wrong.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.