# CREATE2 Metamorphic Contracts & EIP-6780 SELFDESTRUCT Audit

> Detect metamorphic smart-contract rug pulls (CREATE2 + CREATE + SELFDESTRUCT), Cancun EIP-6780 same-tx destruction rules, and DAO governance attacks.

Canonical: https://nftvenueledger.com/protocols/create2-metamorphic-contract-redeployment-rug-detection
Last updated: 2026-11-14T19:55:50.771Z

**Publication:** NFTVenue Ledger
**Category:** Erc721 Erc1155 Eip712 Permit Security
**Published:** 2026-11-13T18:10:25.915Z
**Author:** Dr. Devon Kurosawa, PhD (PhD in Distributed Systems & Cryptographic Protocol Verification)
**Reviewer:** Not recorded

## Answer-first summary

Before Dencun EIP-6780, attackers disguised upgradeable rug-pull contracts as immutable non-proxy code using CREATE2 + CREATE + SELFDESTRUCT metamorphic factories.

## Key takeaways

- Pre-Cancun metamorphic attacks chained CREATE2 + CREATE + SELFDESTRUCT (or dynamic init_code loaders) to swap verified immutable-looking bytecode right before DAO or Conduit execution.
- Cancun EIP-6780 permanently disabled post-deployment bytecode deletion and nonce resets on Ethereum and aligned Rollups—only same-transaction creation + SELFDESTRUCT still clears code.
- Even after EIP-6780, SELFDESTRUCT still force-sends ETH without triggering receive, breaking strict address(this).balance == accounting equality checks.
- DAO Governors must pin target.codehash at proposal creation and re-verify equality at execution, while CREATE2 factories must hash msg.sender and init args into the salt.

## Related financial entities

- **Checks-Effects-Interactions (CEI) Security Pattern** (CEI-SEC) — product: Foundational programming design pattern in smart contract development preventing reentrancy attacks by executing internal state updates before external calls.
- **EIP-712 Typed Structured Data Standard** (EIP-712) — product: Standard for hashing and signing of typed structured data as opposed to just arbitrary byte strings, providing human-readable authorization.
- **Seaport Marketplace Protocol Standard** (SEAPORT) — product: Open-source, highly optimized marketplace contract suite for efficiently buying and selling fungible and non-fungible tokens.

## Analysis

In May 2023, an attacker submitted a benign-looking DAO governance proposal (`Tornado Cash DAO takeover`) whose verified proposal contract on Etherscan contained **zero `DELEGATECALL` proxy opcodes**—convincing token holders the proposal bytecode was 100% immutable! Seconds before execution, the attacker triggered an emergency `SELFDESTRUCT`, wiped the verified proposal contract, and **redeployed completely different malicious bytecode at the exact same Ethereum address** to seize complete DAO governance!

Anchored in our [EIP-712, Permit2 & proxy security master guide](/protocols/eip712-permit2-erc721-royalty-proxy-timelock-security-2026), understanding **`CREATE2` Metamorphic Redeployment Chains** and **Cancun EIP-6780 `SELFDESTRUCT` Semantics** is critical when auditing Seaport Zones, Uniswap v4 Hooks, and cross-chain deployments across EVM L1s and L2s in our [marketplaces directory](/marketplaces) (from [9mm Pro](/marketplaces/9mm-pro) to [Baryonswap Viction](/marketplaces/baryonswap-viction) where older EVM hard-fork parity must be verified!).

## How the `CREATE2 -> CREATE -> SELFDESTRUCT` Metamorphic Trick Worked!

At first glance, `CREATE2` hashes `init_code` (`keccak256(0xff ++ deployer ++ salt ++ keccak256(init_code))`), so changing bytecode appears to change the deployed address. Watch the two-stage trick that bypassed human source-code review:

