Open hats-bug-reporter[bot] opened 8 months ago
We already have price range checks in place for the only place where we consume the latestRoundData(): https://github.com/TempleDAO/origami-public/blob/185a93e25071b6a110ca190e94a6a826e982b2d6/apps/protocol/contracts/common/oracle/OrigamiStableChainlinkOracle.sol#L114-L115
Github username: @0xRizwan Twitter username: 0xRizwann Submission hash (on-chain): 0x27095c8f3023725b44de9df598d7603ab0c7ff9d0da5d3dd8cc767f458f40979 Severity: medium
Description: 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 theactual price
of the asset. This would allow user to continue using the given price with the asset but at the wrong price.This is exactly what happened to Venus on BSC when LUNA imploded.
Vulnerability Details:
The
price()
function from chainlink library is extensively used in contracts.price()
makes use of Chainlink'slatestRoundData()
to get the latest price. The self.oracle.latestRoundData() pulls the associated aggregator and requests round data from it. Chainlink aggregators haveminPrice
andmaxPrice
circuit breakers built into them. This means that if the price of the asset drops below the minimum price, the protocol will continue to value the token at the minimum price instead of it's actual value. This will allow users to take out huge amounts of bad debt and bankrupt the protocol.Impact:
If an asset collapses, like the recent USDC depeg, the protocol can be manipulated where the price feeds used due to inflated prices.
Recommendations
Consider using the following
minPrice
andmaxPrice
check checks.For example: