Reproduced Exploit

BunniHook rebalance sends managers' bids to the attacker's pool

BunniHook holds 1000 BT1 that managers posted as am-AMM bids. rebalanceOrderPostHook treats balanceOf(this) as the amount just bought and transfers all of it to the hub of the pool being rebalanced. The attacker points that hub at themselves and receives the 1000 BT1. rebalanceReceived, which forwa…

Nov 2024•Ethereum•logic•3 min read

Loss

1000 BT1 of bids and rents

Chain

Ethereum

Category

logic

Date

Nov 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: 43544-c-05-attacker-can-steal-bids-and-rent-tokens-from-bunnihook. Standalone Foundry PoC and full write-up: 43544-c-05-attacker-can-steal-bids-and-rent-tokens-from-bunnihook_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/missing-check

Key info#

FieldValue
Loss1000 BT1 of bids and rents
Vulnerable contractBunniHook.rebalanceOrderPostHook
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-11
Compilersolc 0.8.27, cancun, via IR
Bug classPost-hook forwards the whole balance

TL;DR#

BunniHook holds 1000 BT1 that managers posted as am-AMM bids. rebalanceOrderPostHook treats balanceOf(this) as the amount just bought and transfers all of it to the hub of the pool being rebalanced. The attacker points that hub at themselves and receives the 1000 BT1. rebalanceReceived, which forwards only the amount the swap actually delivered, leaves the 1000 BT1 on the hook when that amount is 0.

Background#

Pashov Audit Group's Bunni v2 review, published 5 November 2024, finding C-05. The report shows orderOutputAmount = args.currency.balanceOfSelf() inside rebalanceOrderPostHook, and describes an attacker pool whose output currency is the victim BunniToken.

The vulnerable code#

SOLIDITY
orderOutputAmount = token.balanceOf(address(this)); // @> VULN: full balance, not the amount this swap just received
// FIX: orderOutputAmount = balanceAfter - balanceBefore

The change that removes the harm:

DIFF
- orderOutputAmount = token.balanceOf(address(this));
+ orderOutputAmount = balanceAfter - balanceBefore;

Root cause#

The hook does not snapshot its balance before the swap. Every token already held, including bids and rents, is indistinguishable from swap output and is pushed to the hub.

Preconditions#

  • The hook's BT1 balance is 1000 ether of bids.
  • The attacker can cause a rebalance whose output currency is that same BT1.
  • The hub argument is the attacker's address.

Attack walkthrough#

  1. The hook's balance is read as 1000 BT1.
  2. The post-hook sets the output to that balance.
  3. The hook transfers 1000 BT1 to the attacker.
  4. The hook balance is 0.
  5. The control forwards a received amount of 0 and the bids stay.

Diagrams#

flowchart TD A["Hook holds 1000 BT1 of bids"] --> B["Attacker rebalance uses BT1 as the output"] B --> C["VULN output amount is balanceOf the hook"] C --> D["1000 BT1 is transferred to the attacker"] B --> E["Control forwards only the received amount and bids stay"]

Impact#

Managers lose 1000 BT1. The attacker holds it. The control path does not move the bids.

Remediation#

Transfer only the tokens received during this rebalance, which is the balance increase, not balanceOf of the hook.

How to reproduce#

BASH
cd 43544-c-05-attacker-can-steal-bids-and-rent-tokens-from-bunnihook_exp
forge test -vv

test_exploit is the harm. The control test is the guarded path. 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.