1. **Non-Deterministic Initcode Loader**: `CREATE2` hashes the **initialization code (`init_code`)**, NOT the **runtime code** returned by `init_code`! A 30-byte loader `init_code` simply calls `factory.getImplementation` during construction and `EXTCODECOPY`s whatever runtime bytecode the factory points to today!
2. **Or the `CREATE2 -> CREATE` Nonce Reset Chain**: Factory `F` (deployed via `CREATE2` with `SELFDESTRUCT`) deploys Target `T` via regular **`CREATE`** at `nonce = 1` (`Address(T) = keccak256(rlp([F, 1]))`)—so `T`'s `init_code` isn't hashed at all! When both `T` and `F` called `SELFDESTRUCT`, `F`'s nonce reset to `0`; redeploying `F` at the identical `CREATE2` address reset `F`'s nonce to `1`, deploying **arbitrary new bytecode `T'` at the exact same address `T`**!

![Pre-Cancun CREATE2 metamorphic contract swap vs Post-Cancun EIP-6780 SELFDESTRUCT opcode neutralization](/api/figure?type=flow&title=Metamorphic%20Contract%20Chain%20%26%20Cancun%20EIP-6780%20Neutralization&subtitle=How%20Dencun%20EIP-6780%20permanently%20severed%20post-deployment%20bytecode%20replacement%20on%20Ethereum%20%26%20Rollups&steps=1.%20Ancestor%20Trace%3A%3AAudit%20deployer%20lineage%3A%20walk%20T%20%3C-%20Factory_1%20%3C-%20CREATE2_Root%7C2.%20Opcode%20Byte%20Scan%3A%3AScan%20T%20%26%20all%20ancestor%20factories%20for%200xff%20%28SELFDESTRUCT%29%20or%200xf4%20%28DELEGATECALL%29%7C3.%20EIP-6780%20Hard%20Fork%3A%3AOn%20Cancun%2B%20chains%2C%200xff%20transfers%20ETH%20ONLY%3B%20code%20%26%20nonce%20NEVER%20clear!%7C4.%20Codehash%20Pinning%3A%3AGovernance%20%26%20Conduits%20pin%20expected%20extcodehash%28target%29%20before%20execution!&metrics=SELFDESTRUCT%20HEX%3A%3AOpcode%200xff%3A%3ANeutered%20post-deployment%20by%20EIP-6780%7CSAME-TX%20EXCEPTION%3A%3ADeploy%20%2B%200xff%3A%3AClears%20code%20ONLY%20if%20created%20in%20SAME%20tx!%7CALT-EVM%20WARNING%3A%3ACheck%20Fork%20Spec!%3A%3APre-Cancun%20sidechains%20still%20allow%200xff!%7CGOVERNANCE%20DEFENSE%3A%3Aextcodehash%20%3D%3D%20H%3A%3A1-line%20pre-execution%20hash%20assertion)

## What Cancun **EIP-6780** Changed—And What Residual Edge Cases Remain!

Activated in the March 2024 **Dencun** hard fork on Ethereum Mainnet (and Cancun-aligned L2s like Arbitrum, Optimism, and Base), **EIP-6780** radically neutered `0xff (SELFDESTRUCT)`:

- **In Any Transaction After Deployment**: Executing `SELFDESTRUCT(beneficiary)` **transfers the contract's ETH balance to `beneficiary` ONLY**—it **does NOT delete contract bytecode, does NOT wipe storage, and does NOT reset account nonce**! Consequently, **post-deployment metamorphic `CREATE2` rugs are 100% impossible on EIP-6780 chains**!
- **Three Residual Traps Auditors STILL Catch in 2026**:
 1. **Lagging Alt-L1s / Legacy EVM Sidechains**: Several older EVM-compatible sidechains and enterprise forks have *not* activated EIP-6780—where classic metamorphic rugs still work!
 2. **Broken `address(this).balance` Accounting via `SELFDESTRUCT`**: Even under EIP-6780, an attacker can deploy an ephemeral contract and `SELFDESTRUCT(victimVault)` **inside the same transaction**, force-feeding ETH into `victimVault` without triggering `receive` and breaking naive `require(address(this).balance == totalAccounting)` invariants!
 3. **Counterfactual Pre-Deployment Hijacking (`CREATE2` Parameter Frontrunning)**: If a factory derives `salt = userSuppliedSalt` without hashing `msg.sender` or initialization parameters into `salt`, a mempool bot can frontrun `CREATE2` deployment with tampered admin arguments!

