Closed sherlock-admin closed 1 year ago
helpMePlease
medium
https://github.com/sherlock-audit/2023-04-blueberry/blob/96eb1829571dc46e1a387985bd56989702c5e1dc/blueberry-core/contracts/oracle/ChainlinkAdapterOracle.sol#L87
There isn't any kind of condition to check if the return value indicates stale data.
On ChainlinkAdapterOracle.sol, you are using latestRoundData, but there is no check if the return value indicates stale data.
function getPrice(address token_) external view override returns (uint256) { // remap token if possible address token = remappedTokens[token_]; if (token == address(0)) token = token_; uint256 maxDelayTime = timeGaps[token]; if (maxDelayTime == 0) revert Errors.NO_MAX_DELAY(token_); // Get token-USD price uint256 decimals = registry.decimals(token, USD); (, int256 answer, , uint256 updatedAt, ) = registry.latestRoundData( token, USD ); if (updatedAt < block.timestamp - maxDelayTime) revert Errors.PRICE_OUTDATED(token_); if (answer <= 0) revert Errors.PRICE_NEGATIVE(token_); return (answer.toUint256() * Constants.PRICE_PRECISION) / 10 ** decimals; }
This could lead to stale prices according to the Chainlink documentation: https://docs.chain.link/data-feeds/price-feeds/historical-data Related report: https://github.com/sherlock-audit/2023-02-blueberry-judging/issues/94
Manual Review
function getPrice(address _token) external view override returns (uint256) { // remap token if possible address token = remappedTokens[_token]; if (token == address(0)) token = _token; uint256 maxDelayTime = maxDelayTimes[token]; if (maxDelayTime == 0) revert NO_MAX_DELAY(_token); // try to get token-USD price uint256 decimals = registry.decimals(token, USD); (uint80 roundID, int256 answer, uint256 timestamp, uint256 updatedAt, ) = registry.latestRoundData( token, USD ); //Solution require(updatedAt >= roundID, "Stale price"); require(timestamp != 0,"Round not complete"); require(answer > 0,"Chainlink answer reporting 0"); if (updatedAt < block.timestamp - maxDelayTime) revert PRICE_OUTDATED(_token); return (answer.toUint256() * 1e18) / 10**decimals; }
Duplicate of #118
helpMePlease
medium
Chainlink's latestRoundData return stale or incorrect result
Summary
Vulnerability Detail
https://github.com/sherlock-audit/2023-04-blueberry/blob/96eb1829571dc46e1a387985bd56989702c5e1dc/blueberry-core/contracts/oracle/ChainlinkAdapterOracle.sol#L87
There isn't any kind of condition to check if the return value indicates stale data.
Impact
On ChainlinkAdapterOracle.sol, you are using latestRoundData, but there is no check if the return value indicates stale data.
This could lead to stale prices according to the Chainlink documentation: https://docs.chain.link/data-feeds/price-feeds/historical-data Related report: https://github.com/sherlock-audit/2023-02-blueberry-judging/issues/94
Code Snippet
https://github.com/sherlock-audit/2023-04-blueberry/blob/96eb1829571dc46e1a387985bd56989702c5e1dc/blueberry-core/contracts/oracle/ChainlinkAdapterOracle.sol#L87
Tool used
Manual Review
Recommendation
Duplicate of #118