Chainlink’s latestRoundData might return stale or incorrect results
The ChainlinkAdapter contract calls Chainlink's latestRoundData() without checking whether the returned price is stale or invalid. If Chainlink fails to start a new round or reach consensus, the contract may continue using outdated or incorrect price data.
Originally disclosed on Code4rena
Submitted by nikitastupin, also found by cmichel, defsec, leastwood, and WatchPug
Proof of Concept
The ChainlinkAdapter calls out to a Chainlink oracle receiving the latestRoundData(). If there is a problem with Chainlink starting a new round and finding consensus on the new value for the oracle (e.g. Chainlink nodes abandon the oracle, chain congestion, vulnerability/attacks on the chainlink system) consumers of this contract may continue using outdated stale or incorrect data (if oracles are unable to submit no new round is started).
Recommended Mitigation Steps
Recommend adding the following checks:
( roundId, rawPrice, , updateTime, answeredInRound ) = AggregatorV3Interface(XXXXX).latestRoundData();
require(rawPrice > 0, "Chainlink price <= 0");
require(updateTime != 0, "Incomplete round");
require(answeredInRound >= roundId, "Stale price");
References
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 does not validate the freshness and validity of the price data returned by Chainlink's latestRoundData().
Impact
The contract may use stale or incorrect price data, potentially causing financial loss or incorrect operation.
What the attacker needed
Chainlink oracle fails to update
The fix
Add checks to ensure the returned price is positive, the round is complete, and the price is not stale.
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 an outside service (an oracle) to get the current price of a token. If that service stops updating, the contract might keep using an old price without noticing. This could lead to wrong decisions, like accepting a bad trade.