Skip to content
Business logic Audit finding Intermediate

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.

0xc0ffEE Follow with Fade, Kirkeelee and 12 others

Originally disclosed on Sherlock

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.

Solidity
// 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 crossChainCollaterals mapping contains at least one record for the given user and underlying asset.
  • The function is called with specific values for srcEid, destEid, borrowedlToken, and srcToken.

External Pre-conditions:

  • None.

Attack Path:

  1. A user initiates a cross-chain borrow, which results in a Borrow struct being stored in the crossChainCollaterals mapping.
  2. Later, the protocol needs to retrieve this Borrow struct using the findCrossChainCollateral function.
  3. The function is called with specific values for srcEid, destEid, borrowedlToken, and srcToken.
  4. If any of these values do not exactly match the corresponding values stored in the Borrow struct, the function will return false and 0, even if a matching record exists.
  5. 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.

The original report as published on Sherlock, by 0xc0ffEE. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

  1. A user initiates a cross-chain borrow, storing a Borrow struct in the crossChainCollaterals mapping.
  2. Later, the protocol calls findCrossChainCollateral to retrieve this Borrow struct.
  3. The function is called with specific values for srcEid, destEid, borrowedlToken, and srcToken.
  4. If any value does not exactly match the stored Borrow struct, the function returns false and 0, even if a matching record exists.
  5. 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.

More by 0xc0ffEE

View all

27 more disclosed reports, best first.

More from LEND

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.