Skip to content
Business logic Audit finding Intermediate

Result of transfer / transferFrom not checked

The smart contract calls ERC20 transfer and transferFrom functions without checking their return values. For tokens that return false instead of reverting on failure, an attacker could mint tokens without actually transferring the required tokens, potentially causing loss of funds.

gpersoon Follow

Originally disclosed on Code4rena

Submitted by gpersoon, also found by jonah1005, zer0dot, 0xRajeev, JMukesh, cmichel, k, shw, 7811, heiho1 and maplesyrup.

A call to transferFrom or transfer is frequently done without checking the results. For certain ERC20 tokens, if insufficient tokens are present, no revert occurs but a result of “false” is returned. It’s important to check this. If you don’t, you could mint tokens without have received sufficient tokens to do so and could loose funds. Its also a best practice to check this.

Recommend always checking the result of transferFrom and transfer.

verifyfirst (Spartan) confirmed:

The intention was to not allow non-standard tokens with non-boolean returns however in the interest of future proofing the protocol we agree with this issue

ghoul-sol (judge) commented:

There are a lot of reported issues in relation of non-standard ERC20 and transfer return values. Some wardens report it all in one issue, some divided it into multiple issues. To keep playing field equal, I’ll keep one issue per warden and make others invalid.

The original report as published on Code4rena, by gpersoon. 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 contract fails to verify the boolean return value of ERC20 transfer and transferFrom calls, so it does not detect failed transfers for tokens that return false instead of reverting.

What the attacker needed

The contract uses ERC20 tokens that return false on failure; The contract does not check transfer return values

The fix

The contract should always check the return value of transfer and transferFrom calls and revert if the returned value is false.

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 don't stop a transaction when a transfer fails; they just return a 'false' value. If a smart contract ignores that 'false', it might think a payment succeeded when it didn't, letting someone get tokens for free. This is like a shop not checking if your credit card was actually charged before giving you the goods.

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.

More by gpersoon

View all

47 more disclosed reports, best first.

More from Spartan Protocol Contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.