Skip to content
Business logic Audit finding Intermediate

Incorrect `srcEid` check in `borrowWithInterest()`

The borrowWithInterest() function on the source chain filters borrow records using the wrong chain identifier field, so it never matches existing cross-chain borrows and always returns zero. This makes cross-chain liquidations on that chain impossible because the liquidation check sees no outstanding debt.

FalseGenius Follow with JeRRy0422, Kvar and 4 others

Originally disclosed on Sherlock

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

Found by

FalseGenius, JeRRy0422, Kvar, Waydou, ggg_ttt_hhh, jokr, rudhra1749

Summary

NOTE: This is a different issue from the one in the same function involving the line if (collaterals[i].destEid == currentEid && collaterals[i].srcEid == currentEid). That issue concerns chain B, where repayments happen. The issue described here is about the other if statement, which affects chain A, where borrows originate.

LendStorage.sol#borrowWithInterest() incorrectly checks borrows[i].srcEid == currentEid on the source chain (Chain A), but borrow records store destEid as the current chain ID. This causes the function to always return zero for existing cross-chain borrows on Chain A.

Root Cause

LeadStorage.sol#borrowWithInterest() uses the wrong chain ID field for filtering borrows on the source chain. It checks if srcEid == currentEid, which does not match how borrow records are stored. This condition will never be true on chain A (where userBorrows exist) because the borrow’s destEid (not srcEid) equals the current chain ID. This mismatch causes the function to ignore valid borrows.

When a borrow is stored in userBorrows, the srcEid is set as Chain B and the destEid as Chain A. This happens on Chain A and can be seen here. In this scenario, srcEid corresponds to Chain B while currentEid refers to Chain A.

Internal Pre-conditions

N/A

External Pre-conditions

N/A

Attack Path

N/A

Impact

Calling borrowWithInterest() on chain A will always return 0, making cross-chain liquidations impossible. Since _checkLiquidationValid is called on chain A, it sees the borrowed amount as zero and incorrectly determines the position is not liquidatable.

PoC

No response

Mitigation

No response

The original report as published on Sherlock, by FalseGenius. 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 function compares the borrow record's source chain identifier against the current chain, when on the source chain the record's destination chain identifier is the one that equals the current chain.

Impact

Cross-chain liquidations on the source chain are impossible because the liquidation validity check sees the borrowed amount as zero and treats the position as not liquidatable.

What the attacker needed

Cross-chain borrow exists on source chain

The fix

The function should compare the borrow record's destination chain identifier against the current chain when filtering borrows on the source chain.

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, a user borrows on one blockchain and the debt is recorded on another. A checking function is supposed to look up how much a user owes, but it compares the wrong label on the record, so it finds nothing and reports zero debt. As a result, the system thinks the user owes nothing and will not liquidate an unhealthy position.

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.