# Incorrect srcToken Used When Cross-Chain Liquidation

Cross-chain liquidation passes destination-chain borrowed token as srcToken, so findCrossChainCollateral fails on Chain B, reverting repayment after collateral already seized.

- Payout: Audit contest
- Severity: high
- Program: Lend Audit Contest
- Found by: aman
- Disclosed: 2025-05-22
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/720
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-05-lend-audit-contest%3AH-14
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic

**Target:** LayerZero CrossChainRouter cross-chain liquidation flow
**Root cause:** In _handleLiquidationSuccess, payload.srcToken (destination chain's borrowed underlying) is used to match crossChainCollaterals, but that field stores the source chain's underlying token; addresses differ across chains.
**Steps:**
1. Chain A: borrower calls `borrowCrossChain(_amount, _borrowToken, _destEid)`; `_send` carries `_borrowToken` (Chain A underlying) as srcToken.
2. Chain B: `_handleBorrowCrossChainRequest` stores Borrow with `srcToken: payload.srcToken` (Chain A underlying) and `borrowedlToken: payload.destlToken`.
3. Chain B: liquidator triggers `_executeLiquidationCore`; `_send` to Chain A carries `params.borrowedAsset` (Chain B underlying) as srcToken.
4. Chain A: `_handleLiquidationExecute` seizes collateral and forwards `payload.srcToken` (Chain B underlying) back to Chain B.
5. Chain B: `_handleLiquidationSuccess` calls `findCrossChainCollateral(payload.sender, underlying, currentEid, 0, payload.destlToken, payload.srcToken)`; srcToken mismatch causes `require(found)` to revert.
**How found:** Traced the borrow flow to establish that crossChainCollaterals.srcToken is the source-chain underlying, then followed the liquidation message round-trip and noticed _handleLiquidationSuccess reuses payload.srcToken (destination-chain asset) for the lookup.
**Exploitation:** Liquidator initiates liquidation on Chain B; Chain A seizes the borrower's collateral; the return message's srcToken is the Chain B underlying, which does not match the stored Chain A underlying, so repayment on Chain B reverts. Collateral is seized while debt remains, harming the liquidatee and leaving the protocol with bad debt.
**Insight:** In multi-chain message protocols, track which chain's address space each payload field belongs to; a field echoed back through a round-trip may carry the wrong chain's token address even when symbols match.

## Proof of concept (copied exactly from the original report)

**Liquidation success finds collateral with wrong srcToken**

```
function _handleLiquidationSuccess(LZPayload memory payload) private {
        // Find the borrow position on Chain B to get the correct srcEid
        address underlying = lendStorage.lTokenToUnderlying(payload.destlToken);

        // Find the specific collateral record
        (bool found, uint256 index) = lendStorage.findCrossChainCollateral(
            payload.sender,
            underlying,
            currentEid, // srcEid is current chain
            0, // We don't know destEid yet, but we can match on other fields
453:        payload.destlToken,
454:        payload.srcToken
        );

        require(found, "Borrow position not found");
```

**Liquidation execute sends borrowedAsset as srcToken**

```
function _executeLiquidationCore(LendStorage.LiquidationParams memory params) private {
        // Calculate seize tokens
        address borrowedlToken = lendStorage.underlyingTolToken(params.borrowedAsset);
        ...
        _send(
            params.srcEid,
            seizeTokens,
            params.storedBorrowIndex,
            0,
            params.borrower,
            lendStorage.crossChainLTokenMap(params.lTokenToSeize, params.srcEid), // Convert to Chain A version before sending
            msg.sender,
282:        params.borrowedAsset,
            ContractType.CrossChainLiquidationExecute
```

**Borrow cross chain sends underlying as srcToken**

```
function borrowCrossChain(uint256 _amount, address _borrowToken, uint32 _destEid) external payable {
        ...
        address destLToken = lendStorage.underlyingToDestlToken(_borrowToken, _destEid);
        ...
        _send(
            _destEid,
            _amount,
            0, // Initial borrowIndex, will be set on dest chain
            collateral,
            msg.sender,
            destLToken,
            address(0), // liquidator
151:        _borrowToken,
            ContractType.BorrowCrossChain
```

