The LibChainlinkOracle.sol
contract specially the getPrice()
function uses the aggregator to get/call the latestRoundData()
. The function should check for the min
and max
amount return to prevent some case happen, something like this:
https://solodit.xyz/issues/missing-checks-for-chainlink-oracle-spearbit-connext-pdf
https://solodit.xyz/issues/m-16-chainlinkadapteroracle-will-return-the-wrong-price-for-asset-if-underlying-aggregator-hits-minanswer-sherlock-blueberry-blueberry-git
If a case like LUNA happens then the oracle will return the minimum price and not the crashed price.
The function tries to get latest price data here:
and returns a value given by uint256(answer).mul(PRECISION).div(10 ** decimals);
Within the function, various checks are made such as checking for an invalid roundId
that is 0
as well as checking for invalid Timestamp
or Answer
by invoking checkForInvalidTimestampOrAnswer()
which returns a boolean indicating the status of the above parameters as shown here:
As it can be seen, this function only checks for non-positive price
i.e if (answer <= 0) return true;
but it does not check for the min/max price
allowable and therefore when the getPrice()
returns the price value, this value can be anything absurdly odd.
Without a check for minimum and maximum allowable prices, the function might return prices that are unreasonably high or low. If the function returns a price that is significantly outside the expected range, it could lead to financial losses for users or the system itself. For instance, if the price returned is much lower than the actual market price for an asset, users might end up selling at a loss, or if the price is excessively high, it could result in overpaying for assets.
Manual Review
As shown in this Documentation:
A circuit breaker should be implemented on the oracle so that when the price edges close to minAnswer
or maxAnswer
it starts reverting.
Configure your application to detect when the reported answer is close to reaching reasonable minimum and maximum limits so it can alert you to potential market events. Separately, configure your application to detect and respond to extreme price volatility or prices that are outside of your acceptable limits.
Some check like this can be added to avoid returning of the `min price or the max price in case of the price crashes.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.