Skip to content
Business logic Audit finding Beginner

Use safeTransferFrom() instead of transferFrom()

The contract used ERC20 transfer and transferFrom without checking their boolean return values, so failed transfers could be treated as successful. Tokens that do not return a boolean, such as USDT, would cause transactions to revert, making them unusable in the protocol.

Nyx Follow with 0x4non, yixxas and 2 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-dodo-judging/issues/47

Found by

Nyx, 0x4non, yixxas, Tomo, sach1r0

Summary

The ERC20.transfer() and ERC20.transferFrom() functions return a boolean value indicating success. This parameter needs to be checked for success. Some tokens do not revert if the transfer failed but return false instead.

Vulnerability Detail

Some tokens (like USDT) don't correctly implement the EIP20 standard and their transfer/ transferFrom function return void instead of a success boolean. Calling these functions with the correct EIP20 function signatures will always revert.

Impact

Tokens that don't actually perform the transfer and return false are still counted as a correct transfer and tokens that don't correctly implement the latest EIP20 spec, like USDT, will be unusable in the protocol as they revert the transaction because of the missing return value.

Code Snippet

https://github.com/sherlock-audit/2022-11-dodo/blob/main/contracts/SmartRoute/DODORouteProxy.sol#L420

https://github.com/sherlock-audit/2022-11-dodo/blob/main/contracts/SmartRoute/DODORouteProxy.sol#L423

Tool used

Manual Review

Recommendation

Recommend using OpenZeppelin's SafeERC20 versions with the safeTransfer and safeTransferFrom functions that handle the return value check as well as non-standard-compliant tokens.

Discussion

Evert0x

We think a medium is still valid, although no direct loss of funds, a failed token transfer should be catched.

Attens1423

https://github.com/DODOEX/dodo-route-contract/pull/4

aktech297

Fixes are verified. Contract is using openzeppelin's safeTransfer.

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

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 called ERC20 transfer and transferFrom directly without checking their return values and without handling tokens that do not return a boolean.

Impact

A failed token transfer could be counted as successful, and tokens that do not return a boolean, such as USDT, could not be used in the protocol because transactions would revert; the team noted no direct loss of funds.

What the attacker needed

None

The fix

The contract was fixed to use OpenZeppelin's SafeERC20 safeTransfer and safeTransferFrom, which check the return value and support non-standard tokens.

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 report whether a transfer worked by returning true or false, but the contract ignored that answer. If a transfer quietly failed, the contract still acted as if it had succeeded. Also, some tokens like USDT do not return any answer at all, so the contract's attempt to read one made the whole transaction fail.

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 Nyx

View all

5 more disclosed reports, best first.

More from DODO V3 update

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.