Skip to content
Business logic Audit finding Intermediate

Adversary can utilize a large number of their own loans to cheat other lenders out of interest

The interest distribution logic pays each provision a minimum interest amount when the total interest equals the minimum, regardless of provision size. An attacker can create many small provisions of their own alongside a legitimate large provision, so that when the loan is repaid early, most of the minimum interest goes to the attacker's provisions, cheating the legitimate lender of their expected yield.

0x52 Follow with GimelSec

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-kairos-judging/issues/24

Found by

0x52, GimelSec

Summary

The minimal interest paid by a loan is scaled by the number of provisions that make up the loan. By inflating the number of provisions with their own provisions then can cause legitimate lenders to receive a much lower interest rate than intended.

Vulnerability Detail

ClaimFacet.sol#L94-L106

function sendInterests(Loan storage loan, Provision storage provision) internal returns (uint256 sent) {
    uint256 interests = loan.payment.paid - loan.lent;
    if (interests == loan.payment.minInterestsToRepay) {
        // this is the case if the loan is repaid shortly after issuance
        // each lender gets its minimal interest, as an anti ddos measure to spam offer
        sent = provision.amount + (interests / loan.nbOfPositions);
    } else {
        /* provision.amount / lent = share of the interests belonging to the lender. The parenthesis make the
        calculus in the order that maximizes precison */
        sent = provision.amount + (interests * (provision.amount)) / loan.lent;
    }
    loan.assetLent.checkedTransfer(msg.sender, sent);
}

If a loan is paid back before the minimal interest rate has been reached then each provision will receive the unweighted minimal interest amount. This can be abused to take loans that pay legitimate lenders a lower APR than expected, cheating them of their yield.

Example: A user wishes to borrow 1000 USDC at 10% APR. Assume the minimal interest per provision is 10 USDC and minimum borrow amount is 20 USDC. After 1 year the user would owe 100 USDC in interest. A user can abuse the minimum to pay legitimate lenders much lower than 10% APR. The attacker will find a legitimate offer to claim 820 USDC. This will create an offer for themselves and borrow 20 USDC from it 9 times. This creates a total of 10 provisions each owed a minimum of 10 USDC or 100 USDC total. Now after 1 year they owe 100 USDC on their loan and the repay the loan. Since 100 USDC is the minimum, each of the 10 provisions will get their minimal interest. 90 USDC will go to their provisions and 10 will go to the legitimate user who loaned them a majority of the USDC. Their APR is ~1.2% which is ~1/9th of what they specified.

Impact

Legitimate users can be cheated out of interest owed

Code Snippet

ClaimFacet.sol#L94-L106

Tool used

Manual Review

Recommendation

The relative size of the provisions should be enforced so that one is not much larger than any other one

Discussion

npasquie

similar to #66

npasquie

fixed by https://github.com/kairos-loan/kairos-contracts/pull/51 the fix restricts the nb of offer/provision per loan to 1 eliminating the vulnerability

IAm0x52

Fix looks good. All code relevant to multiple offers has been removed. Borrowing, lending, liquidating and distributing to provisions work correctly with only one offer

The original report as published on Sherlock, by 0x52. 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 interest distribution logic pays each provision a fixed minimum interest amount when the total interest equals the minimum, without considering the relative sizes of the provisions.

Impact

Legitimate lenders can be cheated out of interest owed, receiving a much lower annual percentage rate (APR) than intended.

What the attacker needed

Attacker can create multiple offers/provisions; Attacker has funds to lend to themselves; Victim lender has an existing offer

The fix

The fix restricts the number of offers/provisions per loan to one, eliminating the vulnerability.

How it was found

  1. Attacker finds a legitimate offer to lend a large amount (e.g., 820 USDC).
  2. Attacker creates their own offer and borrows a small amount (e.g., 20 USDC) from it multiple times (e.g., 9 times).
  3. This results in many provisions (e.g., 10) each owed a minimum interest amount.
  4. After some time, the attacker repays the loan, and the total interest equals the minimum.
  5. The interest is distributed equally among all provisions, so the attacker's provisions receive most of the interest, and the legitimate lender receives only a small fraction.

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 system, a loan can be funded by multiple lenders, each contributing a 'provision'. When the borrower repays early, the interest is split equally among all provisions if the total interest is at the minimum. An attacker can add many tiny provisions of their own to a loan, so that when the borrower repays, the attacker's provisions receive most of the minimum interest, leaving the real lender with very little. This cheats the legitimate lender out of 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.

More by 0x52

View all

211 more disclosed reports, best first.

More from Kairos Loan

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.