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

Med - Incomplete validation Chainlink Oracle Data Feed

Summary

The absence of a check for round completeness could lead to stale prices and wrong price return value, or outdated prices. The functions that rely on accurate price feed might not work as expected, with sometimes a loss of funds as a result.

Vulnerability Details

The function staleCheckLatestRoundData() calls out to a Chainlink oracle with latestRoundData() to get the price of some token. Although the returned timestamp is checked, there is no check for round completeness.

According to Chainlink's documentation, this function does not give an error if no answer has been reached but returns 0 or outdated round data. The external Chainlink oracle, which provides index price information to the system, introduces risk inherent to any dependency on third-party data sources. For example, the oracle could fall behind or otherwise fail to be maintained, resulting in outdated data being fed to the index price calculations. Oracle reliance has historically resulted in crippled on-chain systems, and complications that lead to these outcomes can arise from things as simple as network congestion.

Impact

If there is a problem with the Chainlink oracle 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 data (if oracles are unable to submit no new round is started).

This could lead to stale prices and wrong price return value, or outdated prices.

As a result, the functions relying on accurate price feed might not work as expected, which sometimes can lead to fund loss, incorrect liquidation, wrong amounts of DSC minted for x collateral, etc.

Tools Used

Manual review

Recommendations

Add the check require(answeredInRound >= roundID, "round not complete"); to the staleCheckLatestRoundData function as shown below.

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(answeredInRound >= roundID, "round not complete");
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.