Skip to content
Business logic Audit finding Advanced

Interest-bearing suppliers are over-credited when interest-free supply coexists, creating a reserve deficit

The supply exchange price update applies an amplified interest rate multiplicatively to an already-grown exchange price, so interest-bearing suppliers are credited more value than borrowers actually pay. Over time this creates a reserve deficit where early redeemers withdraw inflated value and later redeemers face a shortfall.

qed Follow

Originally disclosed on Code4rena

Submitted by qed

  • programs/liquidity/src/state/token_reserve.rs #L524-L530
  • programs/liquidity/src/state/token_reserve.rs #L449-L466

calculate_exchange_prices() applies an amplified supply rate multiplicatively to the current supply_exchange_price, but the amplification factor is derived from a conservation relationship that only holds at initialization (Ps == 1e12). Once Ps has increased, repeated accrual credits more value to interest-bearing suppliers than borrowers fund. The growing deficit means early redeemers withdraw inflated value while later redeemers face a shortfall.

Root Cause

In programs/liquidity/src/state/token_reserve.rs (lines 524-530), the supply exchange price update is multiplicative in Ps:

// line 524-530
supply_exchange_price = supply_exchange_price.safe_add(
    supply_exchange_price
        .safe_mul(supply_rate)?
        .safe_mul(seconds_since_last_update)?
        .safe_div(SECONDS_PER_YEAR.safe_mul(FOUR_DECIMALS)?)?
        .safe_div(FOUR_DECIMALS.safe_mul(FOUR_DECIMALS)?)?,
)?;

The supply_rate incorporates an amplification factor ratio_supply_yield (lines 452-466) that redistributes interest from interest-free positions to interest-bearing ones. At initialization (Ps = 1e12), the amplification is calibrated correctly: S_raw * delta_Ps = B_raw * delta_Pb * (1 - fee). But after the first accrual step, Ps > 1e12. The formula applies the same amplified rate to the now-larger Ps, producing a larger absolute increase on the supply side than what the borrow side generates. Each subsequent step widens the gap.

The key formula at lines 462-466 (when total_supply_with_interest >= total_supply_interest_free):

// line 462-466
utilization
    .safe_mul(EXCHANGE_PRICE_RATE_OUTPUT_DECIMALS)?
    .safe_mul(FOUR_DECIMALS.safe_add(supply_ratio)?)?
    .safe_div(FOUR_DECIMALS.safe_mul(FOUR_DECIMALS)?)?

Interest conservation requires Ps(t) = 1e12 + (B_raw / S_raw) * (Pb(t) - 1e12) * (1 - fee) — a linear function of Pb(t), not an exponential. The multiplicative formula forces Ps to grow exponentially at a rate higher than Pb, violating conservation after the first step.

Attack Scenario

  1. A reserve contains both interest-bearing supply (from Lending depositors) and interest-free supply (from Vault positions). This is the protocol’s standard operating mode — Vaults always create interest-free Liquidity positions.
  2. Borrows remain open and exchange prices are periodically updated (on every user interaction — deposits, withdrawals, borrows, repayments).
  3. Because supply_exchange_price compounds the amplified rate on top of an already-grown Ps, interest-bearing suppliers are credited more value than borrowers pay into the reserve.
  4. The deficit accumulates silently with every accrual step, growing faster as Ps diverges further from 1e12.
  5. Early withdrawers redeem at inflated exchange prices; remaining suppliers absorb the shortfall when vault balance is insufficient to cover all redemptions.

Impact

  • Reserve deficit: The total redeemable value promised to interest-bearing suppliers exceeds the assets funded by borrowers. When redemptions occur, the shortfall is borne by later withdrawers.
  • Cumulative and irreversible: The over-crediting compounds with every exchange-price update, growing larger over time. The protocol has no mechanism to claw back the excess credits.
  • No attacker action required: This occurs during normal protocol operation whenever interest-free and interest-bearing supply coexist on the same mint — which is the protocol’s standard design (Vaults create interest-free positions on the same reserves used by Lending).
  • Accelerates during market stress: Above the kink (80% utilization), borrow rates jump sharply (from 10% to 150% across the 80-100% range), and the supply-side amplification magnifies the divergence further.

Recommended Mitigation Steps

Compute the supply exchange price increase directly from the actual borrow-side interest collected, distributed only to interest-bearing suppliers:

// Correct approach: derive supply increase from borrow increase
let borrow_interest_increase = borrow_exchange_price
    .safe_mul(borrow_rate)?
    .safe_mul(seconds_since_last_update)?
    .safe_div_ceil(SECONDS_PER_YEAR.safe_mul(FOUR_DECIMALS)?)?;

let fee: u128 = self.fee_on_interest.cast()?;
let supplier_share = borrow_interest_increase
    .safe_mul(FOUR_DECIMALS.safe_sub(fee)?)?
    .safe_div(FOUR_DECIMALS)?;

let total_borrow_raw: u128 = self.total_borrow_with_interest.cast()?;
let total_supply_raw: u128 = self.total_supply_with_interest.cast()?;

if total_supply_raw > 0 {
    let price_increase = supplier_share
        .safe_mul(total_borrow_raw)?
        .safe_div(total_supply_raw)?;
    supply_exchange_price = supply_exchange_price.safe_add(price_increase)?;
}

This ensures that the supply-side price increase is always derived from the borrow-side interest actually collected, preserving the conservation invariant regardless of how many accrual steps occur.

Proof of Concept

View detailed Proof of Concept

Sponsor team notes

The Jupiter Lend team considers this finding to be a duplicate of M-10 due to both pertaining to the same type of issue, and commented:

Addressed by the M-03 fix (same root cause), https://github.com/Instadapp/fluid-contracts-solana/commit/8358cdb3381918ad2f7b4442afe27b642535186a, https://github.com/Instadapp/fluid-contracts-solana/commit/b6821c479e49cd52d2a94c4145c64c26a5e95d8d (PR #137)


The original report as published on Code4rena, by qed. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 supply exchange price is updated by multiplying the current price by an amplified rate, but the amplification factor was only correct when the price equalled its initial value, so the price grows exponentially instead of linearly with the borrow price.

Impact

The total redeemable value promised to interest-bearing suppliers could exceed the assets funded by borrowers, so early withdrawers may take inflated value and later withdrawers may face a shortfall; no attacker action is needed and the over-crediting compounds with every update.

What the attacker needed

Interest-bearing and interest-free supply coexist; borrows remain open; exchange prices are updated over time

The fix

The supply exchange price increase should be derived directly from the borrow-side interest actually collected, with only the supplier share distributed to interest-bearing suppliers; the sponsor says this was addressed by the M-03 fix.

How it was found

  1. A reserve has both interest-bearing supply from Lending depositors and interest-free supply from Vault positions.
  2. Borrows stay open and exchange prices are updated on every user interaction.
  3. Each update compounds the amplified rate on an already-grown supply exchange price.
  4. The deficit accumulates with every accrual step.
  5. Early withdrawers redeem at inflated prices and later suppliers absorb the shortfall.

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 pool, people who deposit money earn interest paid by borrowers. This code also has a special group of depositors who earn no interest, and the pool tries to give their share of interest to the normal depositors. The calculation for doing that is wrong once the pool has been running for a while, so the normal depositors are promised more money than the pool actually holds. The first people to withdraw get too much, and the last people to withdraw find the pool short.

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 qed

View all

13 more disclosed reports, best first.

More from Jupiter Lend

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.