Unbounded Liquidation Iterations Can Lead to Withdrawal DoS
The withdrawal function forces users who opted into liquidation to loop over every liquidation event since their deposit, so gas costs grow without bound. Early depositors could eventually be unable to withdraw because the transaction exceeds the block gas limit.
Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/740
Found by
0xNirix, 0xTamayo, 0xe4669da, Audinarey, santiellena, valuevalk, yoooo
Summary
The protocol's requiring users to iterate through all liquidation events since their deposit during withdrawal will cause eventual transaction failure for early depositors as the number of liquidations grows over time, preventing them from withdrawing their funds.
Root Cause
In CDSLib.withdrawUser() at https://github.com/sherlock-audit/2024-11-autonomint/blob/main/Blockchain/Blockchian/contracts/lib/CDSLib.sol#L640 the forced iteration through all historical liquidations between deposit and withdrawal time creates potential for unbounded gas costs:
// In CDSLib.withdrawUser:
if (params.cdsDepositDetails.optedLiquidation) {
for (uint128 i = (liquidationIndexAtDeposit + 1); i <= params.omniChainData.noOfLiquidations; i++) {
uint128 liquidationAmount = params.cdsDepositDetails.liquidationAmount;
if (liquidationAmount > 0) {
CDSInterface.LiquidationInfo memory liquidationData = omniChainCDSLiqIndexToInfo[i];
// Calculate share for each liquidation
uint128 share = (liquidationAmount * 1e10) / uint128(liquidationData.availableLiquidationAmount);
// Process liquidation share...
}
}
}
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
- Early user deposits with liquidation enabled (
liquidationIndexAtDeposit = currentLiquidations) - Protocol operates normally over months/years
- Many liquidations occur, incrementing
noOfLiquidations - When early user attempts to withdraw:
- Must process EVERY liquidation since their deposit
- Gas costs grow linearly with number of liquidations
- Eventually exceeds block gas limit
Impact
Early CDS depositors who opted for liquidation will be unable to withdraw their funds once the number of liquidations grows too large, as their withdrawal transactions will exceed block gas limits
PoC
No response
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
Likely the withdrawal logic loops over all liquidation records between deposit and withdrawal without any bound, so the gas cost grows with the number of liquidations.
Impact
Early depositors who opted into liquidation could be unable to withdraw their funds once the number of liquidations is large enough that the withdrawal exceeds the block gas limit.
What the attacker needed
User deposits with liquidation enabled; many liquidations occur over time
How it was found
- An early user deposits with liquidation enabled, recording the current liquidation index.
- The protocol operates normally and many liquidations occur, increasing the total liquidation count.
- When the early user tries to withdraw, the contract processes every liquidation since their deposit.
- The gas cost grows with the number of liquidations and eventually exceeds the block gas limit, so the withdrawal fails.
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.
A smart contract is a program on a blockchain. Every operation costs a small fee called gas, and each block has a maximum amount of gas. This contract makes a user's withdrawal go through every liquidation that happened since they deposited, so the more time passes, the more work the withdrawal does and the more gas it needs, until it can no longer fit in a block.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.