Reproduced Exploit

Autonomint: withdrawUser pays 900 CDS when 700 of the deposit is left

liquidationAmount on an opted-in CDS position is the liquidation capacity still left, not the amount already consumed. The position deposited 1000, opted in 400, and has 100 of that capacity left, so 300 was used and 700 remains. withdrawUser deducts 1000 - 100 = 900 from totalCdsDepositedAmount an…

Nov 2024•Ethereum•logic•3 min read

Loss

The withdrawing CDS owner receives 900. Only 700 of that deposit is left. The other depositor is short 200

Chain

Ethereum

Category

logic

Date

Nov 2024

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 45460-h-7-incorrect-deducted-cds-deposit-amount-in-withdrawuser-sh. Standalone Foundry PoC and full write-up: 45460-h-7-incorrect-deducted-cds-deposit-amount-in-withdrawuser-sh_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/liquidation-logic · vuln/logic/state-update

Key info#

FieldValue
LossThe withdrawing CDS owner receives 900. Only 700 of that deposit is left. The other depositor is short 200
Vulnerable contractCdsPool.withdrawUser
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-11
Compilersolc 0.8.27, cancun, via IR
Bug classLeftover liquidation capacity is treated as the amount already used

TL;DR#

liquidationAmount on an opted-in CDS position is the liquidation capacity still left, not the amount already consumed. The position deposited 1000, opted in 400, and has 100 of that capacity left, so 300 was used and 700 remains. withdrawUser deducts 1000 - 100 = 900 from totalCdsDepositedAmount and pays 900. The pool started with 1700 of cash (700 left plus another depositor's 1000) and finishes with 800. The other depositor's record is still 1000.

The vulnerable code#

SOLIDITY
uint256 deposit = depositedAmount[user];
uint256 leftLiquidation = liquidationAmount[user];
// @> VULN: liquidationAmount is the remainder, so this deducts more than the deposit left
totalCdsDepositedAmount -= (deposit - leftLiquidation);
require(asset.transfer(user, deposit - leftLiquidation), "pay");

The finding's expression is depositedAmount - liquidationAmount. The amount that should be deducted is depositedAmount - (initialLiquidationAmount - liquidationAmount).

Root cause#

The same field is read as if it were the consumed liquidation. It is the unused remainder, so the subtraction removes too much from the global total and the payout matches that wrong figure.

Preconditions#

  • Deposited 1000, initial liquidation opt-in 400, leftover liquidation 100.
  • Another depositor has 1000 with no liquidation.
  • The pool holds 1700, the cash still backing both remaining deposits.

Attack walkthrough#

  1. Read the global total. It is 1700.
  2. Withdraw. The deduction and the transfer are both 900.
  3. The owner holds 900. The global total is 800. Pool cash is 800.
  4. The other 1000 deposit is short 200.

Diagrams#

flowchart TD A["Deposit 1000 with 400 opted in and 100 still unused"] --> B["300 was already used so 700 remains"] B --> C["VULN deducts 1000 minus the leftover 100"] C --> D["Owner is paid 900"] D --> E["Pool cash is 800 and the other 1000 deposit is short 200"]

Impact#

The withdrawing owner takes 200 CDS that belongs to the other depositor. totalCdsDepositedAmount is 200 below the deposit that is still recorded for that other user. Deducting the true remainder pays 700 and leaves 1000 of cash.

Remediation#

Deduct depositedAmount - (initialLiquidationAmount - liquidationAmount) from the global total, and pay that same left deposit.

How to reproduce#

BASH
cd 45460-h-7-incorrect-deducted-cds-deposit-amount-in-withdrawuser-sh_exp
forge test -vv

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.