Skip to content
Business logic Audit finding Intermediate

Disabled oracle assets remain usable through the batch-price TTL cache

The batch price function returns a cached price for an asset before checking whether the asset is enabled, so a disabled asset can still be priced. An attacker could keep borrowing against that asset's collateral after its oracle was disabled as a risk control.

droopytoops Follow with 0xZHD, Arthelion and 22 others

Originally disclosed on Code4rena

Submitted by droopytoops, also found by 0xZHD, Arthelion, cbounty, cht1206, david_xia, Deivitto, dumebi042, GiMu84, harry, hezze, HiteshRajpurohit, hodlturk, indieshipx247, InvisibleDieMinute, junnk6, LIN, marvelous, odeili, qed, SarveshLimaye, Saurabh_Singh, Silvermist, tontobex, and yasuhi829

  • contracts/price-oracle/src/contract.rs #L456-L475
  • contracts/price-oracle/src/contract.rs #L365-L377
  • contracts/price-oracle/src/contract.rs #L471-L475
  • contracts/price-oracle/src/contract.rs #L456-L475

PriceOracleContract::get_asset_prices_vec() checks and returns the TTL cached LastPriceData before it loads the asset configuration and before it verifies config.enabled.

The relevant logic is:

// contracts/price-oracle/src/contract.rs
for (idx, asset) in assets.iter().enumerate() {
    // Try cache first — check both cache freshness and underlying oracle staleness
    if cache_ttl > 0 {
        if let Some(cached) = storage::get_last_price_data(&env, &asset) {
            let cache_age = current_time.saturating_sub(cached.cached_at);
            let price_age = current_time.saturating_sub(cached.timestamp);
            if cache_age <= cache_ttl && price_age <= oracle_config.price_staleness_threshold {
                let price_data = PriceData { price: cached.price, timestamp: cached.timestamp };
                Self::validate_price_change(&env, &asset, &price_data.price, &oracle_config)?;
                results.push_back(Some(price_data));
                continue;
            }
        }
    }

    let config = storage::get_asset_config(&env, &asset)
        .ok_or(OracleError::AssetNotWhitelisted)?;
    if !config.enabled {
        return Err(OracleError::AssetDisabled);
    }

This means a cached price can be served for a disabled asset because the continue executes before the disabled-asset check.

The single-asset oracle path rejects disabled assets, but the router-facing batch path can continue returning a cached price. This creates an inconsistent and unsafe state:

  1. The admin disables an asset in the oracle.
  2. Direct get_asset_price_data(asset) fails as expected.
  3. get_asset_prices_vec([asset]) still returns the cached price.
  4. The router uses that batch price during account-data and borrow validation.
  5. The user can open fresh debt against the disabled asset.

Oracle disablement is a risk-control. It should make the asset fail closed when the asset/feed is unsafe, stale, manipulated, or otherwise should not be used for solvency calculations. Because the cache path bypasses config.enabled, disabling the asset does not reliably remove it from lending calculations.

Impact

Users can continue borrowing against collateral after the asset’s oracle pricing has been disabled. If the asset was disabled because the feed was compromised, stale, broken, or no longer trusted, the protocol can accept unsafe collateral valuations and issue fresh debt against them.

This is not only a view inconsistency. The PoC demonstrates that the router accepts the cached disabled price and mints debt to the user.

Recommended mitigation

get_asset_prices_vec() should validate the asset configuration before returning cached data.

The disabled check should happen before the cache lookup:

let config = storage::get_asset_config(&env, &asset)
    .ok_or(OracleError::AssetNotWhitelisted)?;
if !config.enabled {
    return Err(OracleError::AssetDisabled);
}

// Only after this point should cached LastPriceData be considered.

Additionally, set_asset_enabled(asset, false) should clear LastPriceData for that asset so stale cached prices cannot survive an explicit risk-control change.

Proof of Concept

See original finding for full Proof of Concept


The original report as published on Code4rena, by droopytoops. 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 cache lookup and its early `continue` run before the asset configuration is loaded and `config.enabled` is checked.

Impact

Users could continue borrowing against collateral after the asset's oracle pricing was disabled, so unsafe collateral valuations may be accepted and fresh debt issued.

What the attacker needed

An asset is disabled by the admin; a fresh cached price exists for it; router uses the batch price path

The fix

The asset configuration and enabled check should be validated before any cached price is returned, and disabling an asset should also clear its cached price data.

How it was found

  1. The admin disables an asset in the oracle.
  2. A direct single-asset price call fails as expected.
  3. The batch price call for that asset still returns the cached price.
  4. The router uses that batch price during account-data and borrow validation.
  5. The user opens fresh debt against the disabled asset.

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 price oracle tells a lending app what an asset is worth. The app can switch an asset off if its price feed becomes unsafe, but the batch price function looks in a short-lived cache first and skips the 'is this asset switched off?' check. So the app can still value that asset and let someone borrow against it.

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 from K2

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.