Skip to content
Business logic Audit finding Intermediate

Public getter preserves stale baseline

The public getter for the last price extends the storage TTL of the circuit-breaker baseline, allowing any unauthenticated caller to keep a stale price alive. An attacker can thereby cause legitimate price queries to fail with a price-change error after the market moves far from the preserved baseline.

v12 Follow

Originally disclosed on Code4rena

Submitted by v12

Found by V12

  • contracts/price-oracle/src/storage.rs #L268

storage::get_last_price is supposed to be a read helper for the circuit-breaker baseline, but it also calls extend_ttl on PersistentKey::LastPrice whenever the entry exists. The contract exposes this helper through the unauthenticated PriceOracle::get_last_price entry point, so any external account can refresh the lifetime of a baseline without producing a new oracle observation. validate_price_change later consumes the same stored value and rejects moves above max_price_change_bps, while a missing value is treated as an uninitialized first query. A patient attacker can therefore keep an old baseline alive across long periods of inactivity on a reserve, even though the underlying market has moved far away from that price. When the asset is used again, the next legitimate price query can fail purely because the attacker preserved stale state through a public getter.

Root Cause

get_last_price is not a pure read: it mutates TTL on a security-critical baseline and is exposed through an unauthenticated public entry point. That makes the lifetime of circuit-breaker state attacker-controlled.

Impact

An attacker can grief a rarely used reserve into a temporary freeze once the real market moves far enough from the attacker-kept baseline. After that, any router flow that needs this asset price can revert with PriceChangeTooLarge until an admin notices and manually resets the circuit breaker.

Remediation

Make the circuit-breaker baseline read helper pure by removing TTL extension from storage::getlastprice. This prevents unauthenticated getlastprice calls from preserving stale baselines; baseline lifetime now only extends when a fresh validated observation is stored via setlastprice.

For suggested patch, see the original finding


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

The read helper mutates the TTL of a security-critical stored baseline and is exposed through an unauthenticated public entry point.

Impact

An attacker can grief a rarely used reserve into a temporary freeze, causing router flows that need the asset price to revert until an admin manually resets the circuit breaker.

What the attacker needed

Unauthenticated access to the public getter; a rarely used reserve; market price moves far from baseline

The fix

The baseline read helper should be made pure by removing TTL extension from the storage getter, so lifetime only extends when a fresh validated observation is stored.

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 stores a 'last price' used as a safety baseline. A public read function was supposed to just return that value, but it also resets the timer that keeps the stored value from expiring. Anyone can call it repeatedly to keep an old price alive, so when the real market price changes a lot, the contract's safety check rejects the new price and the asset becomes temporarily unusable.

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

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.