## Bytecode Mutability & Provenance Verification Matrix

| Mutability Vector | Etherscan Shows "Proxy"? | Works on Cancun (EIP-6780) Ethereum? | Works on Pre-Cancun EVM? | Deterministic On-Chain Defense |
| :--- | :--- | :--- | :--- | :--- |
| ERC-1967 / UUPS / Diamond Proxy | **Yes** (`0xf4 DELEGATECALL`) | Yes (Intended upgradeability) | Yes | Require [7d Timelock](/protocols/timelockcontroller-multisig-quorum-emergency-guardian-veto) |
| Classic `CREATE2 + SELFDESTRUCT` | **No!** (Looks immutable!) | **NO** (`0xff` keeps code intact!) | **YES (Critical Rug!)** | Pin `target.codehash == EXPECTED_HASH` |
| External Config / Router Pointer | **No!** (Uses `CALL` to mutable addr) | **YES!** (Most common hidden rug!) | **YES!** | Audit **all** storage address setters! |
| Same-Tx Ephemeral `CREATE2 + 0xff` | N/A (0-byte persistent code) | **YES!** (Same-tx `0xff` still wipes!) | Yes | Never trust `extcodesize == 0`! |

![Effectiveness of static opcode scanning, EIP-6780 fork rules, and extcodehash pinning against hidden mutability](/api/figure?type=bars&title=Hidden%20Contract%20Mutability%20Vectors%20%26%20Audit%20Coverage&subtitle=Detection%20and%20prevention%20across%20metamorphic%20factories%2C%20same-tx%20transient%20contracts%2C%20and%20mutable%20pointers&steps=Pre-Cancun%20Metamorphic%3A%3AWiped%20code%20%26%20reset%20nonce%20across%20blocks%20-%3E%20Blocked%20100%25%20by%20EIP-6780!%7CSame-Tx%20Deploy%20%2B%200xff%3A%3AStill%20wipes%20code%20in%20same%20tx%20on%20Cancun%20-%3E%20Bypasses%20extcodesize%20%3D%3D%200!%7CForce-Fed%20ETH%20via%200xff%3A%3AStill%20bypasses%20receive%28%29%2Ffallback%28%29%20-%3E%20Never%20use%20%3D%3D%20on%20.balance!%7Cextcodehash%20DAO%20Pinning%3A%3A400-gas%20warm%20check%20guarantees%20exact%20proposal%2Fhook%20bytecode%20at%20run!&metrics=EXTCODEHASH%20GAS%3A%3A100%20-%202%2C600%20Gas%3A%3AEIP-1052%2032-byte%20keccak256%20of%20runtime%7CSAFE%20SALT%20FORMULA%3A%3Akeccak%28sender%2C%20args%29%3A%3ABlocks%20CREATE2%20frontrun%20hijacking%7CEMPTY%20ACCOUNT%20HASH%3A%3A0x0%20%28Zero%29%3A%3Avs%200xc5d246...%20for%20deployed%200-byte%20code%7CHOOK%20ADDRESS%20MINING%3A%3Av4%20Permission%20Bits%3A%3ACREATE2%20salt%20encodes%20Uniswap%20v4%20flags)

## Safe `CREATE2` Salt Derivation & Proposal `extcodehash` Pinning Formula

Both Uniswap v4 Hook deployers (`who mine CREATE2 salts so leading address bits match hook permission flags`) and DAO Governor executors enforce two mathematical guarantees:

