# DOS on liquidation type 1 due to underflow in cds profits computation

Underflow in CDS profits formula reverts liquidation type 1 once accumulated interest pushes borrower debt above deposited value, making loans unliquidatable.

- Payout: Audit contest
- Severity: medium
- Program: Autonomint
- Found by: 0x37
- Disclosed: 2024-11-26
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/840
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AM-27
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos vuln:liquidation

**Target:** borrowLiquidation.sol liquidation type 1 / CDS profits computation
**Root cause:** cdsProfits subtracts returnToTreasury (borrower debt incl. accrued interest) and returnToAbond from depositedAmountInETH*ethPriceAtDeposit/1e12/100; when lastCumulativeRate grows enough (~126%) borrowerDebt exceeds that deposited value, underflowing the uint128 subtraction.
**Steps:**
1. Borrower deposits 50 ETH at 3000 USD/ETH; normalizedAmount set at loan creation.
2. Interest accrues via calculateCumulativeRate/_rpow until lastCumulativeRate ~1.26e27.
3. Liquidation type 1 computes borrowerDebt = normalizedAmount*lastCumulativeRate/1e27 = 151,200 USD.
4. returnToAbond = ((depositedValue - returnToTreasury)*10)/100 underflows first.
5. cdsProfits = depositedValue - returnToTreasury - returnToAbond underflows, reverting liquidation.
**How found:** Code review of the CDS profits formula flagged the subtraction of returnToTreasury from deposited value as potentially underflowing; traced borrowerDebt growth via cumulative rate and modeled a 126% cumulative rate scenario in a spreadsheet.
**Exploitation:** Not an attacker-driven exploit; the flaw triggers naturally when a loan's accrued interest makes debt exceed the deposited collateral value, causing liquidation type 1 to revert and leaving the underwater loan unliquidatable.
**Insight:** In lending/liquidation math, check every subtraction where one operand is a fixed deposit value and the other is interest-inflated debt; cumulative-rate growth over time can flip the inequality and brick liquidation paths.

