Skip to content
Business logic Audit finding Intermediate

Attackers can maliciously inflate total_supply temporarily to exceed utilization rate limit and push the pool towards 100% util rate, potentially causing a loss of lender funds

The pool's utilisation rate limit was only checked during the borrow action, so a user could temporarily inflate total_supply with a supply action, borrow past the limit, then withdraw the supplied funds in the same transaction. This allowed pushing the pool towards 100% utilisation without providing real funds, potentially causing lender losses from bad debt.

rscodes Follow with 0x37

Originally disclosed on Code4rena

Submitted by rscodes, also found by 0x37

https://github.com/code-423n4/2025-02-blend/blob/f23b3260763488f365ef6a95bfb139c95b0ed0f9/blend-contracts-v2/pool/src/pool/actions.rs#L382

Summary

Blend pools have a utilisation rate limit that borrowers are not allowed to cross. Lenders deposit into the pool because they agree with the utilization limit set that cannot be crossed to protect them from bad debt losses.

However, a malicious user can bypass it with the following attack vector and push the pool illegally towards a 100% util rate (past the limit), causing potential loss for lenders during volatile market conditions

Currently during a borrow action, the only part where the utilization rate is checked is in apply_borrow, which checks it by calling the function reserve.require_utilization_below_max(e).

However, there is a way where users can build transactions to simply bypass the utilization rate. Consider the following transaction order.

In the build actions, the user can build as (assuming the malicious user already has collateral to make a borrow):

  1. apply_supply
  2. apply_borrow
  3. apply_withdraw

(This is done in the same build transaction).

This works because reserve.require_utilization_below_max(e) is total_liabilities / total_supply. You can see that the transaction temporarily inflates total_supply before withdrawing it.

Important note: Even though, apply_borrow sets check_health to true, check health does not check the utilization rate. It checks whether the individual user has sufficient collateral.

Impact

This allows the agreed upon utilization rate to be bypassed, putting the pool at a higher risk at baddebt than the lenders have agreed upon when they deposited their funds.

Malicious users can do this during volatile market conditions, to bring utilisation rate to 100%, which is almost guaranteed to cause a loss of lender funds from baddebt in volatile market conditions. Hence, this is a high impact by Code4rena rules.

Likelihood

There isn’t much precondition to carry out this attack to bypass util rate. In fact, the attacker doesn’t even need to have the funds that they use to temporarily inflate total_supply. This is because funds are net-off and pulled in at the end, so the withdraw will net-off away from the supply.

The attacker will be able to continue having the loan, even though the loan may be causing the pool to reach 100% utilization rate.

Proof Of Concept (POC)

Go to actions.rs in the V2 repo. (I’m using the repo provided by the C4 audit page).

There is currently a function called test_build_actions_from_request_borrow_errors_over_max_util() already coded by the sponsor. It has a #[should_panic....] which is meant to catch the panic when the user borrows over util rate.

First, lets remove the #[should_panic....] line as I will now prove the malicious user can avoid the panic by doing this hack.

Change the test function to the following:

#[test]
fn test_build_actions_from_request_borrow_errors_over_max_util() {
    let e = Env::default();
    e.mock_all_auths();

    let bombadil = Address::generate(&e);
    let samwise = Address::generate(&e);
    let pool = testutils::create_pool(&e);

    let (underlying, _) = testutils::create_token_contract(&e, &bombadil);
    let (mut reserve_config, mut reserve_data) = testutils::default_reserve_meta();
    reserve_config.max_util = 0_9000000;
    reserve_data.b_supply = 100_0000000;
    reserve_data.d_supply = 89_0000000;
    testutils::create_reserve(&e, &pool, &underlying, &reserve_config, &reserve_data);

    e.ledger().set(LedgerInfo {
        timestamp: 600,
        protocol_version: 22,
        sequence_number: 1234,
        network_id: Default::default(),
        base_reserve: 10,
        min_temp_entry_ttl: 10,
        min_persistent_entry_ttl: 10,
        max_entry_ttl: 3110400,
    });
    let pool_config = PoolConfig {
        oracle: Address::generate(&e),
        min_collateral: 1_0000000,
        bstop_rate: 0_2000000,
        status: 0,
        max_positions: 2,
    };

    let user_positions = Positions {
        liabilities: map![&e],
        collateral: map![&e, (0, 20_0000000)],
        supply: map![&e],
    };
    e.as_contract(&pool, || {
        storage::set_pool_config(&e, &pool_config);
        storage::set_user_positions(&e, &samwise, &user_positions);

        let mut pool = Pool::load(&e);

        let requests = vec![
            &e,
            Request {
                request_type: RequestType::Supply as u32,
                address: underlying.clone(),
                amount: 10_1234567,
            },
            Request {
                request_type: RequestType::Borrow as u32,
                address: underlying.clone(),
                amount: 2_0000000,
            },
            Request {
                request_type: RequestType::Withdraw as u32,
                address: underlying.clone(),
                amount: 10_1234567,
            }
        ];
        let mut user = User::load(&e, &samwise);
        build_actions_from_request(&e, &mut pool, &mut user, requests);
    });
}

Run cargo test test_build_actions_from_request_borrow_errors_over_max_util and we can see that it passes even with the #[should_panic..] removed, meaning the attacker has successfully taken a loan passed the util rate.

Recommended mitigation steps

Move reserve.require_utilization_below_max(e) from apply_borrow to validate_submit which is the function that is called when the built transaction ends.

That way, malicious users cannot bypass this by constructing a malicious execute_submit transaction list.

markus_pl10 (Script3) confirmed

DadeKuma (validator) commented:

Bypassing max util is possible with withdraw, and it’s intended to be that way. The issue seems to be that this is possible for user, even if they don’t provide funds.

mootz12 (Script3) commented:

Validated this is an issue.

The root of the issue is that user’s can borrow past max_util without actually having the funds to perform the actual supply invocation, or maintain the supplied position, to reduce the utilization below max util.

mootz12 (Script3) commented:

Fixed to check max util during validation portion and check 100% util during apply_action.

Blend mitigated:

Commit f35271b to clean up utilization checks.

Status: Mitigation confirmed. Full details in reports from oakcobalt, 0xAlix2, 0x007 and Testerbot.


The original report as published on Code4rena, by rscodes. 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

The utilisation check was performed only inside the borrow action, not at the end of the whole transaction, so temporary supply could inflate the denominator.

Impact

The utilisation limit could be bypassed, pushing the pool towards 100% utilisation and potentially causing lender losses from bad debt in volatile markets.

What the attacker needed

Existing collateral to borrow; no need to actually hold the supplied funds

The fix

The check was moved to the validation step at the end of the transaction and a 100% utilisation check was added during action application; the mitigation was confirmed.

How it was found

  1. Build a transaction containing a supply action, a borrow action, and a withdraw action in that order.
  2. The supply action temporarily increases total_supply.
  3. The borrow action passes the utilisation check because total_supply is inflated.
  4. The withdraw action removes the supplied funds, netting them off, leaving the loan in place above the intended utilisation limit.

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 pool has a safety limit on how much of the deposited money can be borrowed, to protect lenders. The check happened only when borrowing, so an attacker could briefly add money, borrow more than allowed, then take their money back in the same transaction. This left the pool dangerously close to being fully borrowed without the attacker risking their own funds.

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 rscodes

View all

8 more disclosed reports, best first.

More from Blend V2 Audit + Certora Formal Verification

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.