Reproduced Exploit

Berachain: the first post-genesis deposit overwrites a genesis validator and locks 1 ETH

Genesis already occupies deposit index 0, but depositCount starts at 0. deposit pulls 1 ETH and enqueue writes the new pubkey at that index. The genesis record is replaced. depositCount advances to 1, which equals genesisCount, so the beacon does not see a new validator. There is no withdraw functi…

Jan 2025•Other•logic•2 min read

Loss

1 ETH locked; genesis index 0 is replaced and no new index is allocated

Chain

Other

Category

logic

Date

Jan 2025

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: 53114-first-deposits-will-be-ignored-and-lost-cantina-none-beracha. Standalone Foundry PoC and full write-up: 53114-first-deposits-will-be-ignored-and-lost-cantina-none-beracha_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/state-update · vuln/dos/frozen-funds

Key info#

FieldValue
Loss1 ETH locked; genesis index 0 is replaced and no new index is allocated
Vulnerable contractDepositStore.enqueue
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateLocal synthetic · 2025-01
Compilersolc 0.8.27, cancun, via IR
Bug classdepositCount starts at 0 while genesis already occupies index 0

TL;DR#

Genesis already occupies deposit index 0, but depositCount starts at 0. deposit pulls 1 ETH and enqueue writes the new pubkey at that index. The genesis record is replaced. depositCount advances to 1, which equals genesisCount, so the beacon does not see a new validator. There is no withdraw function.

The vulnerable code#

SOLIDITY
function enqueue(uint256 index, bytes32 pubkey, uint256 amount) external {
    deposits[index] = Deposit(pubkey, amount, true);
}

function deposit(bytes32 pubkey, uint256 amount) external {
    ethToken.transferFrom(msg.sender, address(this), amount);
    store.enqueue(depositCount, pubkey, amount);
    depositCount += 1;
}

Seed depositCount from genesisCount, or reject an index below genesisCount.

Root cause#

The live counter and the genesis map share an index space, and the live counter is not initialized from genesis.

Preconditions#

  • Index 0 holds a genesis pubkey and a 32 ETH accounting amount. genesisCount is 1.
  • depositCount is still 0. The depositor has 1 ETH.

Attack walkthrough#

  1. The depositor sends 1 ETH and a new pubkey.
  2. The deposit contract pulls the ETH.
  3. enqueue overwrites index 0 with the new pubkey.
  4. The stored key is the new key. depositCount reads back as 1, equal to genesisCount. The 1 ETH is still in the deposit contract.

Diagrams#

flowchart TD A["Genesis occupies index 0"] --> B["depositCount is still 0"] B --> C["Deposit pulls 1 ETH"] C --> D["enqueue writes the new pubkey at index 0"] D --> E["No new index is allocated and the 1 ETH stays locked"]

Impact#

The first post-genesis deposit replaces a genesis validator and cannot be withdrawn. This run locks 1 ETH.

How to reproduce#

BASH
cd 53114-first-deposits-will-be-ignored-and-lost-cantina-none-beracha_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.