Cached oracle prices ignore per-asset freshness limits
Cached oracle prices were validated only against the global staleness threshold and cache TTL, ignoring the stricter per-asset max_age limit that fresh reads enforce. An attacker could warm the cache while a favourable quote was valid, wait for the asset-specific heartbeat to expire, and keep using the stale price to over-borrow, delay liquidations or liquidate at an unfair bonus.
v12 Follow with 0xsolisec, abdelhaq16 and 2 others
Originally disclosed on Code4rena
Submitted by v12, also found by 0xsolisec, abdelhaq16, Bale, and qed
Found by V12
contracts/price-oracle/src/contract.rs#L319contracts/price-oracle/src/contract.rs#L438contracts/kinetic-router/src/liquidation.rs#L53contracts/price-oracle/src/oracle.rs#L287contracts/price-oracle/src/oracle.rs#L376
Targets
- PriceOracleContract::getassetpricedatawith_config
- PriceOracleContract::getassetprices_vec
- PriceOracleContract::getassetprices_batch
- PriceOracle::querycustomoracle
- PriceOracleContract::querybatchadapter_direct
Affected Locations
- PriceOracleContract.getassetpricedatawith_config: Cache-hit validation accepts
LastPriceDatausingcache_age <= cache_ttlandprice_age <= oracle_config.price_staleness_threshold, but does not re-applyAssetConfig.max_agebefore returning a cached price. - PriceOracleContract.getassetprices_vec: The batched price path also serves cached entries under the global staleness threshold only, so downstream callers can receive prices that already exceeded the asset-specific heartbeat.
- PriceOracleContract.getassetprices_batch: Router-side batch consumption trusts the oracle response and applies separate freshness settings, so it does not restore the source-specific
max_ageinvariant. - PriceOracle.querycustomoracle: Fresh external custom-oracle reads enforce the stricter per-asset freshness rule, highlighting that the inconsistency is introduced only when the cached path is taken.
- PriceOracleContract.querybatchadapter_direct: Fresh adapter reads honor
config.max_age, but that protection is lost once the value is stored and later returned from cache.
Description
The oracle enforces stricter freshness limits through AssetConfig.max_age when it fetches fresh prices from custom or batch adapters, but that invariant is dropped after the value enters LastPriceData. On cache hits, both get_asset_price_data_with_config and get_asset_prices_vec validate only against oracle_config.price_staleness_threshold plus the cache TTL, so an asset configured for a short heartbeat can still be served for the broader global window. Because callers such as get_asset_prices_batch and router flows consume the returned timestamp under separate staleness settings, they do not re-enforce the asset-specific limit. Public price-refreshing paths let an attacker warm the cache while a favorable quote is valid, then wait until max_age has expired and continue using that stale price. The same code change fixes all reported variants: cached entries must be rejected once they exceed the effective per-asset freshness bound, not just the global threshold.
Root Cause
Cache validation in get_asset_price_data_with_config and get_asset_prices_vec uses only the global oracle_config.price_staleness_threshold instead of the effective per-asset freshness limit derived from AssetConfig.max_age.
Impact
For assets that depend on a tighter max_age, users can borrow, withdraw, or liquidate against prices older than the protocol explicitly configured as acceptable. If markets move during that gap, attackers can over-borrow, delay necessary liquidations and increase bad debt, or liquidate positions using stale valuations and capture collateral at an unfair bonus.
Proof of Concept
See this gist for full Proof of Concept
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
Cache validation in get_asset_price_data_with_config and get_asset_prices_vec uses only the global oracle_config.price_staleness_threshold instead of the effective per-asset freshness limit derived from AssetConfig.max_age.
Impact
For assets with a tighter max_age, users could borrow, withdraw or liquidate against prices older than configured, potentially allowing over-borrowing, delayed liquidations and bad debt, or unfair liquidation bonuses.
What the attacker needed
Public price-refresh path; asset with a tight max_age; market moves during the gap
The fix
Cached entries should be rejected once they exceed the effective per-asset freshness bound, not just the global threshold.
How it was found
- Warm the cache through a public price-refreshing path while a favourable quote is still valid.
- Wait until the asset-specific max_age has expired but the global staleness threshold has not.
- Consume the cached price through borrowing, withdrawal or liquidation flows that trust the returned timestamp.
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 is a service that tells a lending app what an asset is worth. Each asset can have its own rule for how old a price may be before it is considered too stale to trust. Here the app checked only a loose global age limit when it reused a saved (cached) price, so a price that was too old under the asset's own stricter rule was still accepted.