Skip to content
Business logic Audit finding Beginner

Should prevent users from sending more native tokens in the startBridgeTokensViaCBridge function

The CBridgeFacet contract accepted more native tokens than the specified bridge amount, leaving the excess in the contract. An attacker could recover these stranded tokens, causing a loss of funds for the user who overpaid.

shw Follow

Originally disclosed on Code4rena

Submitted by shw, also found by hickuphh3, hyh, Picodes, and pmerkleplant

When a user bridges a native token via the startBridgeTokensViaCBridge function of CBridgeFacet, the contract checks whether msg.value >= _cBridgeData.amount holds. In other words, if a user accidentally sends more native tokens than he has to, the contract accepts it but only bridges the _cBridgeData.amount amount of tokens. The rest of the tokens are left in the contract and can be recovered by anyone (see another submission for details).

Notice that in the similar functions of other facets (e.g., AnyswapFacet, HopFacet), the provided native token is ensured to be the exact bridged amount, which effectively prevents the above scenario of loss of funds.

Proof of Concept

CBridgeFacet.sol#L68

Recommended Mitigation Steps

Consider changing >= to == at line 68.

H3xept (Li.Fi) commented:

Fixed by lifinance/lifi-contracts@bb21af9a30ea73393101fc80efaa3a1f7cf25bd1

gzeon (judge) commented:

Sponsor confirmed with fix.


The original report as published on Code4rena, by shw. 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 used a greater-than-or-equal check instead of an exact equality check on the sent value, allowing excess native tokens to remain in the contract.

Impact

Excess native tokens sent by a user could be recovered by anyone, resulting in a loss of funds for that user.

What the attacker needed

User sends more native tokens than needed

The fix

The check was changed from >= to ==, and the sponsor confirmed the fix.

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 you send cryptocurrency to a smart contract, you might send more than needed by mistake. This contract only used the exact amount for bridging and kept the extra, which anyone could later take. The fix makes the contract reject any extra amount.

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 shw

View all

22 more disclosed reports, best first.

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.