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)
- ALERT: New batchOverflow Bug in Multiple ERC20 Smart Contracts (CVE-2018-10299)BAT
- 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
- New allowAnyone Bug Identified in Multiple ERC20 Smart Contracts (CVE-2018-11397, CVE-2018-11398)IDE
- New evilReflex Bug Identified in Multiple ERC20 Smart Contracts (CVE-2018-12702, CVE-2018-12703)FlexIDE
- Get the characteristics of a certain class for a certain materialAI
- First blog for Technology Of my own ,new world rules coming up next~
- SMART goals - SMART objectivesGoObject
- Automatically Map Network Drives on Domain Login for All Users, Certain Users, or Certain GroupsAI
- She Got her ownGo
- Another excuse is usually to be parajumpers sale certain safetyAI
- Smart Clientclient
- 【Exception】:own error messageExceptionError
- CodeForces 908B New Year and Buggy Bot
- Recipe 4.7. Blocking Inserts to Certain ColumnsBloCAI
- Build Your Own Cas Service - ProUI
- [BUG反饋]onethink 登陸時呼叫$User = new UserApi; 報錯。API
- oracle 9i wrap加密,需要指定edubug=wrap_new_sqlOracle加密SQL
- SMART Goal SettingGo
- Poor Performance On Certain Dictionary Queries After Upgrade To 10gORMAI
- openzeppelin/contracts/utils/Counters.sol" not found
- 閉包的理解-from my own opinion
- New start new hope!
- 重構smart-importImport
- Slither: A Static Analysis Framework For SmartFramework
- Smart Value Help 總結
- 6.7.Propel-smart,easyobjectpersistenceObject
- Certain:2017年事件營銷調查報告AI事件
- Laravel 原始碼閱讀指南 -- Contracts 契約Laravel原始碼
- 對話#28:Contracts, Promises, and Mere Semantics (轉)Promise
- new self()與new static()
- new Child();new Child(1);
- Write Your Own Operating System Tutorial(1) (轉)
- Write Your Own Operating System Tutorial(2) (轉)
- Write Your Own Operating System Tutorial(4) (轉)
- Write Your Own Operating System Tutorial(3) (轉)