|
| 1 | +# SmartBugs: A Dataset of Vulnerable Solidity Smart Contracts |
| 2 | +SmartBugs is a dataset for research in automated reasoning and testing of smart contracts written in Solidity, the primary language used in Ethereum. The key new idea that SmartBugs proposes is that a reproducible dataset for automated analysis of smart contracts should also provide the possibility to integrate tools easily, so that they can be automatically compared (and their results reproduced). To the best of our knowledge, SmartBugs is the first dataset to provide this facility. |
| 3 | + |
| 4 | +SmartBugs is publicly available as a [GitHub repository](https://github.com/smartbugs/smartbugs). |
| 5 | + |
| 6 | +## Features |
| 7 | + |
| 8 | + - Organized collection of vulnerable Solidity smart contracts (organized according to the [DASP taxonomy](https://dasp.co)) |
| 9 | + - Users can create _named sets_, which are intended to represent subsets of contracts that share a common property. For example, a named dataset already provided by SmartBugs is `reentrancy`: it corresponds to contracts that are vulnerable to reentrancy attacks |
| 10 | + - Users can easily integrate new analysis tools and use SmartBugs' interface to run them. Tools available include [oyente](https://github.com/melonproject/oyente), [mythril](https://github.com/ConsenSys/mythril), [securify](https://github.com/eth-sri/securify), and [smartcheck](https://github.com/smartdec/smartcheck) |
| 11 | + - SmartBugs provides an interface that allows users to query the dataset and run different analysis tools on sets of contracts. |
| 12 | + |
| 13 | + |
| 14 | +## Requirements |
| 15 | +The first step is to clone [SmartBugs's repository](https://github.com/smartbugs/smartbugs): |
| 16 | + |
| 17 | +``` |
| 18 | +git clone https://github.com/smartbugs/smartbugs.git |
| 19 | +``` |
| 20 | + |
| 21 | +SmartBugs requires [Python3](https://www.python.org). To install all the requirements, you can execute: |
| 22 | + |
| 23 | +``` |
| 24 | +pip3 install -r requirements.txt |
| 25 | +``` |
| 26 | + |
| 27 | + |
| 28 | +## Usage |
| 29 | +SmartBugs provides a command-line interface that can be used as follows: |
| 30 | +``` |
| 31 | +smartBugs.py [-h, --help] |
| 32 | + (--file FILES | --type TYPE) |
| 33 | + --tool TOOLS |
| 34 | + --info TOOLS |
| 35 | + --list tools types |
| 36 | +```` |
| 37 | +
|
| 38 | +For example, we can analyse all contracts labelled with type `reentrancy` with the tool oyente by executing: |
| 39 | +
|
| 40 | +``` |
| 41 | +python3 smartBugs.py --tool oyente --type reentrancy |
| 42 | +``` |
| 43 | +
|
| 44 | +By default, results will be placed in the directory `results`. |
| 45 | +
|
| 46 | +
|
| 47 | +### Adding your tool or any third-party tool to SmartBugs |
| 48 | +
|
| 49 | +You will need to add a configuration file in `config/tools` and define the docker image to use and command to run. The config file should follow a structure similar to the following: |
| 50 | + ``` |
| 51 | + docker_image: |
| 52 | + default: primary docker image [REQUIRED] |
| 53 | + solc<5: [OPTIONAL] |
| 54 | + cmd: command to run analysis [REQUIRED] |
| 55 | + info: info about the tool [OPTIONAL] |
| 56 | + |
| 57 | + output_in_files: |
| 58 | + folder: if the tool does not log results in console, you should provide the path file inside the docker image to get the results [OPTIONAL] |
| 59 | + ``` |
| 60 | +Please check the provided config files for more concrete examples. |
| 61 | +
|
| 62 | +
|
| 63 | +### Adding new named sets |
| 64 | +
|
| 65 | +To add a new named set, edit the configuration file `dataset.yml` (in the folder `config/dataset`) and add the named path you want (can be files or dirs): |
| 66 | +
|
| 67 | +The config file should follow a structure similar to: |
| 68 | + ``` |
| 69 | + type_1: PATH |
| 70 | + type_2: |
| 71 | + - PATH |
| 72 | + - PATH |
| 73 | + ``` |
| 74 | +Please check the provided config files for more concrete examples. |
| 75 | +
|
| 76 | +## Known limitations |
| 77 | +
|
| 78 | +When running a tool the user must be aware of the solc compatibility. Due to the major changes introduced in solidity v0.5.0, we provide the option to pass another docker image to run contracts with solidity version below v0.5.0. However, please note that there may still be problems with the solidity compiler when compiling older versions of solidity code. |
| 79 | +
|
| 80 | +## Vulnerabilities |
| 81 | +
|
| 82 | +SmartBugs provides a collection of vulnerable Solidity smart contracts organized according to the [DASP taxonomy](https://dasp.co): |
| 83 | +
|
| 84 | +| Vulnerability | Description | Level | |
| 85 | +| --- | --- | -- | |
| 86 | +| [Reentrancy](https://github.com/smartbugs/smartbugs/blob/master/dataset/reentrancy) | Reentrant function calls make a contract to behave in an unexpected way | Solidity | |
| 87 | +| [Access Control](https://github.com/smartbugs/smartbugs/blob/master/dataset/access_control) | Failure to use function modifiers or use of tx.origin | Solidity | |
| 88 | +| [Arithmetic](https://github.com/smartbugs/smartbugs/blob/master/dataset/arithmetic) | Integer over/underflows | Solidity | |
| 89 | +| [Unchecked Low Level Calls](https://github.com/smartbugs/smartbugs/blob/master/dataset/unchecked_low_level_calls) | call(), callcode(), delegatecall() or send() fails and it is not checked | Solidity | |
| 90 | +| [Denial Of Service](https://github.com/smartbugs/smartbugs/blob/master/dataset/denial_of_service) | The contract is overwhelmed with time-consuming computations | Solidity | |
| 91 | +| [Bad Randomness](https://github.com/smartbugs/smartbugs/blob/master/dataset/bad_randomness) | Malicious miner biases the outcome | Blockchain | |
| 92 | +| [Front Running](https://github.com/smartbugs/smartbugs/blob/master/dataset/front_running) | Two dependent transactions that invoke the same contract are included in one block | Blockchain | |
| 93 | +| [Time Manipulation](https://github.com/smartbugs/smartbugs/blob/master/dataset/time_manipulation) | The timestamp of the block is manipulated by the miner | Blockchain | |
| 94 | +| [Short Addresses](https://github.com/smartbugs/smartbugs/blob/master/dataset/short_addresses) | EVM itself accepts incorrectly padded arguments | EVM | |
| 95 | +
|
| 96 | +
|
| 97 | +## Contributing to SmartBugs |
| 98 | +Everyone is welcome to contribute to the development of SmartBugs. |
| 99 | +
|
| 100 | +The easiest way is to create a pull request. Please write your commit messages in the present tense. We suggest you follow this guide: [Commit Message Guidelines](https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53). |
0 commit comments