Reproduced Exploit

Notional values an unfinalized withdrawal split at the whole withdrawal

_calculateValueOfWithdrawRequest is supposed to scale a split by vaultShares / totalShares once the split is finalized. The quoted branch returns the full withdrawal value when finalized is still false.

Jun 2024•Ethereum•logic•2 min read

Loss

A 40-share piece of a 100-share withdrawal is valued at 100, which is 60 too high

Chain

Ethereum

Category

logic

Date

Jun 2024

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack replays in your browser. Step through it by Solidity line or by opcode.

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: 35125-h-12-the-withdrawvalue-calculation-in-calculatevalueofwithd. Standalone Foundry PoC and full write-up: 35125-h-12-the-withdrawvalue-calculation-in-calculatevalueofwithd_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/withdraw-valuation · vuln/defi/collateral-overvalue

Key info#

FieldValue
LossA 40-share piece of a 100-share withdrawal is valued at 100, which is 60 too high
Vulnerable contractVault.valueOf
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit at 0x15452ec016c4dc8c549e7fe6ff4b26324ea8b7a4
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-06
Compilersolc 0.8.27, cancun, via IR
Bug classAn unfinalized split falls through to the full withdrawal value
flowchart TD A["A withdrawal of 100 shares is worth 100 and this piece is 40"] --> B["The split exists and finalized is false"] B --> C["VULN valueOf returns the whole 100"] C --> D["The account is marked 60 above the 40 it holds"] B --> E["Control returns full times vaultShares over totalShares"] E --> F["The same piece is valued at 40"]

TL;DR#

_calculateValueOfWithdrawRequest is supposed to scale a split by vaultShares / totalShares once the split is finalized. The quoted branch returns the full withdrawal value when finalized is still false.

The withdrawal is worth 100. This piece is 40 shares of 100. valueOf stores 100. The control returns 100 * 40 / 100, which is 40. The overstatement is 60.

The vulnerable code#

SOLIDITY
if (w.hasSplit) {
    SplitWithdrawRequest memory s = splits[w.requestId];
    if (s.finalized) {
        return fullValue[w.requestId] * w.vaultShares / s.totalShares;
    }
}
borrowTokenValue = _getValueOfWithdrawRequest(w); // @> VULN: the unfinalized 40-share piece is valued as the whole 100

Impact#

Collateral and borrow checks that read this value treat a 40-share piece as the entire 100. The account is overvalued by 60.

How to reproduce#

BASH
cd 35125-h-12-the-withdrawvalue-calculation-in-calculatevalueofwithd_exp
forge test -vv

test_exploit_unfinalized_split_is_valued_at_100 asserts the stored value is 100. test_control_scales_the_piece_to_40 asserts the scaled value is 40.

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.