Subsequent Cross‐Chain Borrows don’t Accrue interest on existing principal when borrowing the same Asset
When a user borrows the same asset cross-chain more than once, the contract on the source chain adds the new amount to the existing principal without first applying the accumulated interest. This under-records the user's debt, allowing them to borrow more than their collateral should permit.
0xc0ffEE Follow with 37H3RN17Y2, Brene and 21 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/1011
Found by
0xc0ffEE, 37H3RN17Y2, Brene, Etherking, HeckerTrieuTien, Kvar, Tigerfrake, Z3R0, algiz, coin2own, dmdg321, francoHacker, future, ggg_ttt_hhh, gkrastenov, hgrano, jokr, kom, newspacexyz, oxelmiguel, rudhra1749, t.aksoy, theweb3mechanic, zraxx
Summary
Borrowing the same asset more than once on Chain B, results in crossChainBorrow[user][token] entry's principle not updated with the latest borrowIndex, recording less debt on ChainA than the actual saved on Chain B.
This results in incorrect calculation of the account liquidity state via the getHypotheticalAccountLiquidityCollateral(..), which can allow the user to borrow more than he should be allowed to.
Root Cause
In CrossChainRouter._handleValidBorrowRequest, if the user previously borrowed the same asset on ChainB, we need to update the existing userBorrows[index].principle on ChainA with the new borrow amount.
To do that, it is correct to first update the userBorrows[index].principle according to the latest borrowIndex, before adding the new borrow amount. (the way it is done on ChainB).
However, the code currently just adds the new borrow amount and updates the state:
userBorrows[index].principle =
userBorrows[index].principle +
payload.amount; //@audit - not accounting for interest?
The interest accumulated between the previous cross chain borrow and the new one is lost and the user will not have to pay it.
Internal Pre-conditions
- User on ChainA has already initiated a cross-chain borrow on ChainB.
- User triggers a second cross-chain borrow on the same asset.
External Pre-conditions
None
Attack Path
- User initiates cross-chain borrow from Chain A to Chain B.
- User waits for enough time to pass
- User performs a second cross-chain borrow from Chain A to Chain B on the same asset.
- User's debt calculated on ChainA is less than the real one(recorded on ChainB) by a factor of the
borrowIndexaccumulated between first borrow and second borrow. - User can proceed to borrow more than his collateral is worth(due to the wrong total debt calculated by
getHypotheticalAccountLiquidityCollateralon Chain A
Impact
The user can perform subsequent cross chain borrows between the same chains(ChainA and ChainB) on the same asset with enough time between them.
This will cause his outstanding debt saved on ChainA to be less than it should be(by a factor of the borrowIndex accumulated between first borrow and second borrow).
This will allow the user to borrow additional funds, that he should not be able to and potentially driving the market to an illiquid state.
PoC
Can be provided upon request.
Mitigation
Inside the CrossChainRouter._handleValidBorrowRequest, modify the update on existing principle, so that it accounts for the borrowIndex accumulated:
if (found) {
// Update existing borrow
LendStorage.Borrow[] memory userBorrows = lendStorage.getCrossChainBorrows(payload.sender, payload.srcToken);
- userBorrows[index].principle = userBorrows[index].principle + payload.amount;
+ userBorrows[index].principle = (userBorrows[index].principle * currentBorrowIndex) / userBorrows[index].borrowIndex + payload.amount
userBorrows[index].borrowIndex = payload.borrowIndex;
// Update in storage
lendStorage.updateCrossChainBorrow(payload.sender, payload.srcToken, index, userBorrows[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
Likely, the code updates the stored principal by simply adding the new borrow amount without first accruing interest using the latest borrow index.
Impact
The user's outstanding debt on Chain A is understated, allowing them to borrow additional funds they should not be able to, potentially driving the market to an illiquid state.
What the attacker needed
User has an existing cross-chain borrow on Chain B; User initiates a second cross-chain borrow on the same asset; Enough time passes for interest to accrue
The fix
The code should be fixed by updating the existing principal with the latest borrow index before adding the new borrow amount.
How it was found
- User initiates a cross-chain borrow from Chain A to Chain B.
- User waits for enough time to pass.
- User performs a second cross-chain borrow from Chain A to Chain B on the same asset.
- User's debt calculated on Chain A is less than the real one recorded on Chain B.
- User can proceed to borrow more than their collateral is worth.
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.
Imagine you borrow money and interest builds up over time. If you borrow more of the same currency later, the system should add the new loan to the old loan plus its interest. Here, it just adds the new loan to the old loan amount, forgetting the interest. So the system thinks you owe less than you really do, and you can borrow extra money you shouldn't be allowed to.
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.