Sophisticated rounding error exploitation in Bunni AMM led to $8.4M loss through disproportionate liquidity manipulation
BunniHubLogic::withdraw()
:
mulDiv
function was intentionally rounded down during development, with the assumption that this would round up the idle balance and round down the active balance. The developers considered this “safe” since lower liquidity meant more price impact during swaps, favoring the pool.
Why This Assumption Failed:
While the rounding direction was safe for individual operations, it became exploitable when combined with multiple operations in sequence.
totalLiquidityEstimate0
(USDC-based)totalDensity0X96
to become miniscule (1 wei)totalLiquidityEstimate1
(USDT-based) the chosen estimate, which was larger than the artificially decreased value from step 2