Reproduced Exploit

VirtualToken cashIn mints msg.value and locks the ERC20 deposit

cashIn pulls amount of the underlying token, then mints msg.value. For an ERC20 that value is 0. A call with 100 USDT and no ETH leaves the virtual token holding 100 and the depositor holding 0 shares.

Dec 2024•Ethereum•logic•2 min read

Loss

100 USDT is pulled into the virtual token and the depositor is minted 0 shares

Chain

Ethereum

Category

logic

Date

Dec 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: 49608-h-01-loss-of-user-funds-in-virtualtokens-cashin-function-due. Standalone Foundry PoC and full write-up: 49608-h-01-loss-of-user-funds-in-virtualtokens-cashin-function-due_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/mint-amount · vuln/defi/deposit

Key info#

FieldValue
Loss100 USDT is pulled into the virtual token and the depositor is minted 0 shares
Vulnerable contractVirtualToken.cashIn
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit at 0x15452ec016c4dc8c549e7fe6ff4b26324ea8b7a4
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-12
Compilersolc 0.8.27, cancun, via IR
Bug classAn ERC20 cash-in mints msg.value instead of amount
flowchart TD A["The depositor calls cashIn with 100 USDT and no ETH"] --> B["100 USDT is pulled into the virtual token"] B --> C["VULN the mint uses msg.value, which is 0"] C --> D["The depositor holds 0 shares and the token holds the 100"] B --> E["Control mints amount"] E --> F["The depositor holds 100 shares against the 100 USDT"]

TL;DR#

cashIn pulls amount of the underlying token, then mints msg.value. For an ERC20 that value is 0. A call with 100 USDT and no ETH leaves the virtual token holding 100 and the depositor holding 0 shares.

The fixed cashIn mints amount. The same 100 USDT deposit credits 100 shares.

The vulnerable code#

SOLIDITY
function cashIn(uint256 amount) external payable {
    asset.transferFrom(msg.sender, address(this), amount);
    lastValue = msg.value;
    _mint(msg.sender, msg.value); // @> VULN: ERC20 cash-in mints msg.value, which is 0
}

Impact#

The depositor pays 100 USDT and receives nothing back. The 100 sits in the virtual token.

How to reproduce#

BASH
cd 49608-h-01-loss-of-user-funds-in-virtualtokens-cashin-function-due_exp
forge test -vv

test_exploit_erc20_mints_zero asserts 0 shares and 100 USDT inside the token. test_control_mints_the_amount asserts 100 shares.

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.