Skip to content
Crypto Audit finding Intermediate

[NAZ-M1] Chainlink’s latestRoundData Might Return Stale Results

The contract only checks the updatedAt timestamp from Chainlink's latestRoundData, ignoring other staleness indicators. An attacker could exploit stale prices to cause loss of funds to end-users.

0xNazgul Follow

Originally disclosed on Code4rena

Submitted by 0xNazgul, also found by 141345, 0x1f8b, ak1, brgltd, cccz, csanuragjain, Dravee, Guardian, hyh, IllIllI, itsmeSTYJ, Jujic, Lambda, pashov, peachtea, rbserver, reassor, Sm4rty, TomJ, and zzzitron

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

Across these contracts, you are using Chainlink’s latestRoundData API, but there is only a check on updatedAt. This could lead to stale prices according to the Chainlink documentation:

The result of latestRoundData API will be used across various functions, therefore, a stale price from Chainlink can lead to loss of funds to end-users.

Recommended Mitigation Steps

Consider adding the missing checks for stale data.

For example:

(uint80 roundID ,answer,, uint256 timestamp, uint80 answeredInRound) = AggregatorV3Interface(chainLinkAggregatorMap[underlying]).latestRoundData();

require(answer > 0, "Chainlink price <= 0");
require(answeredInRound >= roundID, "Stale price");
require(timestamp != 0, "Round not complete");

Oighty (Olympus) confirmed and commented:

Agree. We’ll add the additional checks.


The original report as published on Code4rena, by 0xNazgul. 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 contract only checks the updatedAt timestamp from latestRoundData and does not verify that the answer is positive, that answeredInRound is at least roundID, or that timestamp is non-zero.

Impact

A stale price from Chainlink could lead to loss of funds to end-users.

What the attacker needed

Chainlink price feed returns stale data

The fix

The contract should be fixed by adding checks for stale data, such as requiring answer > 0, answeredInRound >= roundID, and timestamp != 0.

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 uses a price feed from Chainlink to get the latest price of an asset. The contract only checks when the price was last updated, but not whether the price is actually fresh according to other checks. If the price is stale, the contract might use an old price, which could be exploited to cause financial loss.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by 0xNazgul

View all

6 more disclosed reports, best first.

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.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.