TGViewer
Solidity Treasures Solidity Treasures @soliditypedia · 4.28K subscribers
Post #579 532
Uniswap v4 hooks move security into your code — and the defaults bite

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
The Trail of Bits Blog Building secure Uniswap v4 hooks This blog post identifies seven recurring failure patterns in application and hook code, including missing caller checks and accounting bugs that still satisfy the PoolManager’s settlement invariant.
  • 👍 1
More from @soliditypedia
  1. Sep 22, 2026Deploy at the same address on every chain, without shipping initcode. Plain CREATE2 ties t…
  2. Sep 18, 2026An on-chain guard for AI-agent transactions moves the trust to whoever signs the attestati…
  3. Sep 16, 2026A generalized MEV bot beat the attacker to the rsETH exploit in the same block When the ex…
  4. Sep 15, 2026Public-mempool gas sponsorship can't have all three: no locked money, no off-chain trust,…
  5. Sep 13, 2026A QEMU/KVM sandbox is not a boundary for a cyber-capable agent Trail of Bits gave a fronti…
  6. Sep 12, 2026This week in Solidity Allbridge halted its core bridge after a $1.65M exploit: a $1.12M Ka…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →