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.

Figure 1: Ownership-Checking Function Modifier: onlyOwner


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?


Figure 2: The Vulnerable setOwner() Method

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.

Figure 3: A Demo Ownership-Replacing Transaction


And we can verify by checking the owner variable of AURA contract.


Figure 4: AURA's New Owner: 0xcafebabe


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


Setting up usage-based billing for premium models typically involves configuring your cloud service provider's billing settings to track and charge based on actual resource consumption. Usage-based pricing allows users to pay only for what they use, which can be particularly beneficial for applications with variable workloads. To configure usage-based billing, navigate to the billing section of your cloud provider’s console or API. Select the premium model or service for which you want to enable this billing method. There should be an option to switch from flat-rate billing to usage-based billing. Ensure that detailed billing is enabled so that all usage metrics are captured accurately[^1]. When usage-based pricing is enabled, the system will monitor various metrics such as compute time, storage, and network usage. These metrics are then used to calculate charges according to the defined rate card. It is important to understand the specific metrics that will be tracked and how they are priced to avoid unexpected costs. If usage-based pricing is not available through the standard configuration options, it may be necessary to contact an administrator or the cloud provider's support team. They can assist with enabling this feature, especially if it requires changes to account settings or special permissions[^1]. When contacting an administrator, provide clear details about the services and resources for which usage-based billing should be enabled. Include any specific requirements, such as custom metrics or reporting intervals. Administrators may also need to set up alerts or budget thresholds to help manage costs effectively[^1]. After enabling usage-based billing, regularly review the usage reports and cost breakdowns provided by the cloud platform. This helps in optimizing resource usage and identifying potential cost-saving opportunities. Some platforms also allow setting up automated alerts when usage exceeds predefined thresholds, which can help prevent unexpected charges[^1]. For programmatic access to billing data, many cloud providers offer APIs that can be integrated into custom dashboards or financial management tools. The following is an example of how to retrieve billing data using a hypothetical API: ```python import requests # Replace with your actual API endpoint and authentication token url = "https://api.cloudprovider.com/v1/billing/usage" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN" } response = requests.get(url, headers=headers) if response.status_code == 200: usage_data = response.json() print("Current usage data:", usage_data) else: print("Failed to retrieve usage data. Status code:", response.status_code) ``` This script demonstrates how to fetch usage data programmatically, which can be useful for organizations that want to automate cost tracking and analysis[^1].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值