15,000 USDC
View results
Submission Details
Severity: medium
Valid

Chainlink price can be stale price as its validity is not checked

Summary

Vulnerability Details

If Chainlink's latestRoundData() is called while the previous round is valid and new round has struggles to establish consensus on the new value for the oracle, the price return from the aforementioned function becomes stale. Without proper checks, consumers of this contract may continue using outdated, stale, or incorrect data if oracles are unable to submit and start a new round.

Impact

Stale price will be returned in the case of lack of validity checks

Tools Used

Manual Review

Recommendations

Consider adding these checks in the function staleCheckLatestRoundData():

function staleCheckLatestRoundData(AggregatorV3Interface priceFeed)
public
view
returns (uint80, int256, uint256, uint256, uint80)
{
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
priceFeed.latestRoundData();
require(answer > 0, "Chainlink price <= 0");
require(updatedAt != 0, "Incomplete round");
require(answeredInRound >= roundId, "Stale price");
uint256 secondsSince = block.timestamp - updatedAt;
if (secondsSince > TIMEOUT) revert OracleLib__StalePrice();
return (roundId, answer, startedAt, updatedAt, answeredInRound);
}

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.