The liquidation function could leave a borrower with a worse health factor (collateral value divided by debt) because the liquidation incentive and fee reduce collateral faster than debt. An attacker could repeatedly liquidate or force replenishment to make the debt unhealthier and potentially extract DOLA from the market.
For a lending pool, borrower’s 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 borrower’s 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, borrower’s 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 borrower’s 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 borrower’s 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.
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.
I think this comes down to design tradeoffs and is not unique to this specific lending protocol. It certainly shouldn’t be consider High risk, but could see it being considered Medium as users should be aware that in market sell offs, cascading liquidations are a potential reality either due to liquidation rewards OR simply declining prices and the feedback loop at liquidations occur.
That being said, these items are not unique to this protocol, so perhaps QA is a better grade for this issue.
@08xmt - care to weigh in on this one? I am unable to see your fix, but may help in how I judge it. The warden asked me to re-review and is suggesting a Medium severity.
@0xean - I think a Medium rating is fair. Our fix has been to revert when the combination of Collateral Factor, Liquidation Incentive and Liquidation Fee would result in profitable self liquidations or unhealthier debt after liquidations.
The original report as published on Code4rena, by hansfriese. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the liquidation logic does not check that the health factor improves after liquidation, and the forceReplenish limit only ensures debt is below collateral value without accounting for the liquidation incentive and fee.
Impact
Repeated liquidations could make a borrower's debt unhealthier and potentially allow an attacker to take DOLA out of the market; the judge noted cascading liquidations are a general market risk and rated it Medium.
What the attacker needed
Borrower's debt above a threshold; attacker can call liquidate or forceReplenish
The fix
The protocol was fixed by reverting when the combination of collateral factor, liquidation incentive and liquidation fee would allow profitable self-liquidations or unhealthier debt after liquidation.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
In a lending pool, your health factor is the value of your collateral divided by your debt. A liquidation is supposed to improve that ratio by repaying some debt and taking some collateral, but here the extra rewards and fees taken from the collateral could make the ratio worse. That means repeated liquidations might keep making the borrower riskier instead of safer.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.