Skip to content
Business logic Audit finding Intermediate

The unwrapETH2LD use transferFrom instead of safeTransferFrom to transfer ERC721 token

The unwrapETH2LD function uses transferFrom instead of safeTransferFrom to transfer an ERC721 token to a new registrant. If the new registrant is a contract that cannot handle ERC721 tokens, the token could become locked.

0x29A Follow

Originally disclosed on Code4rena

Submitted by 0x29A, also found by Amithuddar, benbaessler, berndartmueller, cccz, CRYP70, rbserver, RedOneN, and Sm4rty

NameWrapper.sol#L327-L346

The unwrapETH2LD use transferFrom to transfer ERC721 token, the newRegistrant could be an unprepared contract.

Proof of Concept

Should a ERC-721 compatible token be transferred to an unprepared contract, it would end up being locked up there. Moreover, if a contract explicitly wanted to reject ERC-721 safeTransfers. Plus take a look to the OZ safeTransfer comments: Usage of this method is discouraged, use safeTransferFrom whenever possible.

Recommended Mitigation Steps

    function unwrapETH2LD(
        bytes32 labelhash,
        address newRegistrant,
        address newController
    ) public override onlyTokenOwner(_makeNode(ETH_NODE, labelhash)) {
        _unwrap(_makeNode(ETH_NODE, labelhash), newController);
-       registrar.transferFrom(
+       registrar.safeTransferFrom(
            address(this),
            newRegistrant,
            uint256(labelhash)
        );
    }

jefflau (ENS) disputed and commented:

Transfer is to the contract itself, so there is no point in using safeTransferFrom. For other situations where transferFrom the behaviour is intended.

LSDan (judge) commented:

Transfer is to the contract itself, so there is no point in using safeTransferFrom. For other situations where transferFrom the behaviour is intended.

That’s incorrect in the report above. This is transferring from, not to, the contract itself.

jefflau (ENS) commented:

That’s incorrect in the report above. This is transferring from, not to, the contract itself.

Yes sorry, that is true. I was replying to some of the duplicates that I closed such as: #126, #147.


The original report as published on Code4rena, by 0x29A. 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 the function used transferFrom instead of safeTransferFrom, which skips checking whether the recipient contract can handle ERC721 tokens.

Impact

If the new registrant is a contract that cannot handle ERC721 tokens, the token could be locked and unrecoverable.

What the attacker needed

NewRegistrant is a contract; contract cannot handle ERC721 tokens

The fix

The function should use safeTransferFrom instead of transferFrom.

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.

When a contract sends an NFT (a unique digital token) to another contract, it should use a safe transfer method that checks the receiver can handle NFTs. This report says the code used a basic transfer method, so if the receiver is a contract that cannot handle NFTs, the token might get stuck there forever.

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.

More by 0x29A

View all

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

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.