Skip to content

Latest commit

 

History

History
88 lines (70 loc) · 7.13 KB

README.md

File metadata and controls

88 lines (70 loc) · 7.13 KB

Classification of smart contract vulnerabilities

Each standard vulnerability is made possible by one of the features of smart contracts. We unite types of vulnerabilities into groups by the corresponding features. We unite several groups into the same class if their features have the same nature. Here is the list of classes and groups with some standard vulnerabilities categorized by this classification.

Blockchain

Vulnerabilities caused by blockchain nature of the system.

Block content manipulation

Miner assembles block and thus can influence its contents (included transactions, their order, other block parameters).

Contract interaction

Ethereum allows smart contracts to interact with each other. The following vulnerabilities are based on the fact that one contract cannot rely on the behaviour of an arbitrary contract.

Gas limitations

Blockchains require some payment for a transaction execution. In Ethereum, fee is proportional to the computational complexity of the code being executed. Vulnerabilities of this category are based on the fact that the amount of gas available for the transaction is limited.

  • Infinite loops (SWC-129)
  • Transfer provides too little gas: receiving contract has only 2300 gas for its fallback function, which is not enough for external call, writing to storage, etc

Message structure

Ethereum allows accounts to send messages to each other. This data is converted to function calls according to specific rules.

  • Signature collisions: two different functions may have the same signature
  • Short address attack (DASP-9, SP-8)

Ether transfer

Generally, all ETH transfers invoke contract’s fallback function and, thus, can be detected by the contract. However, there are several ways of ETH transfer that cannot be detected by the contract. Mostly, they are described in (SP-3).

  • Ether transfer with selfdestruct: contract cannot handle incoming Ether sent by selfdestruct function
  • Ether transfer with mining: contract cannot handle incoming Ether sent as a reward for block mining
  • Pre-sent Ether: contract cannot handle Ether sent to its address prior to the deploy

Language

Vulnerabilities caused by the insecure use of Solidity language (or any other language used for smart contracts).

Arithmetic

Solidity operates only with integer numbers and does not check the correctness of arithmetic operations.

Storage access

In some cases, state variables can point to an incorrect storage slot.

Internal control flow

Some features of Solidity can lead to overcomplicated control flow graph.

  • Multiple inheritance (SWC-125)
  • Arbitrary jump with function type variable (SWC-127)
  • Assembly return in constructor: this trick tampers with standard deployment process; as a result, actually deployed bytecode has little in common with the source code

Model

Vulnerabilities caused by mistakes in the model (architecture) of the system.

Authorization

Vulnerabilities connected with the insufficient or incorrect authorization implementation (DASP-2).

Trust

Ethereum was designed as a trustless system. However, many smart contracts are built so that users have to trust the owner/administrator. This part of the system can be compromised or used in an undesirable way.

  • Overpowered owner (SP-11 - see 3. Owner operations)
  • Vulnerable off-chain server: giving too much power to back-end can lead to undesired consequences if the off-chain server is hacked

Privacy

In Ethereum, smart contracts bytecode and values of state variables are available for everyone. However, some developers use it to store sensitive data.

Economy

Issues with the economic model of the system.

  • Voting issues: wrong voting logic that can lead to undesired effects
  • Tokenomics issues: undesired users behaviour caused by economic conjuncture of the token
  • Game Theory issues: undesired users behaviour caused by their feasible benefits

References

The following registries were addressed in the classification.

  1. Smart Contract Weakness Classification Registry.
  2. DASP TOP-10.
  3. Sigma Prime Blog.