• Stars
    star
    568
  • Rank 75,685 (Top 2 %)
  • Language
    Solidity
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Securify v2.0

securify

Securify v2.0

Securify 2.0 is a security scanner for Ethereum smart contracts supported by the Ethereum Foundation and ChainSecurity. The core research behind Securify was conducted at the Secure, Reliable, and Intelligent Systems Lab at ETH Zurich.

It is the successor of the popular Securify security scanner (you can find the old version here).

Features

  • Supports 37 vulnerabilities (see table below)
  • Implements novel context-sensitive static analysis written in Datalog
  • Analyzes contracts written in Solidity >= 0.5.8

Docker

To build the container:

sudo docker build -t securify .

To run the container:

sudo docker run -it -v <contract-dir-full-path>:/share securify /share/<contract>.sol

Note: to run the code via Docker with a Solidity version that is different than 0.5.12, you will need to modify the variable ARG SOLC=0.5.12 at the top of the Dockerfile to point to your version. After building with the correct version, you should not run into errors.

Install

Prerequisites

The following instructions assume that a Python is already installed. In addition to that, Securify requires solc, souffle and graphviz to be installed on the system:

Solc

sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc

Souffle

Follow the instructions here: https://souffle-lang.github.io/download.html

Please do not opt for the unstable version since it might break at any point.

Graphviz / Dot

sudo apt install graphviz

Setting up the virtual environment

After the prerequisites have been installed, we can set up the python virtual environment from which we will run the scripts in this project.

In the project's root folder, execute the following commands to set up and activate the virtual environment:

virtualenv --python=/usr/bin/python3.7 venv
source venv/bin/activate

Verify that the python version is actually 3.7:

python --version

Set LD_LIBRARY_PATH:

