MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.93k stars 4.88k forks source link

[Bug]: Signatures - MetaMask breaks with error `msg.map is not a function` when passing an invalid type #22525

Open seaona opened 8 months ago

seaona commented 8 months ago

Describe the bug

Problem: whenever I trigger a signature message containing an invalid type definition, MetaMask breaks with the error msg.map is not a function

Expected behavior

No response

Screenshots/Recordings

Screenshot from 2024-01-12 12-49-43

https://github.com/MetaMask/metamask-extension/assets/54408225/4d372ca6-ede3-4a40-a055-6ea9163d54e4

Steps to reproduce

  1. Download test dapp project locally
  2. Change the signTypedDataV4.onclick function for this

    signTypedDataV4.onclick = async () => {
    const msgParams = {
      primaryType: 'OrderComponents',
      domain: {
          chainId: chainIdInt,
          name: 'Seaport',
          version: '1.5',
          verifyingContract: '0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC',
      },
      types: {
          EIP712Domain: [
          { name: 'name', type: 'string' },
          { name: 'version', type: 'string' },
          { name: 'chainId', type: 'uint256' },
          { name: 'verifyingContract', type: 'address' },
          ],
          OrderComponents: [
              { name: 'consideration', type: 'ConsiderationItem[+' },
          ],
    
      },
      message: {
          consideration: [
              {
                  itemType: '0',
                  token: '0x0000000000000000000000000000000000000000',
                  identifierOrCriteria: '0',
                  startAmount: '1950000000000000',
                  endAmount: '1950000000000000',
                  recipient: '0x0000000000000000000000000000000000000000',
              },
          ],
    
      }
    }
    try {
      const from = accounts[0];
      const sign = await provider.request({
        method: 'eth_signTypedData_v4',
        params: [from, JSON.stringify(msgParams)],
      });
      signTypedDataV4Result.innerHTML = sign;
      signTypedDataV4Verify.disabled = false;
    } catch (err) {
      console.error(err);
      signTypedDataV4Result.innerHTML = `Error: ${err.message}`;
    }
    };
  3. Run the test dapp yarn start
  4. Trigger the Sign Type 4 Signature from the test dapp
  5. See MM breaks with error

Error messages or log output

No response

Version

seen in 11.7.3 but possibly older too

Build type

None

Browser

Chrome

Operating system

Linux

Hardware wallet

No response

Additional context

No response

Severity

No response

matthewwalsh0 commented 6 months ago

This appears to be failing in the UI when parsing the payload for rendering, hence adding the confirmations UX team.

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days if there is no further activity. The MetaMask team intends on reviewing this issue before close, and removing the stale label if it is still a bug. We welcome new comments on this issue. We do not intend on closing issues if they report bugs that are still reproducible. Thank you for your contributions.

sleepytanya commented 1 month ago

Present in v12.0.5:

https://github.com/user-attachments/assets/b1745548-2d81-4231-a419-c2d878596478