Hooks let pools run custom logic on swaps and liquidity changes: dynamic fees, custom accounting, external calls. That flexibility relocates trust boundaries into hook code, and two real incidents (Cork, Bunni) show where it breaks.
The recurring failures Trail of Bits flags:
Access control: hook callbacks must reject any caller that isn't the
PoolManager, and validate the pool key. Anyone can call your hook directly otherwise.Reentrancy via the unlock pattern: v4's flash-accounting
unlock lets external calls re-enter mid-settlement. Never assume balances are final inside a callback.Arithmetic/rounding: custom accounting that rounds in the user's favor leaks value over many swaps — the Bunni-class bug.
Treat hooks as untrusted-by-default: authenticate the caller, guard reentrancy, round against the user.
Trail of Bits: Building secure Uniswap v4 hooks
@soliditypedia