Skip to content
Business logic Audit finding Intermediate

Use safeTransfer instead of transfer

The contract uses the ERC20 transfer function without checking its return value, so a token that returns false instead of reverting would make the contract treat a failed transfer as successful. This could leave funds stuck in the contract.

hack3r-0m Follow

Originally disclosed on Code4rena

Submitted by hack3r-0m, also found by itsmeSTYJ, JMukesh, leastwood, and shenwilly

https://github.com/code-423n4/2021-09-defiProtocol/blob/main/contracts/contracts/Auction.sol#L146

transfer() might return false instead of reverting, in this case, ignoring return value leads to considering it successful.

use safeTransfer() or check the return value if length of returned data is > 0.

frank-beard (Kuiper) confirmed

Alex the Entreprenerd (judge) commented:

Agree with finding, agree with severity given the specific example given as the funds would be stuck in the contract

The original report as published on Code4rena, by hack3r-0m. 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 calls ERC20 transfer without checking its boolean return value, so a false return is treated as success.

Impact

Funds could be stuck in the contract because a failed transfer is treated as successful.

What the attacker needed

Token returns false on failure

The fix

The contract should use safeTransfer or check that the returned data length is greater than zero.

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 tokens signal a failed transfer by returning false rather than stopping with an error. If the contract ignores that false, it thinks the money moved when it did not, so the funds can get stuck. Using a safe transfer helper or checking the result prevents this.

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 hack3r-0m

View all

3 more disclosed reports, best first.

More from Kuiper 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.