Uniswap v4 hook audit: permissions, callbacks and deltas
A Uniswap v4 hook audit checks who can call each callback, whether the permission flags in the hook's address match its code, how the hook accounts for the deltas it takes or returns, and which pools and routers it trusts. QuillShield audits the hook with the rest of your protocol, then checks each pull request against that audit.
What goes wrong in Uniswap v4 hooks?
A hook runs inside every swap or liquidity change of the pools that name it, and with return-delta permissions it can change what a trader pays or receives. Trail of Bits looked at two hook incidents, Cork and Bunni, and found that neither came from a flaw in Uniswap v4's core contracts. Both came from authorization and accounting logic the teams wrote around their hooks.
- Callbacks anyone can call. Each hook entry point has to accept calls only from the PoolManager, and
unlockCallbackneeds the same check. The page on Uniswap v4 hook vulnerabilities walks through the missing check behind Cork's loss. - Permission flags out of sync. The PoolManager reads which callbacks to run from the low bits of the hook's address. When those bits and the code disagree, callbacks are skipped, calls revert, or returned deltas are ignored.
- Delta and balance accounting. Custom curves, fees and return deltas move real tokens. Each balance needs an owner, rounding has to favor the pool, and the totals have to match the tokens the hook actually holds. The page on rounding and precision errors covers the arithmetic.
- Pools you did not plan for. Anyone can create a pool that names your hook unless
beforeInitializerefuses it, and one pool's state can leak into another's when it is not keyed by PoolId. - The wrong user. The
sendera callback receives is the contract that called the PoolManager, usually a router. Rewards or limits based on it go to the router, andhookDatais only as trustworthy as the router that sent it. See access control.
What has gone wrong before?
Bunni V2 was an automated market maker built on Uniswap v4 hooks, with its own liquidity curve and part of its reserves deposited in ERC-4626 vaults. On 2 September 2025 an attacker took about $8.4M from two pools, USDC/USDT on Ethereum and weETH/ETH on Unichain.
The bug was one rounding direction. When Bunni's withdraw updated a pool's idle balance, it rounded down, which overstated the idle balance and understated the liquidity the curve could use. Bunni's post-mortem, as The Block reported it, says the attacker swapped with 3 million USDT from a flash loan until the pool's active USDC balance was 28 wei. BlockSec's analysis counts 44 tiny withdrawals after that, which cut the balance to 4 wei while burning almost no shares, and then a sandwich around the distorted pool that took the funds.
Bunni's post-mortem says each rounding direction was safe on its own and the exploit came from combining operations. In October 2025 the team shut Bunni down, saying it could not afford a secure relaunch.
How do a full audit and pull request checks fit a hook team?
Audit the hook before you mine its address. The permission flags are part of the address, so a hook that needs a different set of callbacks needs a new deployment, and a pool keeps the hook it was created with.
Put the hook in scope together with the routers that call it, any vault or lending market it deposits into, and your fee and reward logic. QuillShield reviews them as one codebase and builds a security graph of the code. As context, list the routers you trust, the pools the hook should serve and who controls fees, so the audit can compare the code with what you meant it to do.
Hook logic changes after launch too: a new fee rule, a reward, another router. With pull request checks on, each change is compared with the audit's security graph, and a required check on GitHub keeps a change with a High or Critical finding out of your protected branch. GitLab.com projects get a commit status and a note on the merge request.
What does a hook audit cost?
Pricing follows the lines of Solidity in scope. The pricing page lists 100 lines at $79 and 1,000 lines at $379 as of November 2026, and a quote stays valid for 7 days. Five pull request checks come with each full audit of a GitHub or GitLab.com repository. Run your first audit shows where you choose the files in scope, and sign-up is free.
What should you check before you deploy a hook?
- Does every callback, and
unlockCallback, requiremsg.senderto be the PoolManager? - Do the address flags match the callbacks the hook implements, including the return-delta flags?
- Who can initialize a pool with this hook, and does
beforeInitializelimit it to the pools you expect? - Is every piece of per-pool state keyed by a PoolId derived from the PoolKey, rather than one taken from user input?
- Does every balance and delta have a named owner, and do the totals match the tokens the hook holds?
- Do custom curves and fees round in the pool's favor at tiny balances and over many small operations?
- Can a reverting callback block swaps or liquidity removal for everyone?
- Do the tests run against the real PoolManager, with fuzzed amounts and repeated small withdrawals?
Common questions
Can I change a hook's callbacks after it is deployed?
Not at the same address. The PoolManager reads the permission flags from the hook's address, so a different set of callbacks needs a new deployment. A proxy can change the logic behind an address, but not the flags in it.
What should a hook audit include besides the hook?
The routers that call it, any vault or market it moves funds into, your fee and reward logic, and the tests. Bunni's rounding bug was in its withdrawal logic rather than in a hook callback.
How much does a Uniswap v4 hook audit cost?
It is priced from the lines of Solidity in scope. On the pricing page, 100 lines cost $79 and 1,000 lines $379 as of November 2026, and the quote shows the exact price before you pay.
When should a hook be audited again?
When you add a callback, change fee or reward logic, add a router or send funds somewhere new. Pull request checks review those changes against the last full audit, and a change that adds Solidity files, more than 150 lines or more than 5 changed files gets a recommendation for a new full audit.
Sources
- Bunni cites smart contract rounding error for $8.4 million flash loan exploit, The Block
- Bunni incident: repeated small withdrawals compound a rounding error, BlockSec
- Bunni DEX shuts down after $8.4 million exploit, The Block
- Building secure Uniswap v4 hooks, Trail of Bits
- Hook deployment, Uniswap docs