Incorrect `destEid` Value in `_handleLiquidationSuccess` Prevents Liquidation Completion
The cross-chain liquidation handler passes a hardcoded zero destination endpoint ID when looking up a collateral record, so the lookup always fails. This prevents liquidations from completing, allowing bad debt to accumulate and potentially letting users withdraw more collateral than entitled.
Source: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/979
Found by
0xc0ffEE, Fade, Kirkeelee, Tychai0s, Waydou, Z3R0, aman, h2134, jokr, mahdifa, moray5554, newspacexyz, onthehunt, rudhra1749, xiaoming90
Summary:
The _handleLiquidationSuccess function in CrossChainRouter.sol attempts to locate a cross-chain collateral record using the findCrossChainCollateral function in LendStorage.sol. However, it incorrectly sets the destEid parameter to 0, causing the lookup to always fail. This prevents the liquidation process from completing successfully, leading to debt accumulation and potential losses for the protocol.
Root Cause:
The _handleLiquidationSuccess function, which is called on Chain A after a cross-chain liquidation is executed, uses lendStorage.findCrossChainCollateral to find the relevant collateral record. The destEid parameter passed to this function is hardcoded to 0.
// filepath: src/LayerZero/CrossChainRouter.sol
(bool found, uint256 index) = lendStorage.findCrossChainCollateral(
payload.sender,
underlying,
srcEid,
0, // Incorrect destEid
payload.destlToken,
payload.srcToken
);
Internal Pre-conditions:
- The
crossChainCollateralsmapping contains at least one record for the given user and underlying asset. - The function is called with specific values for
srcEid,destEid,borrowedlToken, andsrcToken.
External Pre-conditions:
- None.
Attack Path:
- A user initiates a cross-chain borrow, which results in a
Borrowstruct being stored in thecrossChainCollateralsmapping. - Later, the protocol needs to retrieve this
Borrowstruct using thefindCrossChainCollateralfunction. - The function is called with specific values for
srcEid,destEid,borrowedlToken, andsrcToken. - If any of these values do not exactly match the corresponding values stored in the
Borrowstruct, the function will returnfalseand0, even if a matching record exists. - This can lead to incorrect behavior in the protocol, such as failing to liquidate a user's position or allowing a user to withdraw more collateral than they are entitled to.
Impact:
- The protocol may fail to locate valid collateral records, leading to incorrect behavior.
- Users may be able to exploit this issue to withdraw more collateral than they are entitled to.
- The protocol's solvency may be threatened due to the potential for uncollateralized positions.
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 `_handleLiquidationSuccess` function hardcodes the `destEid` argument to 0 instead of using the actual destination endpoint ID, so the collateral lookup always fails.
Impact
Liquidations may fail to complete, causing debt to accumulate and potentially allowing users to withdraw more collateral than entitled, threatening protocol solvency.
What the attacker needed
CrossChainCollaterals mapping has a record; cross-chain liquidation is triggered
How it was found
- A user initiates a cross-chain borrow, storing a Borrow struct in the crossChainCollaterals mapping.
- Later, the protocol calls findCrossChainCollateral to retrieve this Borrow struct.
- The function is called with specific values for srcEid, destEid, borrowedlToken, and srcToken.
- If any value does not exactly match the stored Borrow struct, the function returns false and 0, even if a matching record exists.
- This leads to incorrect behaviour, such as failing to liquidate a user's position or allowing a user to withdraw more collateral than entitled.
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.
In a cross-chain lending system, when a user's position is liquidated, the protocol must find the right record of what they borrowed on another chain. This code searches for that record using a wrong identifier (zero instead of the real chain ID), so it never finds it. As a result, the liquidation cannot finish, and the protocol may end up with unpaid debt.
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.