New ownerAnyone Bug Allows For Anyone to ''Own'' Certain ERC20-Based Smart Contracts (CVE-2018-10705
This morning, our vulnerability-scanning system at PeckShield identified a new vulnerability namedownerAnyone in certain ERC20-based smart contracts such as AURA, which is deployed by a decentralized banking and finance platform – AURORA. This bug, if successfully exploited, might introduce the danger of serious financial accident. Fortunately, the attackers would not be financially benefited from exploiting the vulnerability. Instead, the ownerAnyone bug can be used to trigger Denial-of-Service (DoS) attack on the affected smart contracts.
Details
Solidity provides function modifiers, which can be used to amend the semantics of functions in a declarative way. For example, privileged functions need to check the identity or the privilege level of the caller.
We can see from the Figure 1, sensitive functions (e.g., unlockToken / lockBalances) use theonlyOwner modifier to guarantee that only the current contract owner can call them. It seems pretty legitimate, so what’s the problem?
Let’s take a closer look into the AURA contract which inherits SafeMath for safe mathematical calculation and Owned for contract ownership management. Inside the Owned contract, there is a method setOwner() for changing the contract ownership, which is a highly sensitive operation. However, this sensitive method doesn’t have any function modifier, like onlyOwner, to restrict its use. Even worse, the method’s visibility is public by default, which means anyone can call it to modify owner to anyone at their choice.
As a proof-of-concept demonstration, we launch the following transaction and essentially replaceowner to 0xcafebabe.
And we can verify by checking the owner variable of AURA contract.
Consequences
With the ownerAnyone bug to essentially change the smart contract ownership, any sensitive operations restricted by onlyOwner can be easily bypassed. For example, the unlockToken()method can be used to unlock transfer, which might be used during early stage to control token transferring. Also, the lockBalances() method can be called to set the balancesUploaded variable to true (with false as the default value), essentially locking up the uploadBalances() operation and making it no longer accessible.
line 140) bool public balancesUploaded = false;
In other words, once balancesUploaded is set to true, uploadBalances() can never be reached, which lead to a DoS attack:
line 142) require(!balancesUploaded);
During our investigation, we initially think there is a questionable operation in the end:
line 148) balanceOf[owner] = safeSub(balanceOf[owner], sum);
It turns out that it is protected by safeSub(), which will revert the whole transaction if balanceOf[owner] doesn’t have enough tokens. Note that ownerAnyone is a twin vulnerability to the IDXM bug in [1].
Conclusion
Writing a safe smart contract is NOT an easy job. It requires different security considerations from our traditional software development. Any security miss may allow for attackers to take advantage of your contract with valuable assets and cause significant financial damage. It is fortunate thatownerAnyone in this particular case only does limited harm. It can get much worse if AURAcontains other administrative functions, say, controlling token supply by owner.
We cannot over-emphasize the importance of smart contract auditing. Here are some basic security guidelines to follow:
Always use libraries like SafeMath for safe mathematical calculations
Always declare your functions with right modifiers and visibilities
Being said, if at all possible, audit your smart contracts before deployment by consulting professional auditing services from qualified security companies. After all, precaution is better than cure.
References
相關文章
- 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)
- New multiOverflow Bug Identified in Multiple ERC20 Smart Contracts (CVE-2018-10706)IDE
- New burnOverflow Bug Identified in Multiple ERC20 Smart Contracts (CVE-2018-11239)IDE
- ALERT: New batchOverflow Bug in Multiple ERC20 Smart Contracts (CVE-2018-10299)BAT
- 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
- SMART goals - SMART objectivesGoObject
- Bug 12725963 - New database connection fails with ORA-12541 after vip failoverDatabaseAI
- [BUG反饋]onethink 登陸時呼叫$User = new UserApi; 報錯。API
- Poor Performance On Certain Dictionary Queries After Upgrade To 10gORMAI
- openzeppelin/contracts/utils/Counters.sol" not found
- Smart Industry Operations
- Laravel 原始碼閱讀指南 -- Contracts 契約Laravel原始碼
- 閉包的理解-from my own opinion
- new self()與new static()
- The phenomenon of smart contract honeypots
- The APR based Apache Tomcat Native library which allows optimal performance in production ...解決方案ApacheTomcatORM
- New
- 重構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
- What’s your own way of spending two-day weekend?
- 理解new和實現一個new
- new learn
- a new ideaIdea
- a new blog
- in place new
- SMART Utility for mac (硬碟檢測)Mac硬碟
- Cell smart table scan等待事件事件
- How to Add a New Disk new partition in centos7CentOS
- PHP new self()和new static()的區別PHP
- javascript 中function(){},new function(),new Function(),Function 摘錄JavaScriptFunction
- new static ,new self ,self::, $this的一些理解
- 硬碟檢測工具:SMART Utility for mac硬碟Mac
- ACT B414F Smart Toy