Blockchain technology has the chance to revolutionize the way the people conduct business with each other. It has the potential to circumvent hurdles that plague nearly every contract, hurdles such as the lack of efficiency, trust, and security often found with contracts. Smart contracts, self-executing contracts that are translated into code and replicated through several nodes in a blockchain, are currently being used as an alternative to standard contracts. Smart contracts eliminate the need for brokers and intermediaries (and their associated fees). In addition, these contracts are automatically executed upon the meeting of the conditions specified in the contract, whose agreement is witnessed by hundreds of people. Thus, the contract is reliable and transparent. Nevertheless, there are major risks the come with using smart contracts. For example, in the DAO hack of 2016, over $50 million in Ethereum was stolen from DAO, the Decentralized Autonomous Organization, which ran on smart contracts (the Ethereum was later recovered, resulting in the creation of Ethereum Classic). Why are smart contracts so risky, and what can be done to combat security issues inherent to them?
One of the key advantages of using smart contracts comes with a big caveat: smart contracts cannot be manipulated or edited in any way without the consent of all parties to the contract. In November 2017, Ethereum users suffered a huge loss because of this danger when a contract owner accidentally locked all parties out of a multi-party contract. The loss in Ethereum was estimated to be between $150-300 million. Another risk of smart contracts is the presence of fraud. Even if a digital asset inside blockchain is verified, there is no way to verify whether that asset exists physically. And because smart contracts always execute, there may be no recourse for the defrauded party. The permanence of the smart contract may also entice hackers, who can lock out parties from contracts or exploit vulnerabilities in the smart contract in order to steal cryptocurrency. There are many other risks associated with smart contracts such as the loopholes that can be exploited from altering the timestamp that triggers an action in the contract, or the intermediate period between when contracts are being called by other contracts (the hacker in the DAO case took advantage of this intermediate period). These dangers can be mitigated through auditing in a scrupulous and holistic fashion.
Auditing smart contracts involves analyzing code in the contract in order to find bugs before the code is deployed into the cryptocurrency’s network, where it cannot be altered. Although audits are not legally binding, they can greatly reduce the likelihood of the risks associated with smart contracts from being exploited. Conducting audits on smart contracts is a multi-step process, and completing it guarantees that the correct measures are taken to prevent theft or fraud. These steps are:
- Determine the correct functioning of the contract, in accordance with the specification provided;
- Determine possible vulnerabilities which could be exploited by an attacker;
- Determine contract bugs, which might lead to unexpected behavior;
- Analyze whether best practices have been applied during development;
- Make recommendations to improve code safety and reliability.
One of the most critical steps that auditors employ is the weighing of the riskiness of vulnerabilities found in the code. Breaking down the code based on risk allows for the identification and correction of the code whose exploitation could have the most deleterious effects.
Major losses of cryptocurrency are an established risk that investors and buyers take when they make purchases—earlier this year that over 10% of Initial Coin Offerings had been stolen—and one must have the proper guidance before jumping into blockchain technology services like blockchain.
Integrity Risk Management and Consulting is here to offer auditing services to safeguard your smart contracts. Integrity will take the following steps when performing an audit:
- Gaining an understanding of the contract’s intended purpose by reading the available documentation;
- Automated scanning of the contract with static code analysis tools for security vulnerabilities and use of best practice guidelines;
- Manual line-by-line analysis of the contract’s source code for security vulnerabilities and use of best practice guidelines, including but not limited to:
- Re-entry analysis;
- Race condition analysis;
- Front-running issues and transaction order dependencies;
- Time dependencies;
- Under- /overflow issues;
- Function visibility issues;
- Possible denial of service attacks;
- Storage layout vulnerabilities;
- Report preparation.