Skip to content
Business logic Audit finding Intermediate

Swaps done internally will be not be possible

The internal swap path in the bridge contract passed the wrong arguments to the internal swap function, so the token ownership check could never pass. As a result, swaps that relied on an internal pool would always fail rather than execute.

0xmint Follow

Originally disclosed on Code4rena

Submitted by 0xmint

BridgeFacet.sol#L346 BridgeFacet.sol#L812

Vulnerability details

Affected functions(that rely on swapAsset()) are:

AssetLogic.sol#L193

AssetLogic.sol#L159

swapAsset() facilitates two swaps, either using the internal or external pool. But if an internal pool exists, a swap will be unsuccessful because the call to

s.swapStorages[_canonicalId].swapInternal() takes two incorrect arguments (due to an incorrect ordering, this seemed to be an oversight, acknowledged by #Layne) :

AssetLogic.sol#L278-L279

Based on the above mentioned code , the arguments would be incorrectly changed to :

SwapUtils.sol#L744-L745

The condition checked here:

SwapUtils.sol#L750

will never be true as the msg.sender would never own the quantity of tokens being swapped from since it’s the wrong token.

jakekidd (Connext) confirmed and resolved:

Resolved by connext/nxtp@a66844e

0xleastwood (judge) commented:

Great find!


The original report as published on Code4rena, by 0xmint. 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 arguments passed to the internal swap function were in the wrong order, so the ownership check compared against the wrong token.

Impact

Swaps routed through an internal pool would always fail, so that functionality was effectively broken; the text does not describe any theft or loss of funds.

What the attacker needed

An internal pool exists for the token

The fix

The issue was fixed by a commit in the project repository, according to the maintainer's comment.

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.

A smart contract is a program on a blockchain. This one had a function for swapping tokens using an internal pool, but it handed the wrong values to the swap routine. The check that the caller owns the tokens being swapped therefore always failed, so the swap simply could not go through.

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

View all

1 more disclosed report, best first.

More from Connext Amarok 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.