Handle
gzeon
Vulnerability details
Impact
There is a price check to avoid flash loan attacks which significantly moved the price. If current price is 5% lower than the stored twap price, the liquidation will fail. This design can be dangerous as it is to openleverage's benefit to close under-collateralized position ASAP when there is a huge market drawdown. When the market keep trading downward, it is possible that the spot price keep trading 5% lower than the twap, which prevent any liquidation from happening and causing the protocol to be under-collateralized.
Proof of Concept
https://github.com/code-423n4/2022-01-openleverage/blob/501e8f5c7ebaf1242572712626a77a3d65bdd3ad/openleverage-contracts/contracts/OpenLevV1Lib.sol#L191
// Avoid flash loan
if (prices.price < prices.cAvgPrice) {
uint differencePriceRatio = prices.cAvgPrice.mul(100).div(prices.price);
require(differencePriceRatio - 100 < maxLiquidationPriceDiffientRatio, 'MPT');
}
Recommended Mitigation Steps
Instead of revert with maxLiquidationPriceDiffientRatio, use the twap price to determine if the position is healthy.
Handle
gzeon
Vulnerability details
Impact
There is a price check to avoid flash loan attacks which significantly moved the price. If current price is 5% lower than the stored twap price, the liquidation will fail. This design can be dangerous as it is to openleverage's benefit to close under-collateralized position ASAP when there is a huge market drawdown. When the market keep trading downward, it is possible that the spot price keep trading 5% lower than the twap, which prevent any liquidation from happening and causing the protocol to be under-collateralized.
Proof of Concept
https://github.com/code-423n4/2022-01-openleverage/blob/501e8f5c7ebaf1242572712626a77a3d65bdd3ad/openleverage-contracts/contracts/OpenLevV1Lib.sol#L191
Recommended Mitigation Steps
Instead of revert with
maxLiquidationPriceDiffientRatio, use the twap price to determine if the position is healthy.