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

Chainlink price feeds can go stale

Summary

Chainlink price feeds can go stale, so there should be check to make sure they are not stale.

If the Chainlink feed goes stale, and the protocol is relying on it, then the protocol could be at risk.

Vulnerability Detail

Stale price check is missing

Impact

If the Chainlink feed goes stale, and the protocol is relying on it, then the protocol could be at risk.

Code Snippet

function getUsdValue(address token, uint256 amount) public view returns (uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(s_priceFeeds[token]);
(, int256 price,,,) = priceFeed.staleCheckLatestRoundData();
// 1 ETH = $1000
// The returned value from CL will be 1000 * 1e8
return ((uint256(price) * ADDITIONAL_FEED_PRECISION) * amount) / PRECISION;
}

Tool used

Recommendation

Check the price of the chainlink aggregator

function getUsdValue(address token, uint256 amount) public view returns (uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(s_priceFeeds[token]);
(, int256 price,,,) = priceFeed.staleCheckLatestRoundData();
// Check if the price retrieved is greater than zero
require(price > 0, "Invalid price from Chainlink");
// 1 ETH = $1000
// The returned value from CL will be 1000 * 1e8
return ((uint256(price) * ADDITIONAL_FEED_PRECISION) * amount) / PRECISION;
}

Support

FAQs

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