You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
sherlock-admin opened this issue
May 23, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
Chainlink's latestRoundData might return stale or incorrect results
Summary
Chainlink's latestRoundData might return stale or incorrect results
Vulnerability Detail
Impact
The getPriceUSD() function in the contracts StableOracleDAI.sol, StableOracleWBTC.sol, StableOracleWETH.sol fetches the asset price from a Chainlink aggregator using the latestRoundData function. However, there are no checks on roundID, resulting in stale prices. The oracle wrapper calls out to a chainlink oracle receiving the latestRoundData().
Stale prices could put funds at risk. According to Chainlink's documentation, This function does not error if no answer has been reached but returns 0, causing an incorrect price fed to the PriceOracle. 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.
Code Snippet
In StableOracleDAI.sol, getPriceUSD ( ) use latestRoundData() which is given as below,
File: contracts/oracles/StableOracleDAI.sol
function getPriceUSD() externalviewoverridereturns (uint256) {
address[] memory pools =newaddress[](1);
pools[0] =0x60594a405d53811d3BC4766596EFD80fd545A270;
uint256 DAIWethPrice = DAIEthOracle.quoteSpecificPoolsWithTimePeriod(
1000000000000000000, // 1 Eth0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // WETH (base token)0x6B175474E89094C44Da98b954EedeAC495271d0F, // DAI (quote token)
pools, // DAI/WETH pool uni v3600// period
);
uint256 wethPriceUSD = ethOracle.getPriceUSD();
// chainlink price data is 8 decimals for WETH/USD, so multiply by 10 decimals to get 18 decimal fractional//(uint80 roundID, int256 price, uint256 startedAt, uint256 timeStamp, uint80 answeredInRound) = priceFeedDAIETH.latestRoundData();
(, int256price, , , ) = priceFeedDAIETH.latestRoundData();
return
(wethPriceUSD *1e18) /
((DAIWethPrice +uint256(price) *1e10) /2);
}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
MohammedRizwan
medium
Chainlink's latestRoundData might return stale or incorrect results
Summary
Chainlink's latestRoundData might return stale or incorrect results
Vulnerability Detail
Impact
The getPriceUSD() function in the contracts StableOracleDAI.sol, StableOracleWBTC.sol, StableOracleWETH.sol fetches the asset price from a Chainlink aggregator using the latestRoundData function. However, there are no checks on roundID, resulting in stale prices. The oracle wrapper calls out to a chainlink oracle receiving the latestRoundData().
Stale prices could put funds at risk. According to Chainlink's documentation, This function does not error if no answer has been reached but returns 0, causing an incorrect price fed to the PriceOracle. 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.
Code Snippet
In StableOracleDAI.sol, getPriceUSD ( ) use latestRoundData() which is given as below,
Link to code
In StableOracleWBTC.sol, getPriceUSD ( ) use latestRoundData() which is given as below,
Link to code
In StableOracleWETH.sol, getPriceUSD ( ) use latestRoundData() which is given as below,
Link to code
Tool used
Manual Review
Recommendation
Consider adding missing checks for stale data.
For example:
(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");
Duplicate of #31
The text was updated successfully, but these errors were encountered: