Reproduced Exploit
Sweep n Flip — Premature createPair creates unusable delegated pairs
1. Wrapper addresses for ERC721 collections are CREATE2-predictable from the factory. 2. Ideal flow is createWrapper then createPair. An attacker can call createPair(usdc, precomputedWrapper) before the wrapper exists. 3. Because the address is not yet a registered wrapper, createPair marks the pai…
Chain
Other
Category
logic
Date
Nov 2024
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. No backend, no live RPC.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 46466-premature-createpair-function-call-will-result-in-the-creati. Standalone Foundry PoC and full write-up: 46466-premature-createpair-function-call-will-result-in-the-creati_exp in the
evm-hack-registrymirror.
Vulnerability classes: vuln/logic/missing-check · impact/mev/frontrun · frozen-funds · dos-resistance
Reproduction: self-contained Foundry PoC, offline, forge-std only. Full trace: output.txt. PoC: test/46466-premature-createpair-function-call-will-result-in-the-creati_exp.sol.
Key info#
| Impact | HIGH — permanent DoS of legitimate ERC721-wrapper trading pairs |
| Protocol | Sweep n Flip (UniswapV2-NFT AMM) |
| Vulnerable code | UniswapV2Factory.createPair — marks unknown tokens as delegated |
| Bug class | CREATE2-precomputable wrapper address front-run → permanent delegated flag |
| Finding | Cantina — Sweep n Flip NFT AMM, Nov 2024 · #46466 · reporter slowfi |
| Report | cantina_sweepnflip_nft_amm_november2024.pdf |
| Source | AuditVault |
| Status | Audit finding — fixed in uniswap-v2-nft PR 5 |
| Compiler | ^0.8.24 (PoC) |
TL;DR#
- Wrapper addresses for ERC721 collections are CREATE2-predictable from the factory.
- Ideal flow is
createWrapperthencreatePair. An attacker can callcreatePair(usdc, precomputedWrapper)before the wrapper exists. - Because the address is not yet a registered wrapper,
createPairmarks the pair as delegated (external DEX). - Later
createWrapperdeploys at the same address, but the delegated flag is never cleared — the pair is permanently unusable on Sweep n Flip.
The vulnerable code#
if (!isWrapper[token0] && !isWrapper[token1]) {
delegates[token0][token1] = true; // @> VULN: marks precomputed (unregistered) wrapper as delegated forever
delegates[token1][token0] = true;
}
Fix: require a registered wrapper (or matching extcodehash) before creating a native pair; or merge createWrapper + createPair.
Root cause#
createPair only checks the isWrapper registry, not whether an address is a CREATE2-precomputable future wrapper. Front-running createWrapper permanently poisons the pair as delegated.
Preconditions#
- Factory uses CREATE2 for WERC721 with a salt derived from the collection address.
createPairis permissionless.- Target NFT collections are known / enumerable (top collections are few).
Attack walkthrough#
- Precompute
wrapper = CREATE2(factory, salt(collection), WERC721 initcode). - Call
createPair(usdc, wrapper)— neither side isisWrapperyet →delegates = true. - Legitimate
createWrapper(collection)deploys at the same address and setsisWrapper. - HARM:
delegates(usdc, wrapper)remains true — Sweep n Flip native trading is DoS'd for that collection.
Diagrams#
Impact#
Denial of service for legitimate NFT-wrapper trading pairs. A handful of front-runs against top collections can brick the core product surface.
Sources#
- AuditVault finding #46466
- Cantina report — Sweep n Flip NFT AMM (Nov 2024)
- Reduced C2 synthetic from finding-quoted
createPair/ CREATE2 wrapper flow (uniswap-v2-nft audited commit / PR 5 fix)
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 46466-premature-createpair-function-call-will-result-in-the-creati_exp (evm-hack-registry mirror).
- AuditVault finding: 46466-premature-createpair-function-call-will-result-in-the-creati.
Alerts & third-party analyses
These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.