Malicious borrowers will never repay loans with high interest
The liquidation check only compares the original borrowed amount to the collateral value and ignores accrued interest, so a borrower whose interest has grown large can never be liquidated as long as the original loan-to-value ratio stays under 90%. This lets borrowers avoid repaying interest indefinitely, causing bad debt for lenders.
DadeKuma Follow with DadeKuma and Arabadzhiev
Originally disclosed on Code4rena
Submitted by DadeKuma, also found by DadeKuma and Arabadzhiev
Borrowers have no incentives to repay the loan if the owed interest grows too much, as the liquidation check fails to take it into consideration when calculating the LTV. This will generate bad debt for the lenders.
Proof of Concept
The liquidation call must pass this check to execute:
require!(ctx.accounts.position_account.amount * 1000 / position_size > 900, FlashFillError::ExpectedCollateralNotEnough );
src/processor/liquidate.rs#L27
The issue is that it fails to consider how much interest is owed by the borrower, it only checks how much the user has borrowed at the start of the loan:
ctx.accounts.position_account.amount = position_size - user_pays;
src/processor/swap.rs#L16
As such, if the borrower accumulates a very high interest to pay, the lender has no way to liquidate this position if the original borrowed amount’s LTV (without accrued interest) stays under 90%. These borrowers will never repaid the loan, and this will generate bad debt for lenders.
Recommended Mitigation Steps
Consider adding the owed interest to the total amount when performing the liquidation check.
Assessed type
Invalid Validation
piske-alex (Lavarage) confirmed
alcueca (judge) decreased severity to Medium and commented:
Downgraded to Medium because even if borrowers can effectively steal the borrowed amount, to do so they need to keep an amount of collateral of higher value locked in the protocol.
@alcueca - I disagree, as this clearly warrants High severity if we follow the severity categorization. There are zero hypotheticals, any borrower can get a loan for an unlimited amount of time (and not pay ANY interest), without consequences.
It’s like saying that I go to the bank to get a loan, never pay the interest (without consequences), and they can’t liquidate me until the collateral I provided is worthless. The bank is experiencing a loss of funds because it is lending money for free.
The attacker is experiencing a larger loss of funds, which makes it a grieving attack, which is Medium.
@alcueca - Consider the following case. The lender lends 1000 SOL with a 10% monthly rate. Let’s say that the collateral is worth 1500 SOL.
Every month, the borrower should pay 100 SOL, but they can ignore the payments without consequences.
After 6 months, the lender has lost more funds than the borrower (they should have earned 600 SOL but they have earned
0), and they can’t do anything to claim the collateral, they are lending money for free. But they are forced to wait until the collateral is worthless.Consequences:
- Lenders miss interest payments, potentially forever.
- Meanwhile, they can’t offer new loans, as their funds are already locked in this one.
- The protocol is useless if no one repays their loans as lenders only lose money.
- If accrued interest is higher than collateral, the borrower will never repay, because at this point the liquidation costs less than the repayment.
The lender is accruing bad debt, which is a clear loss of funds for the lender. Recouping the collateral is not enough if their funds stay locked for decades.
When measuring financial losses it is uncommon to consider loss of future income or opportunity cost. I see this vulnerability as the victim putting X assets into the protocol, and the attacker spending Y assets so that the victim loses theirs, with the value of Y greater than the value of X.
If the victim would have put their assets somewhere expecting 0% income, for example, in an escrow contract, and they would get locked in the same fashion, you could still make the reasoning that because the victim has been blocked from withdrawing and earning an income on their assets in perpetuity, the issue is a critical.
The reasoning can be extended to make all grieving attacks of critical severity, which isn’t fair to attacks where the attacker obtains an actual profit.
It’s not future income as interest is accrued daily. High risk means that funds can be compromised directly (it’s worth noting that this isn’t a dust amount, and any borrower can do it). The actual rules say nothing about griefing, and borrowing/lending is a core feature of this protocol.
There are multiple scenarios:
Scenario 1: The borrower locks collateral but they recoup some immediately by taking the borrowed amount. The lender has no access to any funds until liquidation, which can’t be enforced as interest is not accrued. For a % cost of the total borrowed amount, the attacker can lock a sizeable capital forever. Scenario 2: There is no attacker, and a borrower has lost access to their wallet. The loan remains unliquidable forever, and the lender loses 100% of the capital as there is no time limit for a loan (like described in #9 which was duped to this issue).
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 liquidation condition compares only the original borrowed amount to the position size and omits accrued interest from the debt calculation.
Impact
Borrowers can avoid paying any interest indefinitely, and lenders may never recover their funds, generating bad debt; the judge downgraded it to Medium because the borrower must lock collateral of higher value.
What the attacker needed
A borrower takes a loan; interest accrues over time; original LTV stays under 90%
The fix
The liquidation check should include the owed interest in the total debt amount.
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 lending protocol, a borrower puts up collateral (something valuable) and borrows money. If the borrower does not repay, the protocol can sell the collateral to recover the loan, but only when the loan is too big compared with the collateral. Here the check for that only looks at the original amount borrowed, not the interest that keeps adding up. So a borrower can let interest grow forever and the protocol will never step in, meaning lenders lose the interest they were promised.
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.