Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The unwrapETH2LD use transferFrom instead of safeTransferFrom to transfer ERC721 token #157

Open
code423n4 opened this issue Jul 19, 2022 · 3 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/wrapper/NameWrapper.sol#L327-L346

Vulnerability details

Impact

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.

Tools Used

Manual Review

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)
        );
    }
@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Jul 19, 2022
code423n4 added a commit that referenced this issue Jul 19, 2022
@jefflau jefflau added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue and removed disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) labels Jul 27, 2022
@jefflau
Copy link
Collaborator

jefflau commented Jul 27, 2022

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

@dmvt
Copy link
Collaborator

dmvt commented Aug 3, 2022

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
Copy link
Collaborator

jefflau commented Aug 3, 2022

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

@jefflau jefflau added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

3 participants