Reproduced Exploit

Roots — [H-01] Overwriting collateral breaks collateral gains logic

1. Alice accrues coll-A gains on stability-pool index 0 and leaves them unclaimed. 2. Coll A is sunset; coll C is enabled and reuses index 0. 3. Product sums for index 0 are zeroed; Alice's pending gain mapping is not. 4. Alice claims index 0 and is paid in coll-C tokens for her coll-A leftover, dr…

Feb 2025Otheruntagged3 min read

Chain

Other

Category

untagged

Date

Feb 2025

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. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 55111-h-01-overwriting-collateral-breaks-collateral-gains-logic-pa. Standalone Foundry PoC and full write-up: 55111-h-01-overwriting-collateral-breaks-collateral-gains-logic-pa_exp in the evm-hack-registry mirror.


Vulnerability classes: integer-bounds · underflow · fix-arithmetic · known-pattern

Reproduction: self-contained Foundry PoC with only forge-std — no fork. output.txt · test/55111-…_exp.sol.

AuditVault taxonomy: lang/solidity · sector/cdp · severity/high · genome: integer-bounds · underflow · fix-arithmetic


Key info#

ImpactHIGH — reusing a sunset collateral index pays old gains in the new token; other depositors cannot claim
ProtocolRoots — StabilityPool collateral enable / gains
Vulnerable codeOverwrite clears epochToScaleToSums but not collateralGainsByDepositor / depositSums
Bug classIncomplete state wipe on index reuse
FindingPashov Audit Group — Roots security review 2025-02-09 · #55111
ReportRoots-security-review_2025-02-09.md
SourceAuditVault
FixDo not overwrite sunset collaterals; add disable-after-expiry without reusing dirty indices
Compiler^0.8.24 (PoC)

TL;DR#

  1. Alice accrues coll-A gains on stability-pool index 0 and leaves them unclaimed.
  2. Coll A is sunset; coll C is enabled and reuses index 0.
  3. Product sums for index 0 are zeroed; Alice's pending gain mapping is not.
  4. Alice claims index 0 and is paid in coll-C tokens for her coll-A leftover, draining the pool.
  5. Bob's coll-C claim reverts (transfer amount exceeds balance).

Vulnerable code#

SOLIDITY
function _overwriteCollateral(uint256 index, MockCollateral coll) internal {
    collateralTokens[index] = coll;
    sunsetExpiry[index] = 0;
    epochToScaleToSums[index][0][0] = 0; // @> VULN: only product sums cleared
    // depositSums[*][index] and collateralGainsByDepositor[*][index] left dirty
}

Fix: never reuse sunset indices, or wipe all per-depositor gain state for the index before reuse.

Diagrams#

sequenceDiagram participant Alice participant Bob participant SP as StabilityPool participant CA as CollA participant CC as CollC Alice->>SP: provide + accrue collA gains 50 Note over SP: index0 gains Alice=50 SP->>SP: sunset collA then enable collC at index0 SP->>SP: clear product sums only SP->>CC: mint 50 into pool Alice->>SP: claimCollateralGains index0 SP->>Alice: transfer 50 collC via leftover collA gain Bob->>SP: claim collC SP-->>Bob: revert empty pool

Impact#

Depositors of a new collateral can have their gains drained by leftover accounting from a previous collateral on the same index; claims may also DoS via underflow on sums - depSums.

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.