cd <securify_root>/securify/staticanalysis/libfunctors
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`

Finally, install the project's dependencies by running the following commands from the <securify_root> folder:

pip install --upgrade pip
pip install -r requirements.txt
pip install -e .

Now you're ready to start using the securify framework.

Remember: Before executing the framework's scripts, you'll need to activate the virtual environment with the following command:

source venv/bin/activate

Usage

Analyzing a contract

Currently Securify2 supports only flat contracts, i.e., contracts that do not contain import statements.

To analyze a local contract simply run:

securify <contract_source>.sol [--use-patterns Pattern1 Pattern2 ...]

Or download it from the Blockchain using the Etherscan.io API:

securify <contract_address> --from-blockchain [--key <key-file>]

Notice that you need an API-key from Etherscan.io to use this functionality.

To analyze a contract against specific severity levels run:

securify <contract_source>.sol [--include-severity Severity1 Severity2]
securify <contract_source>.sol [--exclude-severity Severity1 Severity2]

To get all the available patterns run:

securify --list

Supported vulnerabilities

ID Pattern name Severity Slither ID SWC ID Comments
1 TODAmount Critical - SWC-114
2 TODReceiver Critical - SWC-114
3 TODTransfer Critical - SWC-114
4 UnrestrictedWrite Critical - SWC-124
5 RightToLeftOverride High rtlo SWC-130
6 ShadowedStateVariable High shadowing-state, shadowing-abstract SWC-119
7 UnrestrictedSelfdestruct High suicidal SWC-106
8 UninitializedStateVariable High uninitialized-state SWC-109
9 UninitializedStorage High uninitialized-storage SWC-109
10 UnrestrictedDelegateCall High controlled-delegatecall SWC-112
11 DAO High reentrancy-eth SWC-107
12 ERC20Interface Medium erc20-interface -
13 ERC721Interface Medium erc721-interface -
14 IncorrectEquality Medium incorrect-equality SWC-132
15 LockedEther Medium locked-ether -
16 ReentrancyNoETH Medium reentrancy-no-eth SWC-107
17 TxOrigin Medium tx-origin SWC-115
18 UnhandledException Medium unchecked-lowlevel -
19 UnrestrictedEtherFlow Medium unchecked-send SWC-105
20 UninitializedLocal Medium uninitialized-local SWC-109
21 UnusedReturn Medium unused-return SWC-104
22 ShadowedBuiltin Low shadowing-builtin -
23 ShadowedLocalVariable Low shadowing-local -
24 CallToDefaultConstructor? Low void-cst -
25 CallInLoop Low calls-loop SWC-104
26 ReentrancyBenign Low reentrancy-benign SWC-107
27 Timestamp Low timestamp SWC-116
28 AssemblyUsage Info assembly -
29 ERC20Indexed Info erc20-indexed -
30 LowLevelCalls Info low-level-calls -
31 NamingConvention Info naming-convention -
32 SolcVersion Info solc-version SWC-103
33 UnusedStateVariable Info unused-state -
34 TooManyDigits Info too-many-digits -
35 ConstableStates Info constable-states -
36 ExternalFunctions Info external-function -
37 StateVariablesDefaultVisibility Info - SWC-108

The following Slither patterns are not checked by Securify since they are checked by the Solidity compiler (ver. 0.5.8):

  • constant-function
  • deprecated-standards
  • pragma

The following SWC vulnerabilities do not apply to Solidity contracts with pragma >=5.8 and are therefore not checked by Securify:

  • SWC-118 (Incorrect Constructor Name)
  • SWC-129 (Usage of +=)

More Repositories

1

lmql

A language for constraint-guided and efficient LLM programming.
Python
3,236
star
2

silq

Q#
606
star
3

debin

Machine Learning to Deobfuscate Binaries
Python
399
star
4

eran

ETH Robustness Analyzer for Deep Neural Networks
Python
305
star
5

diffai

A certifiable defense against adversarial examples by training neural networks to be provably robust
Python
216
star
6

securify

[DEPRECATED] Security Scanner for Ethereum Smart Contracts
Java
215
star
7

Nice2Predict

Learning framework for program property prediction
C++
201
star
8

language-model-arithmetic

Controlled Text Generation via Language Model Arithmetic
Python
154
star
9

ilf

AI based fuzzer based on imitation learning
Python
144
star
10

ELINA

ELINA: ETH LIbrary for Numerical Analysis
C++
126
star
11

psi

Exact Inference Engine for Probabilistic Programs
JetBrains MPS
123
star
12

zkay

A programming language and compiler which enable automatic compilation of intuitive data privacy specifications to NIZK-enabled private smart contracts.
Python
79
star
13

dl2

DL2 is a framework that allows training neural networks with logical constraints over numerical values in the network (e.g. inputs, outputs, weights) and to query networks for inputs fulfilling a logical formula.
Python
79
star
14

astarix

AStarix: Fast and Optimal Sequence-to-Graph Aligner
C++
67
star
15

fastsmt

Learning to Solve SMT Formulas Fast
SMT
63
star
16

TFix

JavaScript
63
star
17

sven

Python
58
star
18

learch

C++
38
star
19

soltix

SOLTIX: Scalable automated framework for testing Solidity compilers.
Java
33
star
20

colt

Convex Layerwise Adversarial Training (COLT)
Python
29
star
21

probabilistic-forecasts-attacks

Python
29
star
22

lcifr

Learning Certified Individually Fair Representations
Python
24
star
23

adaptive-auto-attack

Python
23
star
24

dp-sniper

A machine-learning-based tool for discovering differential privacy violations in black-box algorithms.
Python
22
star
25

ChatProtect

This is the code for the paper "Self-contradictory Hallucinations of Large Language Models: Evaluation, Detection and Mitigation".
Python
21
star
26

verx-benchmarks

19
star
27

dp-finder

Differential Privacy Testing System
Python
19
star
28

lamp

LAMP: Extracting Text from Gradients with Language Model Priors (NeurIPS '22)
Python
19
star
29

bayonet

Probabilistic Computer Network Analysis
D
18
star
30

phoenix

Private and Reliable Neural Network Inference (CCS '22)
C++
17
star
31

llmprivacy

Python
17
star
32

fnf

Python
16
star
33

EventRacer

A race detection tool for event driven applications.
C++
16
star
34

learning-real-bug-detector

Python
16
star
35

lassi

Latent Space Smoothing for Individually Fair Representations (ECCV 2022)
Python
15
star
36

deepg

Certifying Geometric Robustness of Neural Networks
Python
15
star
37

vscode-silq

TypeScript
15
star
38

zapper

Rust
15
star
39

robust-code

Adversarial Robustness for Code
Python
13
star
40

guiding-synthesizers

Guiding Program Synthesis by Learning to Generate Examples
Python
12
star
41

learning-to-configure-networks

[NeurIPS'22] Learning to Configure Computer Networks with Neural Algorithmic Reasoning
12
star
42

SABR

Python
10
star
43

UniversalCertificationTheory

Universal Approximation with Certified Networks
Python
10
star
44

bayes-framework-leakage

Python
10
star
45

smoothing-ensembles

[ICLR 2022] Boosting Randomized Smoothing with Variance Reduced Classifiers
Python
10
star
46

ModelsPHOG

Synthesized models for PHOG to make the results reproducible by the research community
C++
9
star
47

segmentation-smoothing

Provable robustness for segmentation tasks.
9
star
48

eth-sri.github.io

SRI Group Website
HTML
8
star
49

3dcertify

3DCertify is the first verifier to certify robustness of point cloud models against semantic transformations and point perturbations
Python
8
star
50

ACE

Python
8
star
51

proof-sharing

CAV'22 paper to speed up Neural Network Verification.
Python
7
star
52

prover

Verifier for Deep Neural Network Audio Processing
Python
6
star
53

DFENCE

Dynamic Analysis and Synthesis System for Relaxed Memory Models
C++
6
star
54

R4

C++
5
star
55

mn-bab

[ICLR 2022] Complete Verification via Multi-Neuron Relaxation Guided Branch-and-Bound
Python
5
star
56

automated-error-analysis

Automated Classification of Model Errors on ImageNet (NeurIPS 2023)
Jupyter Notebook
5
star
57

SafeCoder

5
star
58

paradox

On the Paradox of Certified Training (TMLR 10/2022)
Python
4
star
59

Delta-Siege

Python
4
star
60

Unqomp

Automated Uncomputation for Quantum Programs
Python
4
star
61

fairness-feedback-nlp

Human-Guided Fair Classification for NLP (ICLR 2023, Spotlight)
Python
4
star
62

Spire

C#
3
star
63

drs

[NeurIPS 2022] (De-)Randomized Smoothing for Decision Stump Ensembles
Terra
3
star
64

inferui

InferUI: Robust Relational Layouts Synthesis from Examples for Android
C++
3
star
65

fare

FARE: Provably Fair Representation Learning with Practical Certificates (ICML '23)
Shell
3
star
66

transformation-smoothing

Randomized Smoothing for Parametric (Image) Transformations
Python
3
star
67

TAPS

Python
2
star
68

DeepT

Python
2
star
69

ncm

Trace Based Supervision for Neural Architectures
2
star
70

ChromeER

C++
2
star
71

abstraqt

OpenQASM
2
star
72

ACES

[SRML@ICLR 2022] Robust and Accurate -- Compositional Architectures for Randomized Smoothing
Python
2
star
73

malicious-contamination

Python
2
star
74

synthetiq

OpenQASM
1
star
75

CRAFT

Python
1
star
76

fedavg_leakage

Python
1
star
77

Reqomp

Python
1
star
78

tableak

TabLeak: Tabular Data Leakage in Federated Learning
1
star
79

watermark-stealing

Watermark Stealing in Large Language Models
1
star