Submitted by hansfriese
https://github.com/code-423n4/2022-10-inverse/blob/main/src/Market.sol#L559
https://github.com/code-423n4/2022-10-inverse/blob/main/src/Market.sol#L591
For a lending pool, borrowers debt healthness can be decided by the health factor, i.e. the collateral value divided by debt. ($C/D$)
The less the health factor is, the borrowers collateral is more risky of being liquidated.
Liquidation is supposed to make the borrower healthier (by paying debts and claiming some collateral), or else continuous liquidations can follow up and this can lead to a so-called liquidation crisis.
In a normal lending protocol, borrowers debt is limited by collateral factor in any case.
For this protocol, users can force replenishment for the addresses in deficit and the replenishment increases the borrowers debt.
And in the current implementation the replenishment is limited so that the new debt is not over than the collateral value.
As we will see below, this limitation is not enough and if the borrowers debt is over some threshold (still less than collateral value), liquidation makes the borrower debt unhealthier.
And repeating liquidation can lead to various problems and we will even show an example that the attacker can take the DOLA out of the market.
Please see wardens original submission for full proof of concept.
Foundry
Make sure the liquidation does not decrease the health index in the function liquidate.
With this mitigation, we also suggest limiting the debt increase in the function forceReplenish so that the new debt after replenish will not be over the threshold.
08xmt (Inverse) confirmed and commented:
0xean (judge) decreased severity and commented:
0xean (judge) commented:
08xmt (Inverse) commented:
0xean (judge) increased severity to Medium and commented:
