NameWrapper: Cannot prevent transfer while upgrade even with CANNOT_TRANSFER fuse regardless of the upgraded NameWrapper’s implementation
The NameWrapper contract's upgrade functions burn the node before calling the new contract, losing the old owner information. This allows a user to transfer a name to a new owner during upgrade even if the CANNOT_TRANSFER fuse is burned, bypassing the transfer restriction.
Upon upgrade to a new NameWrapper contract, owner of the node will be set to the given wrappedOwner. Since the node will be _burned before calling the upgraded NameWrapper, the upgraded NameWrapper cannot check the old owner. Therefore, no matter the upgraded NameWrapper’s implementation, it locks the information to check whether the old owner and newly given wrappedOwner are the same. If they are not the same, it means basically transferring the name to a new address.
In the case of resolver, the upgraded NameWrapper can check the old resolver by querying to the ENS registry, and prevent changing it if CANNOT_SET_RESOLVER fuse is burned.
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.
The proof of concept below demonstrates upgrade process.
Even if the CANNOT_TRANSFER fuse is in effect, the user1 can call upgradeETH2LD with a new owner.
Before the NameWrapper.upgradeETH2LD calls the new upgraded NameWrapper upgradeContract, it calls _prepareUpgrade, which burns the node in question. It means, the current NameWrapper.ownerOf(node) will be zero.
The upgraded NameWrapper has only the given wrappedOwner which is supplied by the user, which does not guarantee to be the old owner (as the proof of concept above shows). As the ens registry and ETH registrar also do not have any information about the old owner, the upgraded NameWrapper should probably set the owner of the node to the given wrappedOwner, even if CANNOT_TRANSFER fuse is in effect.
On contrary to the owner, although resolver is given by the user on the NameWrapper.upgradeETH2LD function, it is possible to prevent changing it if the CANNOT_SET_RESOLVER fuse is burned, by querying to ENSRegistry.
In the case of resolver, the upgraded NameWrapper can check the old resolver by querying to the ENS registry, and prevent changing it if CANNOTSETRESOLVER fuse is burned.
For this specific case, the public resolver checks for the owner on the NameWrapper. If the NameWrapper needed to be upgraded for any reason, the old resolver would be checking the old NameWrapper, and since the owner would be burnt, they would lock all records. So for this case I think it’s reasonable to allow CANNOT_SET_RESOLVER to be bypassed in this specific case.
From further testing, it seems like upgrading will ignore the value provided, here the changed POC
I think this test is incorrect, you should be checking the new NameWrapper, not the old NameWrapper. I believe this would pass:
@jefflau - Took me a while but I have to agree with you, querying ownerOf on the nameWrapperUpgrade will return the new owner.
I wrote a Bodge to make it work, but would like to flag that the function wrapETH2LD uses different parameters, and also the size of fuses is changed (uint32 vs uint16).
Am assuming the upgradedWrapper will have a check for the old wrapper being the caller
The code changes I made to verify the finding: here.
Per the discussion above, the Warden has shown how, despite burning the fuse to prevent transfers, due to the implementation of NameWrapper, a node can still be transferred during an upgrade.
I believe that, technically this can be prevented by changing the implementation of the upgraded NameWrapper, and because it’s reliant on that implementation, I agree with Medium Severity.
Performing a check for ownership on the old wrapper, I believe, should offer sufficient mitigation.
Fixed.
The owner value is now derived from getData function which retrieves the current node owner. If it does not matches the assigned owner then CANNOT_TRANSFER fuse is always checked (non expired scenario)
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 40 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
Impact
A user could transfer a name that was supposed to be non-transferable, bypassing the CANNOT_TRANSFER fuse, but this depends on the upgraded NameWrapper's implementation.
What the attacker needed
A wrapped name with CANNOT_TRANSFER fuse burned; the NameWrapper contract has an upgrade contract set; the user is the owner of the name
The fix
The fix was to derive the current owner from getData and check if the new owner differs, then enforce the CANNOT_TRANSFER fuse.
How it was found
Wrap a name and burn all fuses, including CANNOT_TRANSFER.
Set the upgrade contract to a new NameWrapper implementation.
Call upgradeETH2LD with a new owner address.
Observe that the name is transferred to the new owner 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 40 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
A fuse is a flag that locks certain actions on a name, like preventing transfers. The upgrade process moves a name to a new contract, but it deletes the old ownership record first, so the new contract cannot check if the new owner is the same as the old one. This means someone can change the owner during upgrade even when transfers are supposed to be blocked.
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.
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.