Skip to content
Business logic Audit finding Intermediate

Inconsistency in staleness checks between OHM and reserve token oracles

The price oracle contract uses inconsistent staleness thresholds for two Chainlink feeds: one allows three times the observation frequency, the other only one times. This could cause the price retrieval function to revert when the stricter feed is not updated within that shorter window.

okkothejawa Follow

Originally disclosed on Code4rena

Submitted by okkothejawa, also found by datapunk, reassor, and Trust

https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L165-L171

Price oracle may fail and revert due to the inconsistency in the staleness checks.

Proof of Concept

In the getCurrentPrice() of PRICE.sol, Chainlink oracles are used to get the price of OHM against a reserve token, and a staleness check is used to make sure the price oracles are reporting fresh data. Yet the freshness requirements are inconsistent, for OHM, updatedAt should be lower than current timestamp minus three times the observation frequency, while for the reserve price, it is required that updatedAt should be lower than current timestamp minus the observation frequency. Our understanding is that that frequency is multiplied by 3 so that there can be some meaningful room where price data is accepted, as the time frame of only observation frequency (multiplied by 1) may not be enough for the oracle to realistically update its data. (In other words, the frequency of new price information might be lower than the observation frequency, which is probably the case as third multiple is used for the OHM price). If this is the case, this inconsistency may lead to the getCurrentPrice() reverting as while third multiple of the observation frequency might give enough space for the first oracle, second oracle’s first multiple of frequency time frame might not be enough and it couldn’t pass the staleness check due to unrealistic expectation of freshness.

Tools Used

Manual review, talking with devs

Recommended Mitigation Steps

Change the line 171 to

            if (updatedAt < block.timestamp - 3 * uint256(observationFrequency))

like line 165.

Oighty (Olympus) confirmed and commented:

This should indeed be the same. We will update to fix.


The original report as published on Code4rena, by okkothejawa. 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 a copy-paste or oversight in the staleness check for the reserve token oracle, using one times the observation frequency instead of three times as done for the OHM oracle.

Impact

The price retrieval function could revert, making the oracle unavailable when the reserve token feed is not updated within the shorter window.

What the attacker needed

Reserve token oracle updates slower than observation…

The fix

The staleness check for the reserve token oracle should use three times the observation frequency, matching the OHM oracle, and the project confirmed it will update to fix.

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 gets prices from two outside services (oracles). It checks that each price is recent enough, but it uses a longer allowed age for one price and a shorter allowed age for the other. If the second service updates less often than expected, the check fails and the whole price lookup stops working.

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 Olympus DAO contest

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.