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.
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
- This sub-domain should not burn
-
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.ethideally
- The hacker should not be able to change the owner and the fuses of
-
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_UNWRAPwhich thus letsexpirydecide 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.
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
- The domain owner assigns a sub-domain to the hacker, which can burn PARENT_CANNOT_CONTROL but not CANNOT_UNWRAP.
- The hacker assigns a sub-sub-domain to a victim user.
- The victim user burns arbitrary fuses, including PARENT_CANNOT_CONTROL.
- The hacker unwraps his sub-domain.
- The hacker invokes ENSRegistry::setSubnodeOwner on the sub-sub-domain to reassign himself as owner.
- 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.