sherlock-audit / 2023-11-olympus-judging

9 stars 7 forks source link

shealtielanz - `ChainlinkPriceFeeds.sol` will return the wrong price for an asset if underlying aggregator hits `minAnswer` or `maxAnswer` as `_validatePriceFeedResult()` doesn't check against it. which will affect the `RBS` #182

Closed sherlock-admin2 closed 6 months ago

sherlock-admin2 commented 6 months ago

shealtielanz

medium

ChainlinkPriceFeeds.sol will return the wrong price for an asset if underlying aggregator hits minAnswer or maxAnswer as _validatePriceFeedResult() doesn't check against it. which will affect the RBS

Summary

Chainlink Aggregators have a built-in circuit breaker if the price of an asset goes outside of a predetermined price band. The result is that if an asset experiences a huge drop in value (i.e. LUNA crash) the price of the oracle will continue to return the minPrice instead of the actual price of the asset.

This would allow user to continue trading/borrowing with the asset but at the wrong price(for Cooler Loans), and can distabilized the RBS(Range Bound Stability) system.

Example: TokenA has a minPrice of $1. The price of TokenA drops to $0.10. The aggregator still returns $1 allowing the user to trade/borrow against TokenA as if it is $1 which is 10x it's actual value.

Note: Chainlink oracle is used a just one piece of the Price/Oracle system and it is assumed that using a combination of other oracles, a scenario like this can be avoided. However, this is not the case because the other oracles also have their flaws that can still allow this to be exploited. As an example if the chainlink oracle is being used with a UniswapV3Oracle which uses a long TWAP then this will be exploitable when the TWAP is near the minPrice on the way down.

Impact

ChainlinkPriceFeeds.sol is part of the PRICE Module, and as per Olympus V3 Overview

`PRICE` — Used to store historical price oracle data. Used for the functionality of the Range-Bound Stability (RBS) system.

In the event that an asset crashes (i.e. LUNA) the Range-Bound Stability (RBS) system will be affected and can be manipulated to Trade/loan at an inflated price.

Code Snippet

Manual Review & Solodit

Recommendation

_validatePriceFeedResult() should check the returned answer against the minPrice/maxPrice and revert if the answer is outside of the bounds:

    function _validatePriceFeedResult(
..SNIP..
+   if (roundData.priceInt >= maxPrice || roundData.priceInt <= minPrice) revert();

Duplicate of #42