Skip to content
Business logic Audit finding Intermediate

Cross-chain collaterals are wrongly calculated in the borrowWithInterest function

The borrowWithInterest function incorrectly checks that both source and destination chain IDs equal the current chain ID, which is always false for cross-chain collaterals. This causes cross-chain collateral amounts to be excluded from repayment calculations, potentially leading to incorrect or failed repayments.

0x1422 Follow with 0xB4nkz, 0xubermensch and 23 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/946

Found by

0x1422, 0xB4nkz, 0xubermensch, 0xzey, Allen_George08, Brene, JeRRy0422, Kvar, Lamsya, TopStar, Ziusz, algiz, anchabadze, dimah7, dystopia, freeking, gkrastenov, heavyw8t, ivanalexandur, m3dython, mahdifa, oxelmiguel, t.aksoy, x0rc1ph3r, xiaoming90, zxriptor

Summary

The borrowWithInterest function can not correctly calculate the cross-chain collaterals, which affects the entire repayment logic.

Root Cause

When a user tries to make a cross-chain borrow from source chain A to destination chain B, their crossChainBorrows are stored on chain B, and their crossChainCollaterals are stored on chain A. The cross-chain collateral is stored during the _handleValidBorrowRequest function:

Solidity
   lendStorage.addCrossChainCollateral(
                payload.sender, // user
                destUnderlying,  // underlying
                LendStorage.Borrow({
                   //@audit-issue srcEid != destEid
                    srcEid: srcEid,
                    destEid: currentEid,
                    principle: payload.amount,
                    borrowIndex: currentBorrowIndex,
                    borrowedlToken: payload.destlToken,
                    srcToken: payload.srcToken
                })
            );

When the user tries to repay their borrow, the system checks the sum of the cross-chain collaterals on either side. In the borrowWithInterest function, while calculating the total collateral, it checks whether:

https://github.com/sherlock-audit/2025-05-lend-audit-contest/blob/main/Lend-V2/src/LayerZero/LendStorage.sol#L497

Solidity
 if (collaterals[i].destEid == currentEid && collaterals[i].srcEid == currentEid)

This condition is always false, because destEid is always different from srcEid. As a result, the amount stored for cross-chain collaterals is never included in the borrow amount calculation, potentially leading to incorrect or failed repayments.

Internal Pre-conditions

N/A

External Pre-conditions

User should have cross-chain borrow.

Attack Path

N/A, just need to be called repayCrossChainBorrow function.

Impact

An incorrect calculation of the borrowed amount will be made as the cross-chain collateral is not included. This can potentially lead to incorrect or failed repayments.

PoC

No response

Mitigation

Avoid checking if collaterals[i].destEid == currentEid && collaterals[i].srcEid == currentEid is true. This condition should be rewritten.

The original report as published on Sherlock, by 0x1422. 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

Likely the condition in borrowWithInterest incorrectly requires both source and destination chain IDs to equal the current chain ID, which is impossible for cross-chain collaterals.

Impact

Cross-chain collateral is not included in the borrowed amount calculation, which could lead to incorrect or failed repayments.

What the attacker needed

User has a cross-chain borrow

The fix

The condition should be rewritten to avoid requiring both source and destination chain IDs to equal the current chain ID.

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 borrow across blockchains, the system records your debt on one chain and your collateral on another. A function that calculates how much you owe mistakenly looks for collateral where both the source and destination chain are the same as the current chain, which never happens for cross-chain loans. So your cross-chain collateral is ignored, and the system may think you owe more or less than you actually do, causing repayment problems.

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