DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: low
Invalid

`ChainlinkUtil::getPrice()` function will revert when `answer` is equal to `minAnswer` or `maxAnswer` values came from aggregator.

Vulnerability Details

In getPrice() function when aggregator.minAnswer() and aggregator.maxAnswer() are called they will return min. and max. answer values in price range. When the answer came from priceFeed.latestRoundData() will be equal to one of these values that should be considered valid price. Since it is within the range

But currently when answer is equal to minAnswer or maxAnswer the function will revert with Errors.OraclePriceFeedOutOfRange(address(priceFeed)) error. This is wrong. The minAnswer or maxAnswer allowed prices from range that's why when answer is equal to one of these the answer must be considered valid. But currently it will be considered invalid and function will revert.

File : src/external/chainlink/ChainlinkUtil.sol
59: try priceFeed.latestRoundData() returns (uint80, int256 answer, uint256, uint256 updatedAt, uint80) {
60: if (block.timestamp - updatedAt > priceFeedHeartbeatSeconds) {
61: revert Errors.OraclePriceFeedHeartbeat(address(priceFeed));
62: }
63:
64: IOffchainAggregator aggregator = IOffchainAggregator(priceFeed.aggregator());
65: int192 minAnswer = aggregator.minAnswer();
66: int192 maxAnswer = aggregator.maxAnswer();
67:
68: if (answer <= minAnswer || answer >= maxAnswer) {//@audit minAnswer and maxAnswer also excluded as out of range price
69: revert Errors.OraclePriceFeedOutOfRange(address(priceFeed));
70: }

ChainlinkUtil.sol#L59-L70

Impact

Valid answer value will be considered invalid. When answer is equal to minAnswer or maxAnswer the function will revert with Errors.OraclePriceFeedOutOfRange(address(priceFeed)) error.

Tools used

Manual review

Recommendation

Do not revert it when answer is equal to minAnswer or maxAnswer.

File : src/external/chainlink/ChainlinkUtil.sol
-68: if (answer <= minAnswer || answer >= maxAnswer) {
+68: if (answer < minAnswer || answer > maxAnswer) {
69: revert Errors.OraclePriceFeedOutOfRange(address(priceFeed));
70: }
Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Appeal created

0x11singh99 Submitter
about 1 year ago
inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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