Skip to content
DoS Audit finding Intermediate

Broken asset-list invariant causes DoS and orphaned whitelist state

The asset list in a price oracle contract can grow beyond its intended maximum because the add function does not enforce the cap. Once oversized, removing an asset truncates the list, orphaning later assets and causing bulk operations to fail or skip assets.

v12 Follow

Originally disclosed on Code4rena

Submitted by v12

Found by V12

  • contracts/price-oracle/src/storage.rs #L229
  • contracts/price-oracle/src/storage.rs #L251
  • contracts/price-oracle/src/storage.rs #L147
  • contracts/price-oracle/src/storage.rs #L116
  • contracts/price-oracle/src/contract.rs #L625
  • contracts/price-oracle/src/storage.rs #L156
  • contracts/price-oracle/src/storage.rs #L199

Targets

  • storage::addtoasset_list
  • storage::removefromasset_list
  • PriceOracleContract::remove_asset
  • PriceOracleContract::setoracleconfig
  • PriceOracleContract::resetallcircuit_breakers
  • PriceOracleContract::getwhitelistedassets
  • storage::getassetlist

Affected Locations

  • storage.addtoasset_list: add_to_asset_list checks duplicates over asset_list.len().min(MAX_RESERVES) and then unconditionally appends, so AssetList can grow past the documented cap.
  • storage.removefromasset_list: remove_from_asset_list rebuilds and overwrites AssetList using only asset_list.len().min(MAX_RESERVES) entries, which truncates any tail beyond index 63 once oversized state exists.
  • PriceOracleContract.remove_asset: remove_asset deletes config only for the explicitly removed asset, so truncation in AssetList can orphan later assets whose per-asset records remain in storage.
  • PriceOracleContract.setoracleconfig: set_oracle_config iterates over the full result of get_asset_list, so an oversized or truncated list causes either excessive work or missed assets during bulk updates.
  • PriceOracleContract.resetallcircuit_breakers: reset_all_circuit_breakers also trusts get_asset_list for full-list iteration, inheriting both the unbounded-loop and orphaned-asset behaviors.
  • PriceOracleContract.getwhitelistedassets: get_whitelisted_assets exposes the stored list directly, so callers observe either an oversized whitelist or a truncated one that no longer matches per-asset storage.
  • storage.getassetlist: get_asset_list returns the full stored vector and serves as the source of truth for list-driven admin and view operations.

Description

AssetList is treated throughout the oracle as if it is permanently bounded by MAX_RESERVES, but the storage helpers do not actually maintain that invariant. add_to_asset_list can grow the list past 64, after which get_asset_list propagates an oversized vector into public enumeration and bulk maintenance paths that iterate over the entire list. Once such oversized state exists, remove_from_asset_list rewrites storage from only the first MAX_RESERVES entries, so removing any asset silently drops every later entry from the canonical list even though their per-asset records remain configured. That means the same invariant break causes both a liveness failure for full-list operations and a persistent desynchronization where list-based administration no longer reaches orphaned assets. The correct fix is to enforce or validate the MAX_RESERVES bound consistently in all list mutation paths and to ensure removal preserves the full list instead of truncating it.

Root Cause

The code relies on AssetList always satisfying the MAX_RESERVES invariant, but add_to_asset_list, remove_from_asset_list, and related list handling do not enforce or preserve that invariant.

Impact

A malicious or compromised oracle admin can bloat AssetList until calls such as set_oracle_config, reset_all_circuit_breakers, or get_whitelisted_assets become too expensive to execute reliably. After the list is oversized, removing a single asset can also hide still-configured assets from canonical enumeration, causing bulk config changes and circuit-breaker resets to skip them while stale per-asset state remains in storage. Repair then requires manual cleanup of inconsistent whitelist and asset configuration state.

Proof of Concept

See original finding for full Proof of Concept

The original report as published on Code4rena, by v12. 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 add and remove functions for the asset list do not enforce or preserve the maximum size invariant, allowing the list to grow unbounded and then truncating it on removal.

Impact

A malicious or compromised oracle admin could bloat the asset list, making bulk operations too expensive, and then removing one asset can hide still-configured assets from enumeration, causing bulk updates and circuit-breaker resets to skip them while stale state remains.

What the attacker needed

Compromised or malicious oracle admin

The fix

The fix should enforce the MAX_RESERVES bound consistently in all list mutation paths and ensure removal preserves the full list instead of truncating it.

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 smart contract keeps a list of assets it tracks, and the code assumes this list never grows beyond a fixed size. However, the function that adds assets does not check the size, so the list can become too long. Later, when an asset is removed, the code only keeps the first part of the list, silently dropping other assets that are still configured, which can break maintenance operations.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by v12

View all

37 more disclosed reports, best first.

More from K2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.