Skip to content
Business logic Audit finding Intermediate

Unsafe handling of underlying tokens

The contract does not check the return value of ERC20 transferFrom calls, so a token that returns false instead of reverting can be used to initiate a trade without actually transferring the underlying tokens.

0xsanson Follow

Originally disclosed on Code4rena

Submitted by 0xsanson, also found by 0xRajeev, cmichel, defsec, GalloDaSballo, JMukesh, leastwood, loop, nikitastupin, pants, and pauliax.

Impact

Not every ERC20 token follows OpenZeppelin’s recommendation. It’s possible (inside ERC20 standard) that a transferFrom doesn’t revert upon failure but returns false.

The code doesn’t check these return values. For example uToken.transferFrom(msg.sender, o.maker, a); in initiateVaultFillingZcTokenInitiate can be exploited by the msg.sender to initiate a trade without sending any underlying.

Proof of Concept

grep 'transfer' Swivel.sol

Tools Used

editor

Recommended Mitigation Steps

Consider using OpenZeppelin’s library with safe versions of transfer functions.

The original report as published on Code4rena, by 0xsanson. 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 transferFrom without verifying its boolean return value, so a token that returns false on failure is treated as successful.

Impact

An attacker could initiate a trade without sending any underlying tokens, potentially obtaining the trade's benefits without paying.

What the attacker needed

A token that returns false on failed transferFrom; ability to call initiateVaultFillingZcTokenInitiate

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 (ERC20) can fail a transfer by returning 'false' instead of stopping with an error. If a smart contract does not check that return value, it may think the transfer succeeded when it did not. An attacker can then start a trade without actually sending the tokens they were supposed to.

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 0xsanson

View all

8 more disclosed reports, best first.

More from Swivel v3 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.