Skip to content
Business logic Audit finding Intermediate

ERC20 bridging functions do not revert on non-zero msg.value

Several ERC20 bridging functions in the Li.Fi contracts do not check that msg.value is zero, so any native funds sent with these calls remain stuck on the contract balance. An attacker could combine this with other issues to freeze or lose user funds.

hyh Follow

Originally disclosed on Code4rena

Submitted by hyh, also found by danb, kirk-baird, and pmerkleplant

Any native funds mistakenly sent along with plain ERC20 bridging calls will be lost. AnyswapFacet, CBridgeFacet, HopFacet and NXTPFacet have this issue.

For instance, swapping function might use native tokens, but the functions whose purpose is bridging solely have no use of native funds, so any mistakenly sent native funds to be frozen on the contract balance.

Placing the severity to be medium as in combination with other issues there is a possibility for user funds to be frozen for an extended period of time (if WithdrawFacet’s issue plays out) or even lost (if LibSwap’s swap native tokens one also be triggered).

In other words, the vulnerability is also a wider attack surface enabler as it can bring in the user funds to the contract balance.

Medium despite the fund loss possibility as the native funds in question here are mistakenly sent only, so the probability is lower compared to direct leakage issues.

Proof of Concept

startBridgeTokensViaAnyswap doesn’t check that msg.value is zero:

AnyswapFacet.sol#L38-L48

startBridgeTokensViaCBridge also have no such check:

CBridgeFacet.sol#L59-L66

startBridgeTokensViaHop the same:

HopFacet.sol#L66-L71

In NXTPFacet completion function does the check, but startBridgeTokensViaNXTP doesn’t:

NXTPFacet.sol#L54-L59

Recommended Mitigation Steps

Consider reverting when bridging functions with non-native target are called with non-zero native amount added.

H3xept (Li.Fi) commented:

Fixed in lifinance/lifi-contracts@a8d6336c2ded97bdbca65b64157596b33f18f70d

gzeon (judge) commented:

Sponsor confirmed with fix.


The original report as published on Code4rena, by hyh. 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 bridging functions for ERC20 tokens lack a check that msg.value is zero, so they accept native currency that they do not handle.

Impact

Mistakenly sent native funds become frozen on the contract balance, and in combination with other issues user funds could be frozen for an extended period or even lost.

What the attacker needed

User mistakenly sends native funds; other issues present for fund loss

The fix

The bridging functions should revert when called with a non-zero native amount, and the sponsor confirmed this was fixed.

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 call a smart contract function, you can also send some of the blockchain's native currency (like ETH) along with the call. Some functions are only meant to move tokens, not native currency, so they should reject any extra native currency. Here, they don't, so if someone accidentally sends native currency, it stays stuck in the contract and cannot be recovered.

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 hyh

View all

137 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.