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

chainlink latestrounddata can still return stale or incorrect results

Summary

chainlink latestrounddata can still return stale or incorrect results

Vulnerability Details

chailink latestround data have some validations but still can return value indicates stale data. This could lead to stale prices according to the Chainlink documentation:

function staleCheckLatestRoundData(AggregatorV3Interface priceFeed)
public
view
returns (uint80, int256, uint256, uint256, uint80)
{
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
priceFeed.latestRoundData();
uint256 secondsSince = block.timestamp - updatedAt;
if (secondsSince > TIMEOUT) revert OracleLib__StalePrice();
return (roundId, answer, startedAt, updatedAt, answeredInRound);
}
function getTimeout(AggregatorV3Interface /* chainlinkFeed */ ) public pure returns (uint256) {
return TIMEOUT;
}
}

https://docs.chain.link/docs/historical-price-data/#historical-rounds
https://docs.chain.link/docs/faq/#how-can-i-check-if-the-answer-to-a-round-is-being-carried-over-from-a-previous-round

Impact

This function does not error if no answer has been reached but returns 0, causing an incorrect price fed to the

Tools Used

Recommendations

Consider adding missing checks for stale data.

(uint80 roundID, int256 feedPrice, , uint256 timestamp, uint80 answeredInRound) = feed.latestRoundData();
require(feedPrice > 0, "Chainlink price <= 0");
require(answeredInRound >= roundID, "Stale price");
require(timestamp != 0, "Round not complete");

Support

FAQs

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