Reproduced Exploit

zkSync Mailbox rejects an ETH withdrawal that is still inside the daily cap

withdraw computes the daily cap as withdrawalFactor * address(this).balance / 100. The balance already excludes withdrawals from earlier in the same window.

Feb 2023•Ethereum•logic•2 min read

Loss

40 ETH stays in the mailbox. The opening balance is 1000 ETH, so the 10 percent daily cap is 100 ETH. After a…

Chain

Ethereum

Category

logic

Date

Feb 2023

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: 33111-eth-withdrawal-within-allowed-limit-could-fail-openzeppelin. Standalone Foundry PoC and full write-up: 33111-eth-withdrawal-within-allowed-limit-could-fail-openzeppelin_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/withdrawal-limit · vuln/dos/frozen-funds

Key info#

FieldValue
Loss40 ETH stays in the mailbox. The opening balance is 1000 ETH, so the 10 percent daily cap is 100 ETH. After a 60 ETH withdrawal the next 40 ETH reverts
Vulnerable contractMailbox.withdraw
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit at 0x15452ec016c4dc8c549e7fe6ff4b26324ea8b7a4
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2023-02
Compilersolc 0.8.27, cancun, via IR
Bug classDaily cap multiplies the live balance instead of the balance at the start of the window
flowchart TD A["Mailbox holds 1000 ETH and the factor is 10"] --> B["First withdraw of 60 ETH is inside 100 ETH"] B --> C["Balance is now 940 ETH"] C --> D["VULN cap becomes 94 ETH"] D --> E["Second withdraw of 40 ETH makes used = 100 and reverts"] C --> F["Control snapshots 1000 ETH when the window opens"] F --> G["Both withdrawals pay and 900 ETH remains"]

TL;DR#

withdraw computes the daily cap as withdrawalFactor * address(this).balance / 100. The balance already excludes withdrawals from earlier in the same window.

A mailbox seeded with 1000 ETH has a 100 ETH cap. The first call sends 60 ETH. The balance is then 940 ETH, so the next cap is 94 ETH. A further 40 ETH makes used equal 100, and 100 <= 94 reverts. Those 40 ETH stay in the contract. Together the two calls are exactly 10 percent of the opening balance.

The fixed mailbox stores address(this).balance when the window id changes and divides that snapshot. Both calls succeed and the mailbox holds 900 ETH.

The vulnerable code#

SOLIDITY
lastCap = (withdrawalFactor * address(this).balance) / 100; // @> VULN: cap uses the post-withdrawal balance
lastUsed = amount + withdrawnAmountInWindow;
emit CapChecked(lastCap, lastUsed);
require(lastUsed <= lastCap, "w4");

The quoted Mailbox check is _amount + s.withdrawnAmountInWindow <= (limitData.withdrawalFactor * address(this).balance) / 100.

Impact#

A withdrawal that is inside the published daily limit fails because an earlier withdrawal in the same window reduced address(this).balance. In this run, 40 ETH of the 100 ETH opening cap cannot leave.


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.