Reproduced Exploit

NUTS Finance: Because rebase()'s oldD>newD branch never syncs balances/totalSupply

Jan 1970Otheruntagged3 min read

Chain

Other

Category

untagged

Date

Jan 1970

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: 62662-buffer-drainage-through-repeated-rebase-calls-due-to-stale-s. The historical source/toolchain is unavailable; this entry is documentation only and claims no executable Forge PoC.


Vulnerability classes: vuln/theft · vuln/locked-funds · vuln/access-control

Reproduction: a faithful minimal reproduction of the vulnerable finding — the vulnerable function is reproduced verbatim (marked @>) with faithful minimal doubles; local deploy, no fork.

Root cause#

Because rebase()'s oldD>newD branch never syncs balances/totalSupply, 3 permissionless calls each recompute the same 100-unit gap and drain the poolToken buffer 3x (300 destroyed) vs 100 for one legitimate call — a value-destruction DoS of LP-holder-owned buffer value.

SOLIDITY

        if (oldD == newD) {
            return 0;
        } else if (oldD > newD) {
            poolToken.removeTotalSupply(oldD - newD, true, true); // @> drains buffer but never updates `balances`/`totalSupply`, so the SAME gap re-triggers every call
            return 0;

Why it's exploitable here#

Because rebase()'s oldD>newD branch never syncs balances/totalSupply, 3 permissionless calls each recompute the same 100-unit gap and drain the poolToken buffer 3x (300 destroyed) vs 100 for one legitimate call — a value-destruction DoS of LP-holder-owned buffer value.

Attack path#

flowchart TD S0["Scale balance by feed decimals"] S1["Normalize balance by precision"] S2["oldD>newD branch never syncs state"] S3["Mark reserves non-empty"] S4["Newton loop for invariant D"] H["Because rebase()'s oldD>newD branch never syncs balances/totalSupply, "] S0 --> S1 S1 --> S2 S2 --> S3 S3 --> S4 S4 --> H

Marked-line walkthrough (Playground)#

The EVM Playground pins each step to the exact executed source line in 0xbd4fd5a3ce…:

  1. L187 — Scale balance by feed decimals: Divides each token's balance by its exchange-rate provider's decimals to bring it to a common scale.
  2. L188 — Normalize balance by precision: _balances[i] is rescaled by precisions[i] so all tokens share one fixed-point basis before computing the invariant D.
  3. L194 — oldD>newD branch never syncs state: Root-cause bug: this drain branch burns the D gap from the buffer but never writes back balances/totalSupply, so each repeat rebase() redrains the same gap.
  4. L219 — Mark reserves non-empty: Sets allZero=false once a non-zero reserve is seen while computing D.
  5. L230 — Newton loop for invariant D: Iterates up to 255 times to converge the StableSwap invariant D from the current balances.
  6. L273 — Wire pool token list: Setup: constructor stores the pool's tokens array.
  7. L274 — Wire per-token precisions: Setup: constructor stores each token's precisions scaling factor.

PoC#

Registry (Foundry, local deploy — verbatim vulnerable source + harm-asserting test + negative control):

BASH
cd 62662-buffer-drainage-through-repeated-rebase-calls-due-to-stale-s_exp
forge test -vvv

The browser Playground replays the same synthetic opcode-for-opcode and measures the harm: **Because rebase()'s oldD>newD branch never syncs balances/totalSupply, 3 permissionless calls each recompute the same 100-unit gap and drain **. Both gates are green (registry forge test PASS + Playground _verify-poc VERDICT: PASS).


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

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.