Sign inSign up

trailofbits/slither

By trailofbits

Updated over 7 years ago

Static Analyzer for Solidity

Image
2

10K+

trailofbits/slither repository overview

Slither, the Solidity source analyzer

Logo

Build Status Slack Status PyPI version

Slither is a Solidity static analysis framework written in Python 3. It runs a suite of vulnerability detectors, prints visual information about contract details, and provides an API to easily write custom analyses. Slither enables developers to find vulnerabilities, enhance their code comphrehension, and quickly prototype custom analyses.

Features

  • Detects vulnerable Solidity code with low false positives
  • Identifies where the error condition occurs in the source code
  • Easily integrates into continuous integration and Truffle builds
  • Built-in 'printers' quickly report crucial contract information
  • Detector API to write custom analyses in Python
  • Ability to analyze contracts written with Solidity >= 0.4
  • Intermediate representation (SlithIR) enables simple, high-precision analyses
  • Correctly parses 99.9% of all public Solidity code
  • Average execution time of less than 1 second per contract

Usage

Run Slither on a Truffle application:

slither .

Run Slither on a single file:

$ slither tests/uninitialized.sol 

For additional configuration, see the usage documentation.

Detectors

By default, all the detectors are run.

NumDetectorWhat it DetectsImpactConfidence
1shadowing-stateState variables shadowingHighHigh
2suicidalFunctions allowing anyone to destruct the contractHighHigh
3uninitialized-stateUninitialized state variablesHighHigh
4uninitialized-storageUninitialized storage variablesHighHigh
5arbitrary-sendFunctions that send ether to arbitrary destinationsHighMedium
6controlled-delegatecallControlled delegatecall destinationHighMedium
7reentrancy-ethReentrancy vulnerabilities (theft of ethers)HighMedium
8erc20-interfaceIncorrect ERC20 interfacesMediumHigh
9incorrect-equalityDangerous strict equalitiesMediumHigh
10locked-etherContracts that lock etherMediumHigh
11shadowing-abstractState variables shadowing from abstract contractsMediumHigh
12constant-functionConstant functions changing the stateMediumMedium
13reentrancy-no-ethReentrancy vulnerabilities (no theft of ethers)MediumMedium
14tx-originDangerous usage of tx.originMediumMedium
15uninitialized-localUninitialized local variablesMediumMedium
16unused-returnUnused return valuesMediumMedium
17shadowing-builtinBuilt-in symbol shadowingLowHigh
18shadowing-localLocal variables shadowingLowHigh
19calls-loopMultiple calls in a loopLowMedium
20reentrancy-benignBenign reentrancy vulnerabilitiesLowMedium
21timestampDangerous usage of block.timestampLowMedium
22assemblyAssembly usageInformationalHigh
23constable-statesState variables that could be declared constantInformationalHigh
24deprecated-standardsDeprecated Solidity StandardsInformationalHigh
25erc20-indexedUn-indexed ERC20 event parametersInformationalHigh
26external-functionPublic function that could be declared as externalInformationalHigh
27low-level-callsLow level callsInformationalHigh
28naming-conventionConformance to Solidity naming conventionsInformationalHigh
29pragmaIf different pragma directives are usedInformationalHigh
30solc-versionIncorrect Solidity version (< 0.4.24 or complex pragma)InformationalHigh
31unused-stateUnused state variablesInformationalHigh

Contact us to get access to additional detectors.

Printers

To run a printer, use --print and a comma-separated list of printers.

How to install

Slither requires Python 3.6+ and solc, the Solidity compiler.

Using Pip
$ pip install slither-analyzer
Using Git
$ git clone https://github.com/trailofbits/slither.git && cd slither
$ python setup.py install 

We recommend using an Python virtual environment, as detailed in the Developer Installation Instructions, if you prefer to install Slither via git.

Using Docker

Use the eth-security-toolbox docker image. It includes all of our security tools and every major version of Solidity in a single image. /home/share will be mounted to /share in the container. Use solc-select to switch the Solidity version.

docker pull trailofbits/eth-security-toolbox

To share a directory in the container:

docker run -it -v /home/share:/share trailofbits/eth-security-toolbox

Getting Help

Feel free to stop by our Slack channel (#ethereum) for help using or extending Slither.

License

Slither is licensed and distributed under the AGPLv3 license. Contact us if you're looking for an exception to the terms.

Tag summary

Content type

Image

Digest

Size

122.4 MB

Last updated

over 7 years ago

docker pull trailofbits/slither