Introduction to Bunni V2 Protocol

Bunni is liquidity protocol built on Uniswap V4 but instead of integrating liquidity curve of Uniswap, it customized it's own curve by utilizing the new hooks feature introduced in V4 to develop UniformDistribution equivalent to uniswap V3 position where it recomputes the idle balance of the pool after each trade BunniHookLogic to detect if the curve has a liquidity surplus, if found it rebalance the liquidity pool to maintain the curve in the correct tokens ratio.

How the Attacker Exploit the Protocol

The exploit targeted this rebalance mechanism. By crafting a sequence of swaps, the attacker tricked the hook into miscalculating surplus, causing it to distribute more output tokens than intended. This logical flaw allowed the attacker to drain ~$8.3M from the pool.

Hack Analysis

Bunni's Uniform Distribution of liquidity miscalculated balance after each trade that goes through Uniswap v4, didn't count properly for flash accounting and deltas which left change or small amounts to be exploit by accumulation, if a well sized swap executed repeatedly.

x-large zoom
Exploit Funds Flow