Incorrect calculation of borrowed amount in liquidateBorrowAllowedInternal
The borrowed amount used in liquidation checks is calculated with interest applied twice, because the value already includes accrued interest from a previous function. This inflated debt could cause users to be incorrectly flagged for liquidation.
Source: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/1019
Found by
0x23r0, 0xAlix2, 0xEkko, 0xc0ffEE, 0xgee, Brene, DharkArtz, Drynooo, Etherking, FalseGenius, HeckerTrieuTien, Hueber, Kirkeelee, Kvar, PNS, Rorschach, Ruppin, SafetyBytes, Sir_Shades, Smacaud, Sparrow_Jac, Tigerfrake, Uddercover, Z3R0, anchabadze, coin2own, crazzyivan, future, ggg_ttt_hhh, gkrastenov, good0000vegetable, h2134, jokr, khaye26, kom, newspacexyz, oxelmiguel, patitonar, theboiledcorn, theweb3mechanic, udo, wickie, ydlee, zraxx
Summary
Double interest applied in borrowed amount calculation causes inflated borrow values and incorrect liquidation checks.
Root Cause
An insufficient shortfall is checked when borrowedAmount > collateral. The borrowedAmount is calculated inside the liquidateBorrowAllowedInternal function as follows:
borrowedAmount =
(borrowed * uint256(LTokenInterface(lTokenBorrowed).borrowIndex())) / borrowBalance.borrowIndex;
The borrowed value passed into this function comes from liquidateBorrow, where it is calculated using getHypotheticalAccountLiquidityCollateral:
(uint256 borrowed, uint256 collateral) =
lendStorage.getHypotheticalAccountLiquidityCollateral(borrower, LToken(payable(borrowedlToken)), 0, 0);
liquidateBorrowInternal(
msg.sender, borrower, repayAmount, lTokenCollateral, payable(borrowedlToken), collateral, borrowed
);
The function getHypotheticalAccountLiquidityCollateral already returns the borrowed amount with accrued interest included, since it internally uses the borrowWithInterestSame and borrowWithInterest methods.
As a result, when the protocol calculates shortfall, it applies interest a second time by again multiplying the already interest-included borrowed amount by the current borrow index and dividing by the stored index.
This causes the borrowedAmount used for shortfall checks to be inflated beyond the actual debt.
Internal Pre-conditions
N/A
External Pre-conditions
N/A
Attack Path
N/A
Impact
Users may be incorrectly flagged for liquidation due to an artificially high perceived borrow amount.
PoC
No response
Mitigation
Avoid double-applying interest. If the borrowed amount already includes accrued interest, it should not be adjusted again using the borrow index.
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 borrowed amount passed to the liquidation check already includes accrued interest, but the function applies the borrow index again, double-counting interest.
Impact
Users may be incorrectly flagged for liquidation due to an artificially high perceived borrow amount.
What the attacker needed
None
The fix
The borrowed amount should not be adjusted again with the borrow index if it already includes accrued interest.
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 money in a lending system, interest builds up over time. This report says the code accidentally added that interest twice when checking if a borrower should be liquidated, making their debt look bigger than it really is. That could lead to unfair liquidation.
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.