Skip to content
Access control Audit finding Advanced

PARENT_CANNOT_CONTROL can be bypassed by maliciously unwrapping parent node

The PARENT_CANNOT_CONTROL fuse is meant to prevent a parent from changing a subdomain's owner or fuses, but a parent can bypass this by unwrapping itself and then re-wrapping the subdomain, thereby overwriting the subdomain's fuses and owner. An attacker who owns a parent domain can thus take control of a victim's subdomain even after the victim has burned PARENT_CANNOT_CONTROL.

PwnedNoMore Follow

Originally disclosed on Code4rena

Submitted by PwnedNoMore, also found by panprog, and zzzitron

NameWrapper.sol#L356 NameWrapper.sol#L295 ENSRegistry.sol#L74

By design, for any subdomain, as long as its PARENT_CANNOT_CONTROL fuse is burnt (and does not expire), its parent should not be able to burn its fuses or change its owner.

However, this contraint can be bypassed by a parent node maliciously unwrapping itself. As long as the hacker becomes the ENS owner of the parent node, he can leverage ENSRegistry::setSubnodeOwner to re-set himself as the ENS owner of the subdomain, and thus re-invoking NameWrapper.wrap can rewrite the fuses and wrapper owner of the given subdoamin.

Considering the following attack scenario:

  • Someone owns a domain (or a 2LD), e.g., poc.eth

  • The domain owner assigns a sub-domain to the hacker, e.g., hack.poc.eth

    • This sub-domain should not burn CANNOT_UNWRAP
    • This sub-domain can burn PARENT_CANNOT_CONTROL
  • Hacker assigns a sub-sub-domain to a victim user, e.g., victim.hack.poc.eth

  • The victim user burns arbitrary fuses, including PARENT_CANNOT_CONTROL

    • The hacker should not be able to change the owner and the fuses of victim.hack.poc.eth ideally
  • However, the hacker then unwraps his sub-domain, i.e., hack.poc.eth

  • The hacker invokes ENSRegistry::setSubnodeOwner(hacker.poc.eth, victim) on the sub-sub-domain

    • He can reassign himself as the owner of the victim.hack.poc.eth
  • The hacker invokes NameWrapper.wrap(victim.hacker.poc.eth) to over-write the fuses and owner of the sub-sub-domain, i.e., victim.hacker.poc.eth

The root cause here is that, for any node, when one of its subdomains burns PARENT_CANNOT_CONTROL, the node itself fails to burn CANNOT_UNWRAP. Theoretically, this should check to the root, which however is very gas-consuming.

Suggested Fix

  • Potential fix 1: auto-burn CANNOT_UNWRAP which thus lets expiry decide whether a node can be unwrapped.
  • Potential fix 2: leave fuses as is when unwrapping and re-wrapping, unless name expires. Meanwhile, check the old fuses even wrapping.

Proof of Concept / Attack Scenario

For full details, please see original warden submission.

Arachnid (ENS) confirmed


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

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, when a subdomain burns PARENT_CANNOT_CONTROL, the parent node does not also burn CANNOT_UNWRAP, so the parent can unwrap and re-wrap to reset the subdomain's fuses and owner.

Impact

A parent domain owner could change the owner and fuses of a subdomain that had burned PARENT_CANNOT_CONTROL, bypassing the intended protection.

What the attacker needed

Attacker owns a parent domain; attacker can assign a subdomain; victim burns PARENT_CANNOT_CONTROL

The fix

The report suggests either auto-burning CANNOT_UNWRAP when a subdomain burns PARENT_CANNOT_CONTROL, or preserving fuses when unwrapping and re-wrapping unless the name expires, and checking old fuses even when wrapping.

How it was found

  1. The domain owner assigns a sub-domain to the hacker, which can burn PARENT_CANNOT_CONTROL but not CANNOT_UNWRAP.
  2. The hacker assigns a sub-sub-domain to a victim user.
  3. The victim user burns arbitrary fuses, including PARENT_CANNOT_CONTROL.
  4. The hacker unwraps his sub-domain.
  5. The hacker invokes ENSRegistry::setSubnodeOwner on the sub-sub-domain to reassign himself as owner.
  6. The hacker invokes NameWrapper.wrap to overwrite the fuses and owner of the sub-sub-domain.

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.

In ENS, a name can be wrapped to add rules called fuses. One fuse, PARENT_CANNOT_CONTROL, is supposed to stop the parent from changing the name's owner or fuses. This report shows that a parent can still do so by first unwrapping itself and then re-wrapping the name, which resets those protections.

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 PwnedNoMore

View all

8 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.