LatestRoundData Call May Result Stale
The contract reads the sequencer uptime feed via latestRoundData without checking whether the returned data is fresh. If Chainlink cannot start a new round or reach consensus, consumers could keep using stale or incorrect data.
Originally disclosed on Immunefi
- Disclosed after under an hour
29445 - [SC - Insight] latestRoundData Call May Result Stale
Submitted on Mar 19th 2024 at 05:06:55 UTC by @caglankaan for Boost | Immunefi Arbitration
Report ID: #29445
Report type: Smart Contract
Report severity: Insight
Target: https://github.com/immunefi-team/vaults/blob/main/src/oracles/FeedRegistryL2.sol
Impacts:
- Stale Data Can Be Used
Description
Brief/Intro
Data returned from chainlink might be old.
Vulnerability Details
The contract 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).Take a look at the Chainlink documentation
Impact Details
The latestRoundData() could return stale price data for the underlying asset.
References
Path: ./src/oracles/FeedRegistryL2.sol
100: (, int256 answer, uint256 startedAt, , ) = SEQUENCER_UPTIME_FEED.latestRoundData(); // @audit-issue
Recommendation
Implement comprehensive checks to validate the freshness of the data returned by Chainlink's latestRoundData() in your smart contracts. This includes verifying the timestamp of the latest round against a permissible time window to ensure the data's relevance and accuracy. Additionally, consider using Chainlink's getRoundData() function with specific round IDs for historical data checks and to verify data continuity. Add 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");
...
Proof of Concept
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 calls latestRoundData without validating the update timestamp or round completeness.
Impact
The latestRoundData() could return stale price data for the underlying asset.
What the attacker needed
Chainlink fails to update the feed
The fix
The contract should check that the returned price is positive, the update time is non-zero, and the answered round is at least the current round, and should validate freshness against a time window.
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 can ask an outside service, called an oracle, for a price or status. This report says the contract never checks how old that answer is, so it might act on an old answer. An attacker cannot directly force this, but stale data could lead to wrong decisions.