Batched liquidations doesn’t distribute bad debt on next batches in the list
When a batch liquidation creates bad debt, the redistribution index is not updated after each liquidation, so subsequent liquidations in the same batch use an incorrect debt value. This means less debt is liquidated and more collateral goes to the CDP owner, while other users must cover the skipped bad debt.
Now, let’s check how liquidations occur by _getTotalsFromBatchLiquidate_NormalMode function. This function loops through all cpds one by one. It fetches ICR for them using getSyncedICR function. This function will calculate ICR not on stored debt and coll of cdp, but it will update this values, according to new fee rate(which means that coll will be reduced) and redistribute rate(which means that debt will increase, if rate is bigger than stored for cdp).
So finally, I can explain the problem. In case if in batch there is cdp, that will create bad debt after liquidation, then this debt will not be redistributed to all next liquidations, as redistribution index is not updated after each liquidation. And as result, next liquidations will have incorrect debt value, which means that smaller amount of debt will be liquidated and bigger amount of coll will be received by cdp owner. And also all else users in the system will have to cover that delta debt that was not redistributed to next liquidations.
Impact
Bad debt is distributed incorrectly.
Tools Used
VsCode
Recommended Mitigation Steps
You need to redistribute bad debt after each liquidation in the batch (in case if bad debt occured).
This is a known finding from Cantina that unfortunately was not added to the report.
The finding specifically means that 3% of bad debt generated in a batch liquidation will be skipped, effectively making liquidations more favourable.
That said, it’s worth noting that since partial liquidations don’t cause a redistribution, the 3% bad debt could have been skipped under other circumstances.
I didn’t find a public record about the issue. So I’ll mark it as Medium severity.
The original report as published on Code4rena, by rvierdiiev. 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 redistribution index is not updated after each liquidation within a batch, so subsequent liquidations use a stale debt value.
Impact
Bad debt is distributed incorrectly, causing some users to cover debt that should have been redistributed to later liquidations in the batch.
What the attacker needed
Batch liquidation with bad debt
The fix
Redistribute bad debt after each liquidation in the batch when bad debt occurs.
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 this lending system, when a borrower's collateral is worth less than their debt, the shortfall (bad debt) is shared among all depositors. The bug is that during a batch of liquidations, the sharing calculation is not updated after each liquidation, so later liquidations in the batch use stale numbers. As a result, some bad debt is not shared correctly and the liquidator gets a better deal at the expense of other users.
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.