```formula
1) Frontrun-Proof CREATE2 Salt Derivation (Binds Caller & Initialization State):
 Safe_Salt = keccak256(abi.encode(msg.sender, chainSpecificConfigHash, userVanityNonce))
 Deploy_Addr = address(uint160(uint256(keccak256(concat(0xff, address(factory), Safe_Salt, keccak256(init_code))))))
 // Because msg.sender & configHash sit inside Safe_Salt, no mempool bot can deploy at Deploy_Addr with altered admin args!

2) DAO Governor Proposal Bytecode Pinning (Blocks Tornado-DAO Style Code Swaps on ANY Chain):
 At Proposal Snapshot Time t_propose:
 Recorded_CodeHash[proposalId] = targetContract.codehash [EIP-1052 EXTCODEHASH opcode]
 At Timelock Execution Time t_exec = t_propose + 7 days:
 require(targetContract.codehash == Recorded_CodeHash[proposalId] && Recorded_CodeHash != 0x0, "BytecodeMutated!")
```

## Completing Proxy Upgrade Safety With EIP-7201 Namespaces

When protocols legitimately *do* need upgradeability rather than immutable `CREATE2` ossification, how do OpenZeppelin v5 contracts guarantee zero storage-slot collisions across multi-inheritance upgrade trees without fragile `__gap` arrays? Conclude Silo 3 next in [EIP-7201 namespaced storage layouts](/protocols/eip-7201-namespaced-storage-layout-audit-upgrade-safety) and [ERC-1967 vs UUPS proxies](/protocols/erc-1967-transparent-vs-eip-1822-uups-proxy-storage-slots) inside our [EIP-712, Permit2 & Proxy Security hub](/topics/erc721-erc1155-eip712-permit-security).

## Frequently asked questions

### How did the Tornado Cash DAO attacker change a verified contract that had no proxy?

The proposal contract and its parent deployer contained SELFDESTRUCT behind an emergency function; destroying both reset the intermediate CREATE deployer nonce so the attacker redeployed malicious code at the exact approved address.

### Are CREATE2 metamorphic rug pulls still possible on Ethereum Mainnet after Dencun (EIP-6780)?

No for already-deployed contracts: EIP-6780 changed SELFDESTRUCT so calling it in a later block only sweeps ETH without deleting bytecode or resetting nonces—though auditors must still check EIP-6780 activation on non-Ethereum alt-EVMs!

### Can EIP-6780 SELFDESTRUCT still bypass extcodesize == 0 checks?

Yes! EIP-6780 preserves legacy deletion behavior when a contract is created AND self-destructed within the exact same transaction, during which its constructor also has extcodesize == 0.

### Why do Uniswap v4 Hooks rely heavily on CREATE2 salt mining?

Uniswap v4 PoolManager encodes which hook callbacks are active (beforeSwap, afterSwap, etc.) directly inside the top 14 bits of the hook contract 20-byte address, requiring CREATE2 salt mining.


## Source URLs

- https://eips.ethereum.org/EIPS/eip-1014
- https://eips.ethereum.org/EIPS/eip-6780
- https://eips.ethereum.org/EIPS/eip-1052

## Citation

- APA: Dr. Devon Kurosawa, PhD. (2026). CREATE2 Metamorphic Contracts, Cancun EIP-6780 SELFDESTRUCT & Bytecode Provenance Audits. NFTVenue Ledger. https://nftvenueledger.com/protocols/create2-metamorphic-contract-redeployment-rug-detection
- Canonical article: [CREATE2 Metamorphic Contracts, Cancun EIP-6780 SELFDESTRUCT & Bytecode Provenance Audits](https://nftvenueledger.com/protocols/create2-metamorphic-contract-redeployment-rug-detection)
- Site research index: [NFTVenue Ledger](https://nftvenueledger.com/llms-full.txt)
