Skip to content
DoS Audit finding Advanced

During oracle provider switch, if previous provider feed stops working completely, oracle and market will be stuck with user funds locked in the contract

When switching oracle providers, the protocol continues to use the previous provider's price feed until a final price is committed. If that feed stops working permanently, no valid price can be committed, so the oracle and market become stuck, preventing users from withdrawing funds.

panprog Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-09-perennial-judging/issues/10

Found by

panprog

The issue 46 of the main contest after the fix still stands with a more severe condition as described by WatchPug in fix review:

If we assume it's possible for the previous Python feed to experience a more severe issue: instead of not having an eligible price for the requested oracleVersion, the feed completely stopped working after the requested time, making it impossible to find ANY valid price at a later time than the last requested time, this issue would still exist.

Sponsor response still implies that the previous provider feed is available, as they say non-requested version could be posted, but if this feed is no longer available, it will be impossible to commit unrequested, because there will be no pyth price and signature to commit.

if the previous oracle’s underlying off-chain feed goes down permanently, once the grace period has passed, a non-requested version could be posted to the previous oracle, moving its latest() forward to that point, allowing the switchover to complete.

Vulnerability Detail

When the oracle provider is updated (switched to a new provider), the latest status (price) returned by the oracle will come from the previous provider until the last request is commited for it, only then the price feed from the new provider will be used. However, it can happen that pyth price feed stops working completely before (or just after) the oracle is updated to a new provider. This means that valid price with signature for any timestamp after the last request is not available. In this case, the oracle price will be stuck, because it will ignore new provider, but the previous provider can never finalize (commit a fresh price). As such, the oracle price will get stuck and will never update, breaking the whole protocol with user funds stuck in the protocol.

Impact

Switching oracle provider can make the oracle stuck and stop updating new prices. This will mean the market will become stale and will revert on all requests from user, disallowing to withdraw funds, bricking the contract entirely.

Code Snippet

Oracle._latestStale will always return false due to this line (since latest().timestamp can never advance without a price feed): https://github.com/sherlock-audit/2023-09-perennial/blob/main/perennial-v2/packages/perennial-oracle/contracts/Oracle.sol#L128

Tool used

Manual Review

Recommendation

Consider ignoring line 128 in Oracle._latestStale if a certain timeout has passed after the switch (block.timestamp - oracles[global.latest].timestamp > SWITCH_TIMEOUT). This will allow the switch to proceed after some timeout even if previous provider remains uncommited.

Discussion

sherlock-admin

1 comment(s) were left on this issue during the judging contest.

polarzero commented:

Medium. The issue is also preoccupying. It does also require a few unlikely conditions, yet it could incur a significant loss of funds for the users.

The original report as published on Sherlock, by panprog. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 oracle's staleness check never allows the switch to complete because it requires a fresh price from the previous provider, which is impossible if that feed is permanently down.

Impact

The oracle and market become permanently stuck, reverting all user requests and locking funds, though the report notes this requires unlikely conditions such as the previous feed going down permanently.

What the attacker needed

Oracle provider switch is initiated; previous price feed stops permanently; grace period passes without a commit

The fix

The oracle should ignore the staleness check after a timeout following the switch, allowing the switch to proceed even if the previous provider never commits.

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 relies on an outside service (an oracle) to provide price data. The protocol was designed to switch to a new price provider, but it waits for one last price from the old provider before completing the switch. If the old provider stops working entirely, that last price never arrives, so the contract freezes and users cannot get their money out.

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 panprog

View all

66 more disclosed reports, best first.

More from Perennial V2 Update #1

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.