Get 40% Off
🚨 Volatile Markets? Find Hidden Gems for Serious Outperformance
Find Stocks Now

OKEx Halts ERC20 Trading After Finding Bug Affecting Majority of Tokens

Published 04/25/2018, 03:50 PM
Updated 04/25/2018, 04:01 PM
 OKEx Halts ERC20 Trading After Finding Bug Affecting Majority of Tokens

OKEx, the third-largest exchange in the world by trade volume, just suspended ERC20 activity due to a vulnerability they are calling BatchOverFlow.

“We are suspending the deposits of all ERC-20 tokens due to the discovery of a new smart contract bug—’BatchOverFlow’. By exploiting the bug, attackers can generate an extremely large amount of tokens, and deposit them into a normal address. This makes many of the ERC-20 tokens vulnerable to price manipulations of the attackers,” the company wrote in its support announcements.

The specific problem with ERC20 is that it doesn’t return any errors when integers are overloaded. It just keeps running the code. This may allow hackers to “overload” the integer to a point that it creates what is known in the programming community as an “overflow.”

[telegram-banner]

Reverse-engineering an attack

BeautyChain was among the first to fall victim to such an attack on Sunday, when attackers generated 10^58 (that’s a one with 58 zeros after it) BEC tokens by taking advantage of an integer overflow vulnerability in the “batchTransfer()” function of its smart contract code.

“At 13:18 on April 22, 2018, BEC’s prices fluctuate [sic] significantly due to the smart contract safety issue on the BEC. After the study by the Beauty Chain Foundation, the Beauty Chain has suspended all transactions and transfers,” the organization’s site currently reads.

By looking at the smart contract code, we can spot the “batchTransfer()” function and find that it passes three arguments, including one called “_value”, representing the quantity of tokens that should be sent to an array of addresses which is passed into the function as “_receivers”.

3rd party Ad. Not an offer or recommendation by Investing.com. See disclosure here or remove ads .

The “_value” integer is the problem here. The hackers could just pass a “_value” with an astronomically huge number and the function will cave in without performing the checks it should. By defaulting to zero, the conditional “require()” later in the code doesn’t do its job and the platform sends the impossibly enormous amount of tokens to the hackers.

Beauty Chain’s announcement of suspension made its BEC token lose half its value despite the fact that the team managed to pause the smart contract before the hackers could cash out their tokens. The startup promised that it would work on launching a patched contract in the near future.

The dangers of copycatting

OKEx used the word “many” to describe the proportion of ERC20 tokens affected by this bug for a reason. There are a lot of them using smart contracts with this particular batch function.

When code is standardized and copied from one smart contract to the next instead of written from scratch, the lack of diversity exposes the weaknesses in the collective ecosystem. To prevent these sorts of situations, ERC20 smart contracts should be written without using code generators. And for that, one would need the resources to hire skilled coders.

For now, OKEx said that it has the situation under control and has “contacted the affected token teams to conduct an investigation and take necessary measures to prevent the attack.” However, it’s important to note that smart contracts are not infallible and companies should do their best to audit their code, perhaps even involving bug bounties to ensure that they get the most talented individuals possible to hunt for potential vulnerabilities.

3rd party Ad. Not an offer or recommendation by Investing.com. See disclosure here or remove ads .

This article appeared first on Cryptovest

Latest comments

Risk Disclosure: Trading in financial instruments and/or cryptocurrencies involves high risks including the risk of losing some, or all, of your investment amount, and may not be suitable for all investors. Prices of cryptocurrencies are extremely volatile and may be affected by external factors such as financial, regulatory or political events. Trading on margin increases the financial risks.
Before deciding to trade in financial instrument or cryptocurrencies you should be fully informed of the risks and costs associated with trading the financial markets, carefully consider your investment objectives, level of experience, and risk appetite, and seek professional advice where needed.
Fusion Media would like to remind you that the data contained in this website is not necessarily real-time nor accurate. The data and prices on the website are not necessarily provided by any market or exchange, but may be provided by market makers, and so prices may not be accurate and may differ from the actual price at any given market, meaning prices are indicative and not appropriate for trading purposes. Fusion Media and any provider of the data contained in this website will not accept liability for any loss or damage as a result of your trading, or your reliance on the information contained within this website.
It is prohibited to use, store, reproduce, display, modify, transmit or distribute the data contained in this website without the explicit prior written permission of Fusion Media and/or the data provider. All intellectual property rights are reserved by the providers and/or the exchange providing the data contained in this website.
Fusion Media may be compensated by the advertisers that appear on the website, based on your interaction with the advertisements or advertisers.
© 2007-2024 - Fusion Media Limited. All Rights Reserved.