Some liquidated collateral will be locked
When a borrow position is liquidated, the contract records the full liquidation amount needed but only deducts the amount minus CDS profits from the total available liquidation amount. This mismatch means CDS owners withdrawing their positions receive less than they should, leaving some liquidated collateral permanently locked.
0x37 Follow with 0x73696d616f
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/759
Found by
0x37, 0x73696d616f
Summary
After we liquidate via liquidation type1 method, all cds owner's liquidation share will change. This will cause some liquidated collateral will be locked.
Root Cause
When one borrow position is unhealthy, the admin will liquidate this position. We will record each liquidated position's needed liquidation amount. When cds owners withdraw their positions, we will loop all liquidated positions to check this position's used liquidated amount.
When we record this liquidated position's needed liquidation amount, we use liquidationAmountNeeded. But we update omniChainData.totalAvailableLiquidationAmount via deducting liquidationAmountNeeded - cdsProfits.
When cds owners withdraw their positions, liquidationAmountNeeded amount will be deducted from their liquidation amount, but we only deduct liquidationAmountNeeded - cdsProfits from the totalAvailableLiquidationAmount. This will cause the left liquidation amount from all cds owners will be less than totalAvailableLiquidationAmount.
For example:
- Alice deposits 2000 USDT/USDA and opt in the liquidation. The liquidation amount is 2000 USDA.
totalAvailableLiquidationAmount= 2000 USDA. - Bob borrows some UDSA and is liquidated because the ether price drops. Assume
liquidationAmountNeeded= 1000 USDA,cdsProfits= 150 USDA. ThentotalAvailableLiquidationAmountafter the first liquidation will be 1150 USDA. - Cathy borrows some USDA and is liquidated because the ether price drops.
- Alice withdraw her position and we will calculate the deducted liquidation amount.
4.1. In the first loop round, share is 100%, we will deduct 1000 from Alice's liquidation amount. params.cdsDepositDetails.liquidationAmount = 1000.
4.2 In the second loop round, liquidationData.availableLiquidationAmount is 1150 USDA. Alice's share will be less than 100%. But Alice is the only cds owners. Alice cannot get all liquidated collateral. This will cause some liquidated collateral will be locked.
liquidationInfo = CDSInterface.LiquidationInfo(
liquidationAmountNeeded,
cdsProfits,
depositDetail.depositedAmount,
omniChainData.totalAvailableLiquidationAmount,
depositDetail.assetName,
((depositDetail.depositedAmount * exchangeRate) / 1 ether)
);
...
omniChainData.totalAvailableLiquidationAmount -= liquidationAmountNeeded - cdsProfits;
for (uint128 i = (liquidationIndexAtDeposit + 1); i <= params.omniChainData.noOfLiquidations; i++) {
uint128 liquidationAmount = params.cdsDepositDetails.liquidationAmount;
if (liquidationAmount > 0) {
CDSInterface.LiquidationInfo memory liquidationData = omniChainCDSLiqIndexToInfo[i];
uint128 share = (liquidationAmount * 1e10) / uint128(liquidationData.availableLiquidationAmount);
params.cdsDepositDetails.liquidationAmount -= getUserShare(liquidationData.liquidationAmount, share);
...
}
Internal pre-conditions
N/A
External pre-conditions
N/A
Attack Path
- Alice deposits 2000 USDT/USDA and opt in the liquidation. The liquidation amount is 2000 USDA.
totalAvailableLiquidationAmount= 2000 USDA. - Bob borrows some UDSA and is liquidated because the ether price drops. Assume
liquidationAmountNeeded= 1000 USDA,cdsProfits= 150 USDA. ThentotalAvailableLiquidationAmountafter the first liquidation will be 1150 USDA. - Cathy borrows some USDA and is liquidated because the ether price drops.
- Alice withdraw her position and we will calculate the deducted liquidation amount.
4.1. In the first loop round, share is 100%, we will deduct 1000 from Alice's liquidation amount. params.cdsDepositDetails.liquidationAmount = 1000.
4.2 In the second loop round, liquidationData.availableLiquidationAmount is 1150 USDA. Alice's share will be less than 100%. But Alice is the only cds owners. Alice cannot get all liquidated collateral. This will cause some liquidated collateral will be locked.
Impact
Some liquidated collateral will be locked.
PoC
N/A
Mitigation
No response
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The contract records `liquidationAmountNeeded` in the liquidation info but only deducts `liquidationAmountNeeded - cdsProfits` from `totalAvailableLiquidationAmount`, so the per-position recorded amount and the global total diverge.
What the attacker needed
CDS owner opts in to liquidation sharing; at least two liquidations occur; CDS owner later withdraws
How it was found
- Alice deposits 2000 USDA and opts in to liquidation sharing, setting totalAvailableLiquidationAmount to 2000.
- Bob is liquidated with liquidationAmountNeeded of 1000 and cdsProfits of 150, leaving totalAvailableLiquidationAmount at 1150.
- Cathy is also liquidated, adding another liquidation entry.
- Alice withdraws; in the first loop round her share is 100% and 1000 is deducted from her liquidation amount.
- In the second loop round her share is below 100% because availableLiquidationAmount is 1150, so she cannot recover all liquidated collateral.
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.
In this lending protocol, people who deposit funds can opt in to share in the collateral seized when a borrower is liquidated. The code tracks how much collateral is available to share, but it subtracts a smaller number than it records, so the accounting drifts. When depositors later withdraw, the maths no longer adds up and some of the seized collateral can never be claimed by anyone.
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.