metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

Warning not being shown when sending tokens to a known token contract address

Open danjm opened this issue 5 years ago • 3 comments

In ducks/send/send.js we have code that is meant to show a warning to users when they are sending to a known contract address:

if (
          isSendingToken &&
          isValidHexAddress(recipient.userInput) &&
          (tokenAddressList.find((address) =>
            isEqualCaseInsensitive(address, recipient.userInput),
          ) ||
            checkExistingAddresses(recipient.userInput, tokens))
        ) {
          recipient.warning = KNOWN_RECIPIENT_ADDRESS_WARNING;
        } else {
          recipient.warning = null;
 }

This recipient.warning property is read in renderDialogs of ui/pages/send/send-content/add-recipient/add-recipient.component.js

Currently, if I try to send DAI token to the DAI contract, no warning is shown.

Acceptance criteria:

  • if a known token contract address is entered in the recipient field in the send flow, a warning should be shown to the user
  • this warning can just be the <Dialog type="warning" className="send__error-dialog"> that add-recipient.component.js is currently meant to render
  • "known token contract addresses" include any of the addresses in this list: https://github.com/MetaMask/contract-metadata/blob/master/contract-map.json

danjm avatar Nov 10 '21 11:11 danjm

AC:

  • Implement the warning message on choosing existing account
  • Remove "New address detected ..." when this specific warning is shown

EHaracic avatar Nov 16 '21 12:11 EHaracic

Solving this shouldn't be top priority? I mean it like an honest assessment, it's an easy to fix issue that involves avoiding the lose of tokens.

Gahen avatar Jan 26 '22 01:01 Gahen

I agree, I don't know why this was marked sev2. This is a low hanging fix for an easy cause of fund loss.

I didn't realize this had regressed until I saw this prominent example of it in the wild: https://twitter.com/0xfoobar/status/1538000663988228101?s=20&t=w9V_AQgNE5XBHl3nNMS90w

danfinlay avatar Jun 18 '22 04:06 danfinlay