Cross chain repayment updates wrong borrow balance
The cross-chain repayment path calls a shared internal repayment routine that updates the borrower's same-chain borrow balance instead of the cross-chain borrow record. This leaves cross-chain debt accounting wrong, which could prevent repayment or liquidation of cross-chain borrows.
Source: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/964
Found by
0xEkko, 0xc0ffEE, 0xgee, Kvar, SarveshLimaye, Z3R0, benjamin_0923, dmdg321, ggg_ttt_hhh, h2134, jokr, mussucal, newspacexyz, oxelmiguel, patitonar, rudhra1749, sil3th, wickie, xiaoming90
Summary
The function CoreRouter::repayBorrowInternal() only updates user's borrowBalance (which is the borrow balance same-chain). This can cause cross chain repayment to update wrong borrow balance
Root Cause
The function _repayCrossChainBorrowInternal() is used within the flow of function repayCrossChainBorrow() and _handleLiquidationSuccess(). The function _repayCrossChainBorrowInternal() calls internal function _handleRepayment(), which will external call to CoreRouter::repayCrossChainLiquidation(). The function CoreRouter::repayCrossChainLiquidation() calls internal function repayBorrowInternal(). Here exists problem that the cross chain borrow information is not updated, but the same-chain borrow balance.
Indeed, on the dest chain, the borrow information crossChainCollateral should be updated.
function repayBorrowInternal(
address borrower,
address liquidator,
uint256 _amount,
address _lToken,
bool _isSameChain
) internal {
address _token = lendStorage.lTokenToUnderlying(_lToken);
LTokenInterface(_lToken).accrueInterest();
uint256 borrowedAmount;
if (_isSameChain) {
borrowedAmount = lendStorage.borrowWithInterestSame(borrower, _lToken);
} else {
borrowedAmount = lendStorage.borrowWithInterest(borrower, _lToken);
}
require(borrowedAmount > 0, "Borrowed amount is 0");
uint256 repayAmountFinal = _amount == type(uint256).max ? borrowedAmount : _amount;
// Transfer tokens from the liquidator to the contract
IERC20(_token).safeTransferFrom(liquidator, address(this), repayAmountFinal);
_approveToken(_token, _lToken, repayAmountFinal);
lendStorage.distributeBorrowerLend(_lToken, borrower);
// Repay borrowed tokens
require(LErc20Interface(_lToken).repayBorrow(repayAmountFinal) == 0, "Repay failed");
// Update same-chain borrow balances
if (repayAmountFinal == borrowedAmount) {
@> lendStorage.removeBorrowBalance(borrower, _lToken);
@> lendStorage.removeUserBorrowedAsset(borrower, _lToken);
} else {
@> lendStorage.updateBorrowBalance(
borrower, _lToken, borrowedAmount - repayAmountFinal, LTokenInterface(_lToken).borrowIndex()
);
}
// Emit RepaySuccess event
emit RepaySuccess(borrower, _lToken, repayAmountFinal);
}
Internal Pre-conditions
NA
External Pre-conditions
NA
Attack Path
NA
Impact
- Potential unable to repay cross chain borrow and liquidate cross chain borrow
- If the function
repayBorrowInternal()successfully executed, then the same chain borrow balance is also updated, which is incorrectly accounting
PoC
No response
Mitigation
Since the function _updateRepaymentState() is executed later to update cross chain borrow information, then the function repayBorrowInternal() should consider not update borrow balance when _isSameChain == false
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
Impact
Cross-chain borrows may become impossible to repay or liquidate, and the same-chain balance is wrongly reduced, so accounting is incorrect.
What the attacker needed
Cross-chain borrow exists; repayment or liquidation triggered
The fix
The repayment helper should skip updating the same-chain borrow balance when the repayment is not same-chain, leaving the cross-chain update to the later state-update step.
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.
A lending app lets people borrow on one blockchain and repay on another. When a repayment arrives from the other chain, the code updates the wrong record of what the person owes, so the books no longer match reality. That can block later repayments or liquidations because the system thinks the debt is different from what it is.
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.