Skip to content
Business logic Audit finding Advanced

Cds amounts to reduce from each chain are incorrect and will lead to the inability to withdraw cds in one of the chains

The liquidation logic reduces each chain's total CDS deposit using a share based on CDS deposit amounts, while the per-depositor liquidation amount is computed pro-rata to available liquidation amounts, so the two calculations disagree. This overcharges the chain with the most CDS and can make its total CDS deposited amount underflow, preventing withdrawals.

0x73696d616f Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/762

Found by

0x73696d616f

Summary

The cds amount to reduce on liquidations from each chain is given by the share of cds deposit, but then the liquidation amount by each cds depositor is given by the available liquidation amount pro-rata to the depositor's liquidation amount, which renders the first share calculation incorrect.

Root Cause

In CDSLib.sol:728, totalCdsDepositedAmount is reduced by params.cdsDepositDetails.depositedAmount - params.cdsDepositDetails.liquidationAmount, but in BorrowLib:390, the share is given by the cds amounts of each chain, not the available liquidation amounts.

Internal pre-conditions

None.

External pre-conditions

None.

Attack Path

  1. Consider 2 chains, A has 1000 cds deposited with 1000 available liquidation amount; chain B has 19000 cds deposited, also 1000 available liquidation amount. 1 borrower is liquidated with 1 ETH deposited at a price of 1000 USD / ETH and 800 USDa borrowed.
  2. The calculations in BorrowLib::getLiquidationAmountProportions() yield, for chain A, B, respectively:
  • shares 0.05;0.95.
  • _liqAmount is 820 (1000 - 800 - 20, where 800 is the debt and 20 is the amount to return to abond, given by (1000 - 800) * 10 / 100)
  • liqAmountToGet is 41;779 (820 multiplied by the shares of each chain)
  • cdsProfits are 9;171 (total is 180, 1000 - 820, these 2 are multiplied by shares)
  • cdsAmounts 32;608 (chainA cds amount to get is 41 - 9 = 32 and chainB is 779 - 171 = 608).

Chain B will have 18000 cds withdrawn (consider that the price goes back up in the meantime and they don't take losses), and only the cds depositor that provided liquidation amount is left. As it will fetch 608 cds amount from the cds, it becomes 19000 - 18000 - 608 = 392. Then, when it loops through the liquidations that happened, share is 50% (availableLiquidationAmount / totalAvailableLiquidationAmount), so params.cdsDepositDetails.liquidationAmount becomes 1000 - 0.5 * 820 = 590. Then, totalCdsDepositedAmount -= (params.cdsDepositDetails.depositedAmount - params.cdsDepositDetails.liquidationAmount); = 392 - (1000 - 590) = -18, which underflows. This proves that Chain B is overcharged.

Impact

The chain with the most cds will be charged to much cds as the liquidation amount to subtract for each depositor is given by the available liquidation amount, but the cds was removed based on the cds amount.

PoC

See above.

Mitigation

Consider using share calculation in borrowingLiquidation.sol based on the available liquidation amounts themselves.

The original report as published on Sherlock, by 0x73696d616f. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 share of CDS to reduce per chain is computed from CDS deposit amounts rather than from the available liquidation amounts used for the per-depositor split.

Impact

The chain with the most CDS is overcharged, and its total CDS deposited amount can underflow, which would prevent CDS withdrawals on that chain.

What the attacker needed

Two chains with CDS deposits; a liquidatable borrower

The fix

The share calculation in the borrowing liquidation logic should be based on the available liquidation amounts themselves.

How it was found

  1. Set up two chains with different CDS deposits but equal available liquidation amounts.
  2. Liquidate a borrower whose collateral and debt produce a liquidation amount.
  3. Observe the per-chain shares and CDS amounts computed from deposit shares.
  4. Withdraw most CDS from the larger chain, leaving only the depositor that provided liquidation amount.
  5. Observe the per-depositor liquidation amount uses available liquidation shares, causing the total CDS deposited amount to underflow.

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.

CDS is a pool of deposited funds that backs loans. When a borrower is liquidated, the code works out how much each chain's pool should lose, but it uses two different ways of splitting the loss, so one chain is charged too much. That chain's recorded balance can then go below zero, which breaks withdrawals.

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.

More by 0x73696d616f

View all

172 more disclosed reports, best first.

More from Autonomint Colored Dollar V1

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.