The MarketShutdownFacet::shutdownMarket()
is a critical function allowing anyone to freeze the market permanently. The function determines whether or not the market will be frozen based on the asset collateral ratio calculated from a cached price, which can be outdated (too risky for this critical function).
Once the market is frozen, no one can unfreeze it.
The shutdownMarket()
allows anyone to call to freeze the market permanently when the asset collateral ratio threshold (default of 1.1 ether) has been reached. Once the market is frozen, all shorters will lose access to their positions. Even the protocol's DAO or admin cannot unfreeze the market. Therefore, the shutdownMarket()
becomes one of the most critical functions.
To calculate the asset collateral ratio (cRatio
), the shutdownMarket()
executes the _getAssetCollateralRatio()
. However, the _getAssetCollateralRatio()
calculates the cRatio
using the cached price loaded from the LibOracle::getPrice()
.
Using the cached price in a critical function like shutdownMarket()
is too risky, as the cached price can be outdated. The function should consider only a fresh price queried from Chainlink.
https://github.com/Cyfrin/2023-09-ditto/blob/a93b4276420a092913f43169a353a6198d3c21b9/contracts/facets/MarketShutdownFacet.sol#L36
https://github.com/Cyfrin/2023-09-ditto/blob/a93b4276420a092913f43169a353a6198d3c21b9/contracts/facets/MarketShutdownFacet.sol#L37
https://github.com/Cyfrin/2023-09-ditto/blob/a93b4276420a092913f43169a353a6198d3c21b9/contracts/facets/MarketShutdownFacet.sol#L44
https://github.com/Cyfrin/2023-09-ditto/blob/a93b4276420a092913f43169a353a6198d3c21b9/contracts/facets/MarketShutdownFacet.sol#L99
Using the cached price in a critical function like shutdownMarket()
is too risky, as the cached price can be outdated.
Once the market is frozen, all shorters will lose access to their positions. Even the protocol's DAO or admin cannot unfreeze the market.
Manual Review
The shutdownMarket()
requires the most accurate price, not just a cached price. Execute the LibOracle::getOraclePrice()
to get the accurate price from Chainlink.
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.