Skip to content
Business logic Disclosed report Advanced

Bypass parsing of transaction data, users on the phishing site will transfer/approve ERC20 tokens without being alerted

MetaMask failed to parse ERC20 transaction calldata for contracts compiled with solc below 0.5.0 when two bytes were removed, showing a generic contract call instead of recipient, amount and token, letting a phishing site induce transfers or approvals without showing the amount.

ronnyx2017 Follow

Originally disclosed on HackerOne

Bounty$1,000 Low 3.3 View original
  • Triaged in 6 days
  • Fixed in 7 months
  • Paid in 7 days
  • Disclosed after 8 months

Summary by the program

@ronnyx2017 discovered an issue that prevented MetaMask from presenting informational UI elements regarding the message the user was signing. This occurred when interfacing with smart contracts compiled using solc < 0.5.0 by removing two bytes from the call data. We would like to thank @ronnyx2017 for the detailed report, and bring this to our attention ultimately making MetaMask more secure.

The report

Summary:

There are still a lot of valuable erc20 tokens compiled with solc < 0.5.0 on the eth mainnet. The methods compiled with Solc below 0.5.0 will not check if the length of the input calldata matches the params types. It will load the calldata as long as the params types need, regardless of the actual input length. And the insufficient parts will be read as byte(00).

Metamask can't parse these unusual length transaction data like normal. For example, delete the last byte of the input data:

A normal transfer call data:

sighash ->          0xa9059cbb
address to ->       000000000000000000000000C588e338FdBB2CC523a1177f3D18e87FF5A16a6b
uint256 value ->    0000000000000000000000000000000000000000000000000000000000989700  ->  10000128

Evil call data:

sighash ->          0xa9059cbb
address to ->       000000000000000000000000C588e338FdBB2CC523a1177f3D18e87FF5A16a6b
uint256 value ->    00000000000000000000000000000000000000000000000000000000009897  

When users connect to a phishing site, attack can trigger a token transfer or approve transaction without alerting users to the token amount.

Steps To Reproduce:

I fork the metamask test dapp repo as a exp demo. (Attachment on the original report: dist.tar.gz)

  1. cd in the dist, and setup a http server, for example run static-server . -z --port 9011.
  2. open in the browser and connect with metamask ext at the Rinkeby network.
  3. Click the button Create Token will deploy a erc20 token with compiler solc 0.4.26.

contract source code: (Attachment on the original report: TokenERC20_pure.sol)

token.png
token.png From the original on HackerOne
  1. After contract deploying, click Transfer Tokens, metamask will show its a normal contract call without showing send to address, send amount and token symbol.
transfer.png
transfer.png From the original on HackerOne

transfer send data hex:

transfer_hex.png
transfer_hex.png From the original on HackerOne

Transfer event log:

event.png
event.png From the original on HackerOne
  1. Click Approve Tokens, lack of prompt like transfer.
approve.png
approve.png From the original on HackerOne

Impact

The attacker can induce the victims to send/approve any number of tokens without knowing it.

Attachments

18.png
18.png From the original on HackerOne

The original report as published on HackerOne, by ronnyx2017. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 wallet's calldata parser rejected or failed to interpret truncated argument data that older solc-compiled contracts still accept by zero-padding, so it fell back to a generic contract-call display.

Impact

An attacker could induce victims to send or approve any number of tokens without them knowing, though this only affects contracts compiled with solc below 0.5.0.

What the attacker needed

Victim uses MetaMask; victim visits a phishing site; token compiled with solc < 0.5.0

The fix

The report was acknowledged and credited as making MetaMask more secure; the text does not state a specific fix.

How it was found

  1. Serve the forked MetaMask test dapp locally and open it in a browser connected to MetaMask on the Rinkeby network.
  2. Click Create Token to deploy an ERC20 token compiled with solc 0.4.26.
  3. Click Transfer Tokens and observe that MetaMask shows a normal contract call without the recipient, amount or token symbol.
  4. Click Approve Tokens and observe the same missing prompt.

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 you send a token transaction, your wallet reads the data attached to it and shows you what it means, such as who receives the tokens and how many. Older smart contracts accept data that is slightly too short and fill the missing part with zeros, but the wallet could not read that shortened data and showed nothing useful. A fake site could use this to make you approve or send tokens while your wallet displayed no amount.

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 ronnyx2017

View all

24 more disclosed reports, best first.

More from MetaMask

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.