Reproduced Exploit

Vaultcraft: addVault prices a non-empty vault at 1 and a depositor takes 50 assets

addVault sets the oracle price to 1e18 so the first update does not pause the vault. It does not require the vault to be empty. A vault with 200 assets and 100 shares is priced at 1. A deposit of 100 assets mints 100 shares instead of 50 and redeems 150. The new depositor gains 50 assets.

Dec 2024•Ethereum•oracle•3 min read

Loss

50 assets taken from the depositor who funded the vault before it was registered

Chain

Ethereum

Category

oracle

Date

Dec 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: 45890-a-vault-can-be-added-to-oraclevaultcontroller-after-receivin. Standalone Foundry PoC and full write-up: 45890-a-vault-can-be-added-to-oraclevaultcontroller-after-receivin_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/oracle/price-manipulation

Key info#

FieldValue
Loss50 assets taken from the depositor who funded the vault before it was registered
Vulnerable contractOracleVaultController.addVault
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-12
Compilersolc 0.8.27, cancun, via IR
Bug classShare price forced to 1 after deposits

TL;DR#

addVault sets the oracle price to 1e18 so the first update does not pause the vault. It does not require the vault to be empty. A vault with 200 assets and 100 shares is priced at 1. A deposit of 100 assets mints 100 shares instead of 50 and redeems 150. The new depositor gains 50 assets.

The vulnerable code#

SOLIDITY
function addVault(address vault) external {
    highWaterMarks[vault] = 1e18;
    oracle.setPrice(vault, address(ERC4626(vault).asset()), 1e18, 1e18); // @> VULN: price is forced to 1e18 even when the vault already holds assets
}

The review says to revert when the vault already holds assets.

Root cause#

The price write is a constant. It is not totalAssets * 1e18 / totalShares, and it is not guarded by totalAssets == 0.

Preconditions#

  • The vault already holds 200 assets against 100 shares.
  • The owner calls addVault after that seed.
  • A later depositor mints against the oracle price and redeems against the real asset ratio.

Attack walkthrough#

  1. The vault is seeded at 2 assets per share.
  2. addVault writes 1e18.
  3. 100 assets mint 100 shares.
  4. Redeeming those shares returns 150 assets.

Diagrams#

flowchart TD A["Vault holds 200 assets and 100 shares"] --> B["VULN addVault writes price 1e18"] B --> C["100 assets mint 100 shares"] C --> D["100 shares redeem 150 assets"] D --> E["Depositor gains 50 assets"]

Impact#

The depositor who funded the vault before registration loses 50 assets to the next depositor. Any vault added after it has a non-1 exchange rate is mispriced the same way.

Remediation#

Revert in addVault when totalAssets is not zero, or set the price from the current exchange rate instead of the constant 1e18.

How to reproduce#

BASH
cd 45890-a-vault-can-be-added-to-oraclevaultcontroller-after-receivin_exp
forge test -vv

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.