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…
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
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.
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-registrymirror.
Vulnerability classes:
vuln/logic/missing-check
Key info#
| Field | Value |
|---|---|
| Loss | 1000 BT1 of bids and rents |
| Vulnerable contract | BunniHook.rebalanceOrderPostHook |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2024-11 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | Post-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#
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:
- 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#
- The hook's balance is read as 1000 BT1.
- The post-hook sets the output to that balance.
- The hook transfers 1000 BT1 to the attacker.
- The hook balance is 0.
- The control forwards a received amount of 0 and the bids stay.
Diagrams#
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#
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#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/43544-c-05-attacker-can-steal-bids-and-rent-tokens-from-bunnihook.md
- Pashov report: https://github.com/pashov/audits/blob/master/team/md/Bunni-security-review-August.md
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 43544-c-05-attacker-can-steal-bids-and-rent-tokens-from-bunnihook_exp (evm-hack-registry mirror).
- AuditVault finding: 43544-c-05-attacker-can-steal-bids-and-rent-tokens-from-bunnihook.
Alerts & third-party analyses
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.