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

Metamask Mishandles ENS ERC-721 Transfer, Submits Wrong Token ID #4092

Closed
kylebakerio opened this issue Apr 12, 2022 · 3 comments
Closed

Metamask Mishandles ENS ERC-721 Transfer, Submits Wrong Token ID #4092

kylebakerio opened this issue Apr 12, 2022 · 3 comments
Labels
Sev2-normal An issue that may lead to users misunderstanding some limited risks they are taking type-bug Something isn't working

Comments

@kylebakerio
Copy link

kylebakerio commented Apr 12, 2022

Describe the bug
Attempting to transfer my ENS domain name (kyle3.eth) from one wallet to another, using Metamask Mobile's built-in ERC-721 transfer functionality, fails.

  1. First, it just gives a cryptic "intrinsic gas too low" error. (This is almost certainly because the transaction being simulated is with faulty parameters, as we'll see later.)
  2. Corrected the gas limit manually by looking up how much gas should be allocated for an ERC-721 transfer on etherscan (84904, rounded to 85000) (see here).
  3. Then, transaction fails. (Transaction here)
  4. Looking up transaction on tenderly shows that it fails at the check for the token to not be expired, within ownerOf()
    function ownerOf(uint256 tokenId) public view returns (address) {
        require(expiries[tokenId] > now);
        return super.ownerOf(tokenId);
    }
  1. Looking at the state in that transaction within tenderly, I can see that the from and to arguments are correct, but the tokenId argument appears to be wrong. Thus, the failure is because the (presumably nonexistent) token does not have a valid expiration.

Actual Token ID according to etherscan is:
67389638965262593448462623680994207765963563118284578216830450145622015809311
(This also validates, if I look up the ownerOf for this one on the ENS contract for it, I get my address)

Token ID in the transaction (therefore, injected/generated by metamask mobile app) according to tenderly is:
67389638965262590220318309333039877597547483020474590898904772124586079682560
(Again, validating by checking ownerOf reverts for this one)

Seems like a precision error, perhaps? They're both the same as of 6738963896526259 but then diverge after that number, while being the same length.

Looking on Etherscan to confirm, we see that argument 3 in the failed transaction is
94fd2f196cf1f800000000000000000000000000000000000000000000000000
which, when put through a hex->decimal converter, is:
67389638965262590220318309333039877597547483020474590898904772124586079682560
which matches what we see on tenderly

What is especially frustrating is I added my account to Metamask Mobile only because the chrome extension cannot handle NFT transfers but the docs inform that the mobile app can / should be used for that feature.

I'll just be doing it manually using etherscan and specifying the arguments manually, it seems.

Note: I'm sure the "intrinsic gas error" message is because Metamask Mobile predicted the transaction would fail. Better error messaging would be helpful.

Screenshots
N/A

To Reproduce
Should be clear enough from above; if not, let me know, will expand

Expected behavior
Should be clear

Smartphone (please complete the following information):

  • Device: OnePlus 9
  • OS: Oxygen OS, fully updated, Android 12, security update March 5, 2022
  • App Version: 4.3.1 (859)

to be added after bug submission by internal support / PM
Severity

  • How critical is the impact of this bug on a user?
  • Add stats if available on % of customers impacted
  • Is this visible to all users?
  • Is this tech debt?
@kylebakerio kylebakerio added the type-bug Something isn't working label Apr 12, 2022
@tommasini tommasini added the needs-triage Issues that require triage label Apr 19, 2022
@gantunesr gantunesr added Sev2-normal An issue that may lead to users misunderstanding some limited risks they are taking and removed needs-triage Issues that require triage labels Apr 26, 2022
@Fatxx Fatxx self-assigned this May 3, 2022
@Fatxx Fatxx removed their assignment Jul 19, 2022
@Fatxx
Copy link
Contributor

Fatxx commented Jul 26, 2022

Check if it's related with #4636

@wdv4758h
Copy link
Contributor

Check if it's related with #4636

This seems to be related to the PR I sent. I was indeed having problem when doing NFT transfer due to Token ID is mis-converted.

I spent time digging the reason about MetaMask NFT transfer failure, while at the same time transfer via my other script are just fine. And then I found out the token id in transaction is wrong. So I search the code related to NFT transfer and find out a token id conversion issue if the token id is big.

@Fatxx
Copy link
Contributor

Fatxx commented Jul 27, 2022

@kylebakerio @wdv4758h

This issue is fixed with #4636 check testing at #4636 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sev2-normal An issue that may lead to users misunderstanding some limited risks they are taking type-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants