Reproduced Exploit

Autonomint: anyone can set downsideProtected and freeze a 100 token CDS deposit

updateDownsideProtected has no access control. It adds the caller's uint128 to downsideProtected. deposit and withdraw subtract that value from totalCdsDepositedAmount. A depositor puts in 100 tokens. An attacker adds 101. The next withdraw underflows and reverts. The 100 tokens stay in CDS and the…

Nov 2024•Ethereum•access-control•3 min read

Loss

Depositor cannot withdraw 100 tokens after downsideProtected is set to 101

Chain

Ethereum

Category

access-control

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: 45461-h-8-malicious-users-can-dos-the-protocol-by-setting-downside. Standalone Foundry PoC and full write-up: 45461-h-8-malicious-users-can-dos-the-protocol-by-setting-downside_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/access-control/missing-auth · vuln/arithmetic/underflow

Key info#

FieldValue
LossDepositor cannot withdraw 100 tokens after downsideProtected is set to 101
Vulnerable contractCDS.updateDownsideProtected
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-11
Compilersolc 0.8.27, cancun, via IR
Bug classPermissionless addition to downsideProtected underflows the deposit total

TL;DR#

updateDownsideProtected has no access control. It adds the caller's uint128 to downsideProtected. deposit and withdraw subtract that value from totalCdsDepositedAmount. A depositor puts in 100 tokens. An attacker adds 101. The next withdraw underflows and reverts. The 100 tokens stay in CDS and the depositor's balance stays 0. With downsideProtected left at 0, the same withdraw returns the 100.

Background#

Sherlock, November 2024 Autonomint Colored Dollar V1, issue 624 (H-8). CDS.updateDownsideProtected is external. _updateCurrentTotalCdsDepositedAmount subtracts downsideProtected from both deposit totals and then zeroes it. That helper runs on deposit and withdraw. A value above the live total reverts both, so deposited assets cannot move.

The vulnerable code#

SOLIDITY
function updateDownsideProtected(uint128 downsideProtectedAmount) external {
    downsideProtected += downsideProtectedAmount; // @> VULN: no access control
}

function _updateCurrentTotalCdsDepositedAmount() private {
    if (downsideProtected > 0) {
        totalCdsDepositedAmount -= downsideProtected; // underflows when downside exceeds deposits
        totalCdsDepositedAmountWithOptionFees -= downsideProtected;
        downsideProtected = 0;
    }
}
DIFF
 function updateDownsideProtected(uint128 downsideProtectedAmount) external {
+    require(msg.sender == admin, "admin");
     downsideProtected += downsideProtectedAmount;
 }

Root cause#

The setter is permissionless, and the value it writes is later subtracted from a total that users can only increase by depositing. Nothing caps downsideProtected at totalCdsDepositedAmount. Once it is larger, every core call that runs the subtraction reverts, which is a permanent denial of service until the value is repaired by an upgrade.

Preconditions#

  • totalCdsDepositedAmount is 100 tokens. That is one depositor's balance in this run.
  • Anyone can call updateDownsideProtected. No role is checked.
  • The attacker passes 101 ether, which fits in uint128 and is greater than the deposit total.

Attack walkthrough#

  1. The depositor supplies 100 tokens. The deposit succeeds because downsideProtected is still 0.
  2. The attacker calls updateDownsideProtected(101 ether).
  3. The depositor calls withdraw.
  4. _updateCurrentTotalCdsDepositedAmount computes 100 - 101 and reverts.
  5. The low-level call reports failure.
  6. CDS still holds 100 tokens. The depositor holds 0.

Diagrams#

flowchart TD A["Depositor supplies 100 tokens"] --> B["totalCdsDepositedAmount is 100"] B --> C["VULN anyone adds 101 to downsideProtected"] C --> D["Withdraw subtracts 101 from 100"] D --> E["Underflow revert"] E --> F["100 tokens stay in CDS"] B --> G["Control with downside left at 0 returns the 100"]

Impact#

The depositor cannot withdraw. The 100 tokens are frozen in CDS for as long as downsideProtected stays above the deposit total. The same revert hits deposit, so new users cannot enter either. The control, which never calls the setter, returns the 100 tokens to the depositor and leaves CDS empty.

Remediation#

Restrict updateDownsideProtected to the admin, and reject an amount that would make downsideProtected larger than totalCdsDepositedAmount.

How to reproduce#

BASH
cd 45461-h-8-malicious-users-can-dos-the-protocol-by-setting-downside_exp
forge test -vv

test_exploit_downside_underflow_locks_100 asserts downsideProtected of 101, a 100 token CDS balance, and a 0 depositor balance. test_control_withdraw_succeeds_when_downside_is_unset asserts a full withdrawal. Captured output is output.txt.

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.