Skip to content
Business logic Write-up Advanced

Exposing a Critical Uniswap V4 Hook Flaw: Cross-Pool Invariant Manipulation

A Uniswap v4 hook tracked reserves for all supported tokens in one global array instead of per-pool state. An attacker could skew the shared invariant by trading in a low-liquidity side pool, then swap in an unrelated high-value pool at a manipulated price and drain funds.

coinsbench.com

Published on coinsbench.com

When auditing decentralized finance (DeFi) protocols, the most devastating bugs rarely come from simple typos or reentrancy. They come from fundamental architectural assumptions.

Hacker MD, on coinsbench.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The hook calculated its StableSwap invariant from a single global reserves array shared across all PoolKeys instead of isolating reserves per PoolId.

Impact

Any attacker could use a low-liquidity side pair to manipulate the pricing of large stablecoin pairs, causing a permanent drain of liquidity provider funds through toxic arbitrage.

What the attacker needed

Hook supports multiple pairwise pools; a low-liquidity side pool exists; attacker can trade in both pools

The fix

The fix required a fundamental architectural rewrite to map reserves strictly to their respective PoolIds.

How it was found

  1. Query the execution price for a 1,000 USDC to USDT swap in a balanced state and confirm a 1:1 ratio.
  2. Deposit a massive amount of DAI into the USDC/DAI pool, spiking the global reserves array and skewing the invariant.
  3. Swap in the USDC/USDT pool, which now uses the corrupted global invariant, and drain USDT at an artificially cheap rate.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A hook is a small contract that runs custom logic around a Uniswap pool. This hook kept one shared list of token balances for every pool it managed, so changing the balance of one token in one pool changed the price maths for all the other pools too. An attacker could therefore push a cheap pool around and then trade in a valuable pool at a price that was not real.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.