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 shadowing⁠HighHigh
2suicidalFunctions allowing anyone to destruct the contract⁠HighHigh
3uninitialized-stateUninitialized state variables⁠HighHigh
4uninitialized-storageUninitialized storage variables⁠HighHigh
5arbitrary-sendFunctions that send ether to arbitrary destinations⁠HighMedium
6controlled-delegatecallControlled delegatecall destination⁠HighMedium
7reentrancy-ethReentrancy vulnerabilities (theft of ethers)⁠HighMedium
8erc20-interfaceIncorrect ERC20 interfaces⁠MediumHigh
9incorrect-equalityDangerous strict equalities⁠MediumHigh
10locked-etherContracts that lock ether⁠MediumHigh
11shadowing-abstractState variables shadowing from abstract contracts⁠MediumHigh
12constant-functionConstant functions changing the state⁠MediumMedium
13reentrancy-no-ethReentrancy vulnerabilities (no theft of ethers)⁠MediumMedium
14tx-originDangerous usage of tx.origin⁠MediumMedium
15uninitialized-localUninitialized local variables⁠MediumMedium
16unused-returnUnused return values⁠MediumMedium
17shadowing-builtinBuilt-in symbol shadowing⁠LowHigh
18shadowing-localLocal variables shadowing⁠LowHigh
19calls-loopMultiple calls in a loop⁠LowMedium
20reentrancy-benignBenign reentrancy vulnerabilities⁠LowMedium
21timestampDangerous usage of block.timestamp⁠LowMedium
22assemblyAssembly usage⁠InformationalHigh
23constable-statesState variables that could be declared constant⁠InformationalHigh
24deprecated-standardsDeprecated Solidity Standards⁠InformationalHigh
25erc20-indexedUn-indexed ERC20 event parameters⁠InformationalHigh
26external-functionPublic function that could be declared as external⁠InformationalHigh
27low-level-callsLow level calls⁠InformationalHigh
28naming-conventionConformance to Solidity naming conventions⁠InformationalHigh
29pragmaIf different pragma directives are used⁠InformationalHigh
30solc-versionIncorrect Solidity version (< 0.4.24 or complex pragma)⁠InformationalHigh
31unused-stateUnused state variables⁠InformationalHigh

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