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.
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:
startBridgeTokensViaCBridge also have no such check:
startBridgeTokensViaHop the same:
In NXTPFacet completion function does the check, but startBridgeTokensViaNXTP doesn’t:
Recommended Mitigation Steps
Consider reverting when bridging functions with non-native target are called with non-zero native amount added.
Fixed in lifinance/lifi-contracts@a8d6336c2ded97bdbca65b64157596b33f18f70d
Sponsor confirmed with fix.
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.