Skip to content
Business logic Audit finding Intermediate

Failed transfer with low level call won’t revert

A low-level call in the swap function can return success even when the target contract does not exist, so a failed swap does not revert. An attacker could use this to make a user's funds be transferred to the contract without receiving anything in return.

GeekyLumberjack Follow

Originally disclosed on Code4rena

Submitted by GeekyLumberjack, also found by CertoraInc

LibSwap.sol#L42-L46

swap is used throughout the code via _executeSwaps in Swapper.sol. According to Solidity Docs the call may return true even if it was a failure. This may result in user funds lost because funds were transferred into this contract in preparation for the swap. The swap fails but doesn’t revert. There is a way this can happen through GenericSwapFacet.sol due to a missing require that is present in the other facets which is a separate issue but gives this issue more relevance.

Proof of Concept

  1. Alice uses Generic swap with 100 DAI
  2. Alice’s 100 DAI are sent to the Swapper.sol contract
  3. The call on swap _swapData.callTo.call{ value: msg.value }(_swapData.callData); fails but returns success due to nonexisting contract
  4. postSwapBalance = 0
  5. Alice receives nothing in return

Recommended Mitigation Steps

Check for contract existence.

A similar issue was awarded a medium here.

H3xept (Li.Fi) resolved

gzeon (judge) commented:

Sponsor confirmed with fix.


The original report as published on Code4rena, by GeekyLumberjack. 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

Likely the low-level call does not check whether the target address actually contains a contract, so a call to a non-existent contract returns success.

Impact

User funds could be lost because the swap fails without reverting, leaving the transferred funds stuck in the contract.

What the attacker needed

A swap to a non-existent contract address

The fix

The contract should check that the target address contains code before making the low-level call.

How it was found

  1. Alice uses Generic swap with 100 DAI
  2. Alice's 100 DAI are sent to the Swapper.sol contract
  3. The call on swap fails but returns success due to nonexisting contract
  4. postSwapBalance = 0
  5. Alice receives nothing in return

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.

When a smart contract sends a low-level call to another address, the call can report success even if the target address has no code. This means a swap that should fail might not trigger an error, and the user's tokens could be sent to the contract without anything coming back.

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 from LI.FI 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.