Building secure Uniswap v4 hooks
Uniswap v4 hooks shift security responsibility onto application code: the PoolManager enforces swap math, callback sequencing and end-of-session settlement, but not a hook's authorization or internal accounting. Drawing on audits and incidents like Cork (~$12M) and Bunni ($8.4M), seven recurring failure patterns emerge: unchecked callers, trusting arbitrary PoolKeys, leaky custom accounting that still passes settlement, logic in the wrong callback, address permission bits out of sync with implemented callbacks, non-essential hook code blocking exits, and shared state mutating across nested callbacks. Fixes include BaseHook/SafeCallback caller checks, pool allowlists keyed by PoolId, separate balance buckets, try/catch for optional calls, and fuzzing adversarial scenarios with Echidna and Medusa, packaged as checklists for builders and auditors.
Related posts
- State divergence enables unauthorized access
Trail of Bits mediumAdeptProvenance Blockchain's marker module let any account grant itself ACCESS_ADMIN, mint and withdraw rights on non-fixed-supply markers. The authorization check compared the caller's bank balance to a stale supply field on the marker struct that stays zero, so a caller holding nothing passed via 0 == 0. Two transactions were enough to mint arbitrary tokens or drain escrow, putting 82 mainnet markers and about $500,000 in escrowed nhash at risk. The fix reads live supply from the bank module and adds an explicit zero-supply guard, illustrating that an authorization predicate must never be satisfiable from an attacker's default state.
- After Binance, check what your signing systems can approve
Trail of Bits hardMasterBinance's October 2026 breach showed that attackers who compromise a service allowed to request signatures can misuse a protected key without ever extracting it. Here the attacker obtained a signed EIP-7702 delegation that persisted on-chain and enabled repeated drains, including of later deposits, with no further signatures. Signing policies and monitors that only watch transfers and ownership changes miss authority shifts via EIP-7702 authorizations, Safe modules, session keys and ERC-4337 UserOperations. A four-step checklist follows, each step with verification tests: inventory and isolate signing access, treat delegation as an admin privilege with separate approval and simulation, add custody limits the operational key cannot bypass, and alert on wallet authority changes.
- Supabase Auth: Identity Linking, Hooks, and HaveIBeenPwned integration
Supabase mediumAdeptSupabase Auth adds four features: manual Identity Linking via linkIdentity()/unlinkIdentity() for OAuth identities, session controls (time-boxed sessions, inactivity timeouts, single session per user on Pro and above), leaked password protection using the HaveIBeenPwned Pwned Passwords API with configurable password requirements, and Auth Hooks. Auth Hooks are Postgres functions that run synchronously at points such as access token generation, MFA verification and password verification, so they can add custom JWT claims or enforce custom security rules. Webhook-based hooks via Standard Webhooks are planned for Q1 2024. The GoTrue fork is also being renamed to Auth, with no breaking changes.
- Post mortem on Linear security incident on March 24th, 2026
Linear mediumAdept
A performance optimization to Linear's "sync group" access-control resolvers contained a variable shadowing bug in the disabled code path. For all non-target workspaces it dropped every user-specific resolver, so permission filtering was silently skipped instead of erroring. For about an hour on March 24, 2026, private-team issues, comments, documents and projects leaked to other members of the same workspace, including guests. The main exposure routes were digest emails, about 7,000 client bootstraps, mobile sessions, API/OAuth queries and background tasks. Tests had covered only the path where the optimization was enabled. Fixes include broader permission-boundary integration tests, caps on digest size, stricter security review of authorization code and monitoring for permission violations.
- When protections outlive their purpose: A lesson on managing defense systems at scale
GitHub Engineering mediumAdeptEmergency protection rules added during past GitHub abuse incidents were left in place and began rate-limiting legitimate logged-out users with "Too many requests" errors. The rules combined fingerprinting with business-logic signals. Only 0.5–0.9% of fingerprint matches were blocked, but false positives still reached about 3–4 per 100,000 requests. Finding the cause meant correlating logs across edge, application and service layers with different schemas. GitHub removed the stale rules and now treats incident mitigations as temporary by default, with expiration, post-incident review and cross-layer visibility into which layer blocked a request.