Skip to content
Smart contracts Audit finding Intermediate

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.

robee Follow

Originally disclosed on Code4rena

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

  1. 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.

0xKiwi (NFTX) resolved

LSDan (judge) decreased severity to medium and commented:

This is medium risk, not high. Loss of funds requires external factors.


The original report as published on Code4rena, by robee. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by robee

View all

6 more disclosed reports, best first.

More from NFTX contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.