• Stars
    star
    215
  • Rank 183,925 (Top 4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated almost 5 years ago

Reviews

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

Repository Details

[DEPRECATED] Security Scanner for Ethereum Smart Contracts

[DEPRECATED] Securify

This is version of Securify is deprecated and will be no longer supported. Please use Securify v2.0.

securify

Securify is a security scanner for Ethereum smart contracts supported by the Ethereum Foundation and ChainSecurity. The core research behind Securify was conducted at the ICE Center at ETH Zurich.

scan now

It features an extensive list of security patterns commonly found in smart contracts:

  • some forms of the DAO bug (also known as reentrancy)
  • locked ether
  • missing input validation
  • transaction ordering-dependent amount, receiver and transfer
  • unhandled exceptions
  • unrestricted ether flow

The project is meant to be an open platform welcoming contributions from all of the Ethereum Security Community. To suggest new patterns, to volunteer for testing or to contribute developing new patterns please get in touch through our Discord group.

Getting Started

Requirements

  • Soufflé: https://github.com/souffle-lang/souffle/releases (Securify should work with the latest package, please raise an issue if it does not). If you cannot install Soufflé, look at the Docker container for an alternative. Securify will crash without the souffle binary. As of writing, Soufflé is not available on Windows, so Securify should not be expected to run on Windows either.
  • Java 8
  • A solc binary is required to be able to use Solidity file as input. Securify assumes that the right version is installed for the given file. solc is available here.

Use

To build:

./gradlew jar

To run Securify on a Solidity file:

java -jar build/libs/securify.jar -fs src/test/resources/solidity/transaction-reordering.sol

To run Securify on the decompilation output provided by the pysolc.py script (which requires py-solc):

java -jar build/libs/securify.jar -co out.json

To run Securify on some EVM binary (produced e.g. by solc):

java -jar build/libs/securify.jar -fh src/test/resources/solidity/transaction-reordering.bin.hex

To see the full list of options:

java -jar build/libs/securify.jar -h

To run the tests (which use JUnit4):

./gradlew test

A Python wrapper helps to deal with solc and truffle. The requirements are in the requirements.txt file. The Dockerfile can be used as a reference to set-up your local environment to use this wrapper.

Docker

The installation should be simple enough on Debian derivatives, or any other platform supported by Soufflé.

For a quick demonstration which does not require Soufflé, you can use Docker.

Build the Docker image:

docker build . -t securify

Run Securify on a small example:

docker run securify

You can change the files analyzed by specifying a volume to mount, and every *.sol file contained will then be processed by Securify:

docker run -v $(pwd)/folder_with_solidity_files:/project securify

Adding a --truffle flag should allow Securify to run over Truffle project in which dependencies have already been installed (so run npm install before if need be). Without this flag, the project is compiled using solc. Add a -h to obtain the full list of options. In particular, if the user wants to receive compilation information from Truffle, he should add the -v flag.

If one wants to receive JSON output, the docker supports a --json flag that will suppress the pretty output and return JSON instead. Make sure to add the -q flag if no progress information should be displayed, hence resulting in pure JSON output. The indices of the lines matched are 0-based, meaning that a match to line i means that the i+1th line is matched. In particular, the first line has an index of 0.

Tests

Basic end to end tests can be run through the test.py file:

python3 test.py

The requirements can be installed using Pipenv:

pipenv install

or using pip:

pip install -r requirements.txt

These tests compare the current json output given by Securify with some past output, and report differences between the two.

Travis Integration

You can add the following .travis.yml to your project to run Securify on new commits:

services:
  - docker

before_install:
  - docker pull chainsecurity/securify

script:
- docker run -v $(pwd):/project chainsecurity/securify

This should allow Securify to run over Truffle project in which dependencies have already been installed (so run npm install before if need be).

Output

The output loosely follows the clang style. Only warnings and vulnerabilities are reported. If one wishes to also get the compliance information, please use the --json flag in the docker, or -co flag on the Java executable to get all analysis information in JSON format.

Contributing

See CONTRIBUTING.md.

Join our Discord to discuss with other users.

Known Limitations

Although Securify is regularly used to help audits at ChainSecurity, there are still bugs, including:

  • the code in the fallback function is currently not analyzed. A workaround is to name this function instead.
  • in some cases, a StackOverflowError exception is thrown, due to computeBranches being recursive. In most cases, it is enough to increase the stack size using the -Xss option of java, e.g. java -Xss1G -jar ....
  • libraries are not properly supported
  • abstract contracts (whose binary cannot be obtained via solc) are not supported

Presentations, research, and blogs about Securify

Technical details

Securify statically analyzes the EVM code of the smart contract to infer important semantic information (including control-flow and data-flow facts) about the contract. This step is fully automated using Soufflé, a scalable Datalog solver. Then, Securify checks the inferred facts to discover security violations or prove the compliance of security-relevant instructions.

The full technical details behind the Securify scanner are available in the research paper.

More Repositories

1

lmql

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

silq

Q#
608
star
3

securify2

Securify v2.0
Solidity
587
star
4

debin

Machine Learning to Deobfuscate Binaries
Python
412
star
5

eran

ETH Robustness Analyzer for Deep Neural Networks
Python
313
star
6

diffai

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

Nice2Predict

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

language-model-arithmetic

Controlled Text Generation via Language Model Arithmetic
Python
201
star
9

ilf

AI based fuzzer based on imitation learning
Python
149
star
10

ELINA

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

psi

Exact Inference Engine for Probabilistic Programs
JetBrains MPS
123
star
12

sven

Python
95
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
82
star
14

zkay

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

astarix

AStarix: Fast and Optimal Sequence-to-Graph Aligner
C++
72
star
16

TFix

JavaScript
66
star
17

fastsmt

Learning to Solve SMT Formulas Fast
SMT
63
star
18

learch

C++
38
star
19

llmprivacy

Python
36
star
20

soltix

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

ChatProtect

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

probabilistic-forecasts-attacks

Python
30
star
23

colt

Convex Layerwise Adversarial Training (COLT)
Python
29
star
24

SafeCoder

Python
27
star
25

lcifr

Learning Certified Individually Fair Representations
Python
24
star
26

adaptive-auto-attack

Python
23
star
27

dp-sniper

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

verx-benchmarks

20
star
29

lamp

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

dp-finder

Differential Privacy Testing System
Python
19
star
31

bayonet

Probabilistic Computer Network Analysis
D
18
star
32

phoenix

Private and Reliable Neural Network Inference (CCS '22)
C++
18
star
33

fnf

Python
16
star
34

EventRacer

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

learning-real-bug-detector

Python
16
star
36

lassi

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

deepg

Certifying Geometric Robustness of Neural Networks
Python
15
star
38

vscode-silq

TypeScript
15
star
39

zapper

Rust
15
star
40

robust-code

Adversarial Robustness for Code
Python
13
star
41

watermark-stealing

Watermark Stealing in Large Language Models (ICML '24)
Python
13
star
42

guiding-synthesizers

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

learning-to-configure-networks

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

SABR

Python
11
star
45

bayes-framework-leakage

Python
11
star
46

smoothing-ensembles

[ICLR 2022] Boosting Randomized Smoothing with Variance Reduced Classifiers
Python
11
star
47

UniversalCertificationTheory

Universal Approximation with Certified Networks
Python
10
star
48

llm-quantization-attack

Python
10
star
49

eth-sri.github.io

SRI Group Website
HTML
9
star
50

ModelsPHOG

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

segmentation-smoothing

Provable robustness for segmentation tasks.
9
star
52

3dcertify

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

prover

Verifier for Deep Neural Network Audio Processing
Python
7
star
54

proof-sharing

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

mn-bab

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

ACE

Python
7
star
57

DFENCE

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

Delta-Siege

Python
6
star
59

automated-error-analysis

Automated Classification of Model Errors on ImageNet (NeurIPS 2023)
Jupyter Notebook
6
star
60

R4

C++
5
star
61

drs

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

paradox

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

fare

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

Unqomp

Automated Uncomputation for Quantum Programs
Python
4
star
65

fairness-feedback-nlp

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

Spire

C#
3
star
67

TAPS

Python
3
star
68

inferui

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

abstraqt

OpenQASM
3
star
70

transformation-smoothing

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

cuts

Python
3
star
72

ACES

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

synthetiq

OpenQASM
2
star
74

DeepT

Python
2
star
75

ncm

Trace Based Supervision for Neural Architectures
2
star
76

malicious-contamination

Python
2
star
77

CRAFT

Python
1
star
78

fedavg_leakage

Python
1
star
79

Reqomp

Python
1
star
80

ibp-propagation-tightness

Python
1
star
81

tableak

TabLeak: Tabular Data Leakage in Federated Learning
1
star
82

domino

1
star