Reproduced Exploit

Vaultcraft — performance fee prices 1e6 shares instead of one 18-decimal share

The performance fee asks convertToAssets for the assets behind 10 asset.decimals() shares. USDC has 6 decimals, so that is 1e6 shares, not one 18-decimal share. On a vault with 2000 USDC and 1000e18 shares, that unit rounds to 0 and sits under the high-water mark of 1 USDC per share. No fee is take…

Dec 2024•Other•arithmetic•3 min read

Chain

Other

Category

arithmetic

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: 45889-converttoassets-is-receiving-assets-decimals-instead-of-shar. Standalone Foundry PoC and full write-up: 45889-converttoassets-is-receiving-assets-decimals-instead-of-shar_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/arithmetic/decimal-mismatch · vuln/logic/fee-calculation

Key info#

ProtocolVaultcraft
FindingZokyo, AuditVault 45889
Vulnerable code_accruedPerformanceFee calls convertToAssets
HarmFee taken is 0 and the depositor redeems 2000 USDC. The control pays the fee recipient 100 USDC.
Chainlocal synthetic

TL;DR#

The performance fee asks convertToAssets for the assets behind 10 ** asset.decimals() shares. USDC has 6 decimals, so that is 1e6 shares, not one 18-decimal share. On a vault with 2000 USDC and 1000e18 shares, that unit rounds to 0 and sits under the high-water mark of 1 USDC per share. No fee is taken. The depositor redeems all 2000 USDC. Pricing 1e18 shares yields 2 USDC, and 10 percent of the profit is 100 USDC to the fee recipient.

The vulnerable code#

SOLIDITY
uint256 shareValue = convertToAssets(10 ** asset.decimals());

The finding's recommendation is to pass one share, 10 ** 18, not one asset unit.

Root cause#

convertToAssets expects a share amount. The call passes an asset decimal scale. For a 6-decimal asset and 18-decimal shares the two units differ by 1e12, and the fee math compares the result with a high-water mark stored per 1e18 shares.

Preconditions#

totalAssets is 2000e6. totalSupply is 1000e18. highWaterMark is 1e6, meaning 1 USDC per whole share. The performance fee is 10 percent of the per-share profit. One whole share is worth 2 USDC.

Attack walkthrough#

  1. takeFee calls _accruedPerformanceFee.
  2. convertToAssets(1e6) returns 0. convertToAssets(1e18) returns 2e6.
  3. 0 is not above the high-water mark, so the fee is 0 and the fee recipient is not paid.
  4. The depositor redeems and receives 2000e6 USDC.
  5. The control vault prices 1e18 shares, transfers 100e6 USDC to the fee recipient, and leaves 1900e6 for the depositor.

Diagrams#

flowchart TD A["2000 USDC and 1000e18 shares"] --> B["VULN: convertToAssets of 1e6 shares"] B --> C["Share value rounds to 0"] C --> D["Fee is 0 and depositor redeems 2000"] D --> E["One whole share pays a 100 USDC fee"]

Impact#

The fee recipient is paid 0 instead of 100 USDC. The depositor redeems 2000 USDC, which includes that unpaid fee. The control pays the recipient 100 USDC and the depositor 1900 USDC.

Remediation#

Pass 10 ** 18, or the vault's own share decimals, into convertToAssets. Keep the high-water mark in that same unit.

How to reproduce#

BASH
cd 45889-converttoassets-is-receiving-assets-decimals-instead-of-shar_exp
forge test -vv

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.