New multiOverflow Bug Identified in Multiple ERC20 Smart Contracts (CVE-2018-10706)
Our vulnerability-scanning system at PeckShield has so far discovered several dangerous smart contract vulnerabilities ( batchOverflow, proxyOverflow, transferFlaw, ownerAnyone). Some of them could be used by attackers to generate tokens out of nowhere while others can be used to steal tokens from legitimate holders. Today, we would like to report another vulnerability named multiOverflow that afflicts dozens of ERC20-based smart contracts. Our investigation shows that multiOverflow is another integer overflow bug which is similar tobatchOverflow but with its own characteristics.
Details
Integer overflow has been one of most common root causes of vulnerabilities in smart contracts. The multiOverflow bug also falls in this category.
We show in Figure 1 the vulnerable function, i.e., transferMulti(). This function takes two parameters: an address array, _to, for naming receivers and an uint256 array, _value, for holding the amount transferring to each receiver. In line 250, we notice that amount is calculated by adding the product of _value and 10 to the power of decimal (set as 8 in the contract constructor). Obviously, this could be an integer overflow case because the sanity check in line 252 can be easily bypassed. To demonstrate, we craft a proof-of-concept with following parameters:
- _to
- 0x93995bc9db9ae7af4f969400012c6fe94c93f761
- 0x0c2a5f9a88bf2467f0b90e80e263e6c25daed62d
- _value
- 0x15798ee2308c39df9fb841a566d74f87a7a9a7aeb02c2d2f8e0d1e768e
- 0x15798ee2308c39df9fb841a566d74f87a7a9a7aeb02c2d2f8e0d1e768e
Since there’re two receivers, the loop in line 249-251 would be iterated twice. The execution proceeds as follows:
Iteration 1
amount += _value[0]*10**uint256(decimals);
==> amount += 0x15798ee2308c39df9fb841a566d74f87a7a9a7aeb02c2d2f8e0d1e768e * 100,000,000 (line 250)
Iteration 2
amount += _value[1]*10**uint256(decimals);
==> amount += 0x15798ee2308c39df9fb841a566d74f87a7a9a7aeb02c2d2f8e0d1e768e * 100,000,000 (line 250)
Now, amount is overflowed successfully to0x10000000000000000000000000000000000000000000000000000000004319c00 which equals to 0x4319c00 in uint256 format.
As long as the attacker has enough tokens, i.e., balanceOf[msg.sender] >= 0x4319c00, each receiver will receive a tremendous number of tokens —0x800000000000000000000000000000000000000000000000000000000218ce00.
The following figure demonstrates a successful attack which proves our theory:
Affected Tokens
The multiOverflow bug is of the same nature of other integer overflow vulnerabilities (e.g.,batchOverflow and proxyOverflow) and could cause similar damages. When analyzing deployed smart contracts, we find a few are affected. A particular example token is SCA, which is deployed by SocialChain (a blockchain startup focusing on entertainment and leisure industries). SCA is currently in the pre-sale stage, which means a successfulmultiOverflow attack can wreak havoc and cause serious financial loss to the company.
Upon the detection, we immediately contacted SocialChain and provided them with vulnerability details and necessary technical supports. The SCA team promptly responded to our notification and took actions to fix the problem actively. As of the time publishing this blog, a new smart contract with the multiOverflow bug fixed has been deployed while all addresses holding SCA tokens have been mapped to the new contract successfully. We applaud the team’s reaction and believe this is what a high-quality development team should behave!
Conclusion
As cryptocurrency is getting acceptable to the public, a popular way for entrepreneurs to raise funds is to issue tokens. Compare to prosperity of various tokens, security in blockchain is still at a primitive stage. As indicated in recent discovery of various smart contract vulnerabilities, very few (token-issuing) teams have taken the security into serious consideration before deploying their smart contracts.
We believe security is essential in any blockchain-based smart contracts and any token-related businesses (including ICOs and live DAPPs). Ealier vulnerabilities such asbatchOverflow and proxyOverflow have demonstrated how devastating they could be once exploited by attackers. Regarding the SocialChain case, it’s fortunate that we are ahead by identifying and fixing the bug before any multiOverflow attack, thus successfully preventing possible damage or financial loss. But always keep in mind, attackers are out there, lurking in the shadows and seeking for another chance. This would be an endless arms race!
相關文章
- New burnOverflow Bug Identified in Multiple ERC20 Smart Contracts (CVE-2018-11239)IDE
- New evilReflex Bug Identified in Multiple ERC20 Smart Contracts (CVE-2018-12702, CVE-2018-12703)FlexIDE
- New allowAnyone Bug Identified in Multiple ERC20 Smart Contracts (CVE-2018-11397, CVE-2018-11398)IDE
- New ceoAnyone Bug Identified in Multiple Crypto Game Smart Contracts (CVE-2018-11329)IDEGAM
- New proxyOverflow Bug in Multiple ERC20 Smart Contracts (CVE-2018-10376)
- ALERT: New batchOverflow Bug in Multiple ERC20 Smart Contracts (CVE-2018-10299)BAT
- New ownerAnyone Bug Allows For Anyone to ''Own'' Certain ERC20-Based Smart Contracts (CVE-2018-10705AI
- CVE-2018-10944: Vulnerability of ROC(aka Rasputin Online Coin) smart contract (Ethereum ERC20 token)
- SMART goals - SMART objectivesGoObject
- Bug 12725963 - New database connection fails with ORA-12541 after vip failoverDatabaseAI
- [BUG反饋]onethink 登陸時呼叫$User = new UserApi; 報錯。API
- openzeppelin/contracts/utils/Counters.sol" not found
- ERC20介紹
- JavaScript select multipleJavaScript
- Logstash Multiple Pipelines
- Smart Industry Operations
- Small Multiple(最短路)
- 2.3.6.2 Synchronization of Multiple ApplicationsAPP
- LLM multiple modal applicationsAPP
- kubernetes traefik multiple namespacesnamespace
- Laravel 原始碼閱讀指南 -- Contracts 契約Laravel原始碼
- new self()與new static()
- GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root‘ WITH GRANT OPTION;報錯IDE
- The phenomenon of smart contract honeypots
- Multiple Books多賬薄
- POJ1426-Find The Multiple
- New
- Mysql8.0不支援grant all privileges on *.* to root@“%“ identified by “.“;MySqlIDE
- 重構smart-importImport
- Slither: A Static Analysis Framework For SmartFramework
- Smart Value Help 總結
- onClick事件中點選跳轉新的activity提示FLAG_ACTIVITY_NEW_TASK的奇怪bug事件
- JavaScript中的new map()和new set()使用詳細(new map()和new set()的區別)JavaScript
- Lowest Common Multiple Plus hd 2028
- 理解new和實現一個new
- 【區塊鏈100問】ERC20代幣那麼火爆, 那麼ERC20到底是什麼?區塊鏈
- new learn
- a new ideaIdea