From today BugBounty.Center will present a series of articles on classification of economical-technical threats when building blockchain apps, developed by a BugBounty.Center’s co-fouder Grigory Vasilkov. Hope this report will be informative and helpful for any, who has an interest in blockchain technology in general, and for programmers and developers in particular. If you have any notes or questions on the article, do not hesitate to contact us :)
Introduction:
The information security market as a rule is one step behind innovations in the world of information technologies. Many companies often recall the safety of a product only when something wrong has already happened and the subsequent risks of detecting and exploiting a security flaw are greater than the cost of self-searching for a defect and correcting it.
Going back 20 years ago, the detection was often limited only to finding vulnerabilities in Windows and Linux. Most hackers attempted to exploit the Buffer Overflow class attacks and gain remote access to computers. About 15 years ago, when the massive web resources were introduced, there appeared another class of attacks that focused on exploiting security flaws in web technologies: XSS, SQL injection, etc. Approximately 7 years ago, the Internet of Things (IoT) technologies for mass use began spreading, which resulted in the classification of OWASP Internet of Things Project (https://www.owasp.org/index.php/OWASP_Internet_of_Things_Project#tab=Main) attacks. And it is not a long way when we will see a whole class of security flaws, relating to both blockchain technologies and even to artificial intelligence.
2016 should be considered as the beginning of the mass use of programmable smart contracts in the blockchain environment. It was that year when the resonant hacking of The DAO on the Ethereum blockchain occurred, and as a result the public began to pay more attention to security problems in the design of smart contracts.
Since smart contracts directly relate to the movement of valuable cryptocurrency units between counterparties, the security of a smart contract is of paramount importance in the implementation of transactions.
When developing a smart contract, one often has to solve unique tasks. Although the programming of contracts in many respects resembles traditional programming, it touches upon important new security issues, since cryptocurrency and tokens have value that needs to be protected. If you send money to a smart contract with an existing vulnerability, you are most likely at risk of losing all your funds. In addition, the programming of smart contracts requires economic thinking, which traditional programmers may not have.
Smart contracts should be designed taking into account the interests of all parties, even if counterparties change the data that maximize their economic benefits. Designing an application architecture assumes that when programming smart contracts, additional precautions and checks are of great importance.
Which blockchains are exposed to security risks:
At the moment, due to the popularity of the ICO, most of the members of the blockchain community are unlikely to be able to name more than a dozen of blockchain platforms on which one can build smart contracts. Most likely, many will stop at Ethereum. Nevertheless, even now the number of blockchain platforms on which it is possible to implement smart contracts is approaching 40.
Each new blockchain platform tries to provide for some of its features that will help it to take the leading positions in the community. Some of the platforms serve as private blockchain and their focus is the corporate sector, some position themselves as hybrid platforms, i.e. combine both private and public blockchain.
Each platform has its own peculiarities, which allow receiving data from external sources. Some of this functionality is implemented from under the box, while others are encouraged to use the system of external trusted Oracle nodes that can provide reliable external data.
To increase the speed of transactions and the processing of information in the blockchain network various platforms use different consensus algorithms: POW, POS, DPOS, POI, etc.
Most likely, most blockchain systems that do not provide for the logics of implementing smart contracts will be left on the margins of history and will be unclaimed even as a means of value exchange. Next year 2018 we will remember as the year of development of smart contracts and blockchain platforms, which will increasingly influence the decentralized systems.
Programming languages of smart contracts:
To date, most of the developers for writing smart contracts use the Ethereum platform and the Solidity programming language. But in the next year new blockchain platforms will bring a huge variety to the programming languages used. More and more often there will be used not only well-known languages, such as: C ++, C #, Java, Go, Solidity, Kotlin, Rust, Scala, Javascript, Plutus, but their platforms’ own languages as well: Michelson, Simvolio, etc.
Such a number of programming languages in an actively developing imperfect area not only threatens the security of this technology, but also increases the risks of emergence of critical situations. To study the features of technology and programming languages, it is necessary that enough time has passed. Developers also need time to master many of the nuances of development, as well as to learn the rules of safe code writing. The market of blockchain technologies is only in its beginning and the blockchain community has not come yet to a single classification of security flaws and vulnerabilities that developers could use as patterns of secure code writing.
Security problems in smart contracts:
Nowadays many blockchain platforms, if not all, face a lot of technical problems: scalability, transaction speed, confidentiality, obtaining data from external sources, the cost of transactions, etc. The creators of blockchain platforms work for solving of all these problems. In this report we will not be deeply concerned with the problems of the architecture of blockchain systems, but focus on application security issues.
These problems of building a security architecture include the following:
In public blockchain platforms the logic of work and the smart contract code is available to all platform participants;
Personal data stored in smart contracts is also available to all platform participants;
When receiving data from external centralized sources, a smart contract can not explicitly guarantee the reliability of these data.
Let’s look at each point in more detail. For clarity, we will consider the security aspects by the example of the Ethereum blockchain because of its popularity.
In Ethereum blockchain smart contracts are most often developed in the high-level Solidity programming language, and then compiled into bytecode, which is processed and stored in the blockchain block. If you look at from bytecode of any contract, then you can see a long line in the hexadecimal system 0x6060604052600261010860005055604051611b51380380611b518339810 …. At first glance it is impossible to understand what a smart contract makes. Nevertheless, there are already many free tools that allow you to restore opcodes, machine instructions with a unique identifier, from bytecode, a sequence of bytes executed by the interpreter. For example, you can use ByteCode To Opcode Disassembler (https://etherscan.io/opcode-tool). As a result, we get much more readable code:
PUSH1 0x60
PUSH1 0x40
MSTORE
PUSH1 0x02
PUSH2 0x0108
PUSH1 0x00
POP
SSTORE
PUSH1 0x40
MLOAD
PUSH2 0x1b51
CODESIZE
…
Even when viewing opcodes, we can isolate and analyze the instructions that produce mathematical operations. But for most developers opcodes analysis, due to its complexity, has little to say.
In August 2017, at the Defcon conference, the Porosity tool was introduced, which is the first decompiler of smart contracts on the Ethereum blockchain. This tool allows you to lead to a high-level Solidity programming language by any bytecode. Now there is no need to analyze the contract opcodes to understand its work. Attackers can take any published smart contract and read all the methods available in it, even if the developers tried to hide some principles of work.
When developing smart contracts, it should be born in mind that all data placed in the blockchain will automatically become visible to all participants of the platform. Therefore, the transfer and storage of critical data in an open form can not be used. An incorrect example of designing an application can be an anonymous voting system, in which each participant sends his or her vote in an open form. In this case, the attacker can analyze the received votes and indirectly, or directly, affect the outcome of the vote. To prevent the publication of critical data in the clear, you should use different types of transformation, such as hashing. But in this case, users of a smart contract can use a centralized service to automate the process of hashing, which in its turn also imposes additional security risks.
Obtaining data from external untrusted sources also jeopardizes the implementation of the laid logic of a smart contract. To do this, we have to use a system of external Oracles, which can be compromised. Also, the external resource, to which the addressing occurs, is at risk of compromise as well.
It should be noted that for public blockchains the algorithm of obtaining data from external sources that would not be subjected to security risks, and logics of which would be embedded in the blockchain protocol, is not explicitly presented yet..
Types of attacks:
Applications and smart contracts that are based on blockchain technology are new and experimental. Therefore, it is necessary to expect constant changes in the security architecture, since new errors and security flaws are detected.
To program smart contracts one requires thinking different from that used in writing centralized applications. The cost of an error can be extremely high, and if there has not been foreseen a possibility to update the smart contract, the fix may not be possible, which makes the development something more like hardware programming or financial applications programming, rather than web or mobile development. Therefore, it is not enough to defend against known attacks and vulnerabilities. In addition, it is necessary to study the architecture of building of secure applications.
Many resources on the Internet now mention and describe technical attacks on smart contracts, but practically no one mentions economical-technical attacks and threats, which are based on mistakes in the business model and business logic. This class of security flaws only begins to appear; before the arising of blockchain technology and smart contracts it was presented to a lesser extent. In this paper we will attempt to classify this type of security flaws and give a definition of what it is.
Economical-Technical Attacks:
When designing the architecture of complex information systems using smart contracts, our development team faced the fact, that we can not explicitly foresee and predict the behavior of all elements of the system, that can directly or indirectly affect the logic of the work. Without an explicit idea of the number and type of data received, it is very difficult to develop the logics for eliminating errors. For example, when distributing winnings to a lottery, it is difficult to predict how many users will win a prize, if it is presupposed in conditions that more than one participant can win. For centralized applications the distribution of winnings would not be a problem, but for decentralized ones improvidence of all incoming data can play a cruel joke, up to freezing the prize on a smart contract.
An economic-technical attack is a set of plotter’s actions, leading to a violation of the economic stability of the information system. The result of a successful attack may be a change in economic indicators, stored in the information system, or their distortion.
Economic deficiencies, as a rule, are not clearly visible and require a full understanding of the mechanism of value transfer in the system, as well as the interaction of the elements of the application. To search for economic-technical deficiencies in smart contracts, it is desirable to understand the methods of economic-mathematical and system modeling, as well as the principles of the operation of blockchain technology. A descriptive language for such probabilistic dependencies in managed and controlled information systems was developed within the framework of a discipline such as economic cybernetics.
In the broad sense, economic cybernetics is understood as the field of science that arose at the junction of mathematics and cybernetics with the economy, including mathematical programming, operation research, economic-mathematical models, econometrics and mathematical economics.
Economic cybernetics considers the economy, as well as its structural and functional components, as a complex system in which regulatory and control processes implemented, that are operated by the movement and transformation of information. Economic cybernetics examines the management processes of complex economic systems using the tools of economic and mathematical modeling, and these management processes are essentially informational, based on economic information.
To design complex blockchain systems it is necessary to take into account the basic elements of economic cybernetics:
System analysis of components;
Hierarchy of interaction of complex elements;
Hierarchical management of elements;
Coordination of goals in hierarchical elements;
Processing of received information;
Optimization of information flows in management tasks;
Control and management in organizational systems;
Classification tasks;
Complex evaluation of system elements;
Cybernetic models of social and economic systems.
Thanks to the use of blockchain, economic cybernetics as a science can now get a second wind, because the use of blockchain technologies is directly related to the construction of economic processes and systems.
The use of economic cybernetics in the design of applications on blockchain should help in identifying difficult-to-forecast behavior patterns that affect the security of applications.
Our aim is not to describe all the properties of economic cybernetics. In this article, we only describe and solve one of many tasks, — the design problems. Applying the methods of economic cybernetics, we tried to classify economic-technical threats that could affect the embedded functional of the application.