Closed sherlock-admin2 closed 1 year ago
2 comment(s) were left on this issue during the judging contest.
Trumpero commented:
invalid/low, the code already validated the chainlink results, and issues related to chainlink round completeness is invalid
YakuzaKiawe commented:
invalid. See here
Oxhunter526
medium
Chainlink's
latestRoundData
return stale or incorrect resultSummary
The function
getPriceInEth
in the provided code lacks a comprehensive check for stale or outdated data returned by the Chainlink Oracle'slatestRoundData
function. This omission could lead to the usage of inaccurate or obsolete price information for tokens.Vulnerability Detail
The
getPriceInEth
function is designed to retrieve the price of a token in terms of Ethereum (ETH) from the Chainlink Oracle network. While the code includes checks for the round ID, price, and timestamp, it does not adequately address the possibility of receiving stale or outdated data from the Chainlink Oracle.Specifically, the following factors contribute to this vulnerability:
updatedAt
timestamp with the current block's timestamp. If theupdatedAt
timestamp is earlier than a certain threshold (defined bytokenPricingTimeout
), the function reverts. However, this check only ensures that the data is not too old according to the specified threshold, without considering the possibility of the data being stale or delayed.updatedAt
timestamp indicates that the data is up to date, but in reality, the data might still be delayed or not reflecting the latest market conditions.Impact
The lack of a comprehensive check for stale or delayed data can have significant implications. If the Chainlink Oracle experiences delays in updating its price feed, the function might continue to use outdated data, leading to incorrect pricing information being used in the smart contract logic. This could result in inaccurate decisions and actions based on the token prices obtained from the Chainlink Oracle.
Code Snippet
( https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/oracles/providers/ChainlinkOracle.sol#L103-L124 )
Tool used
Manual Review
Recommendation
To address this issue, it's essential to implement a thorough check for both data freshness and staleness in the
getPriceInEth
function. This can be achieved by comparing theupdatedAt
timestamp with both the current block's timestamp and a maximum allowable data age. Here's how to mitigate the vulnerability:By introducing the
maxDataAge
check, the function will not only ensure that the data is not too old but will also flag data that, while technically within the freshness threshold, is too outdated to be considered reliable. This enhancement helps in guarding against the usage of potentially inaccurate or stale price data in the smart contract's decision-making process.