Slither 一个Solidity静态分析框架,提供了一个API来轻松操作Solidity代码

网友投稿 1055 2022-11-05

Slither 一个Solidity静态分析框架,提供了一个API来轻松操作Solidity代码

Slither 一个Solidity静态分析框架,提供了一个API来轻松操作Solidity代码

Slither, the Solidity source analyzer

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 comprehension, and quickly prototype custom analyses.

FeaturesBugs and Optimizations DetectionPrintersToolsHow to InstallGetting HelpPublications

Features

Detects vulnerable Solidity code with low false positivesIdentifies where the error condition occurs in the source codeEasily integrates into continuous integration and Truffle buildsBuilt-in 'printers' quickly report crucial contract informationDetector API to write custom analyses in PythonAbility to analyze contracts written with Solidity >= 0.4Intermediate representation (SlithIR) enables simple, high-precision analysesCorrectly parses 99.9% of all public Solidity codeAverage execution time of less than 1 second per contract

Bugs and Optimizations Detection

Run Slither on a Truffle/Embark/Dapp/Etherlime application:

slither .

Run Slither on a single file:

$ slither tests/uninitialized.sol

For additional configuration, see the usage documentation.

Use solc-select if your contracts require older versions of solc.

Detectors

NumDetectorWhat it DetectsImpactConfidence
1name-reusedContract's name reusedHighHigh
2rtloRight-To-Left-Override control character is usedHighHigh
3shadowing-stateState variables shadowingHighHigh
4suicidalFunctions allowing anyone to destruct the contractHighHigh
5uninitialized-stateUninitialized state variablesHighHigh
6uninitialized-storageUninitialized storage variablesHighHigh
7arbitrary-sendFunctions that send ether to arbitrary destinationsHighMedium
8controlled-delegatecallControlled delegatecall destinationHighMedium
9reentrancy-ethReentrancy vulnerabilities (theft of ethers)HighMedium
10erc20-interfaceIncorrect ERC20 interfacesMediumHigh
11erc721-interfaceIncorrect ERC721 interfacesMediumHigh
12incorrect-equalityDangerous strict equalitiesMediumHigh
13locked-etherContracts that lock etherMediumHigh
14shadowing-abstractState variables shadowing from abstract contractsMediumHigh
15tautologyTautology or contradictionMediumHigh
16boolean-cstMisuse of Boolean constantMediumMedium
17constant-function-asmConstant functions using assembly codeMediumMedium
18constant-function-stateConstant functions changing the stateMediumMedium
19divide-before-multiplyImprecise arithmetic operations orderMediumMedium
20reentrancy-no-ethReentrancy vulnerabilities (no theft of ethers)MediumMedium
21tx-originDangerous usage of tx.originMediumMedium
22unchecked-lowlevelUnchecked low-level callsMediumMedium
23unchecked-sendUnchecked sendMediumMedium
24uninitialized-localUninitialized local variablesMediumMedium
25unused-returnUnused return valuesMediumMedium
26shadowing-builtinBuilt-in symbol shadowingLowHigh
27shadowing-localLocal variables shadowingLowHigh
28void-cstConstructor called not implementedLowHigh
29calls-loopMultiple calls in a loopLowMedium
30reentrancy-benignBenign reentrancy vulnerabilitiesLowMedium
31reentrancy-eventsReentrancy vulnerabilities leading to out-of-order EventsLowMedium
32timestampDangerous usage of block.timestampLowMedium
33assemblyAssembly usageInformationalHigh
34boolean-equalComparison to boolean constantInformationalHigh
35deprecated-standardsDeprecated Solidity StandardsInformationalHigh
36erc20-indexedUn-indexed ERC20 event parametersInformationalHigh
37low-level-callsLow level callsInformationalHigh
38naming-conventionConformance to Solidity naming conventionsInformationalHigh
39pragmaIf different pragma directives are usedInformationalHigh
40solc-versionIncorrect Solidity versionInformationalHigh
41unused-stateUnused state variablesInformationalHigh
42reentrancy-unlimited-gasReentrancy vulnerabilities through send and transferInformationalMedium
43too-many-digitsConformance to numeric notation best practicesInformationalMedium
44constable-statesState variables that could be declared constantOptimizationHigh
45external-functionPublic function that could be declared as externalOptimizationHigh

See the Detectors Documentation for more information. By default, all the detectors are run.

Check out Crytic to get access to additional Slither's detectors and GitHub integration.

Printers

Quick Review Printers

human-summary: Print a human-readable summary of the contractsinheritance-graph: Export the inheritance graph of each contract to a dot filecontract-summary: Print a summary of the contracts

In-Depth Review Printers

call-graph: Export the call-graph of the contracts to a dot filecfg: Export the CFG of each functionsfunction-summary: Print a summary of the functionsvars-and-auth: Print the state variables written and the authorization of the functions

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

See the Printer documentation for the complete lists.

Tools

slither-check-upgradeability: Review delegatecall-based upgradeabilityslither-prop: Automatic unit tests and properties generationslither-flat: Flatten a codebaseslither-erc: Check the ERC's conformanceslither-format: Automatic patches generation

See the Tool documentation for additional tools.

Contact us to get help on building custom tools.

How to install

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

Using Pip

$ pip3 install slither-analyzer

Using Git

$ git clone https://github.com/crytic/slither.git && cd slither$ python3 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.

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.

The Printer documentation describes the information Slither is capable of visualizing for each contract. The Detector documentation describes how to write a new vulnerability analyses. The API documentation describes the methods and objects available for custom analyses. The SlithIR documentation describes the SlithIR intermediate representation.

License

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

Publications

Trail of Bits publication

Slither: A Static Analysis Framework For Smart Contracts, Josselin Feist, Gustavo Grieco, Alex Groce - WETSEB '19

External publications

ReJection: A AST-Based Reentrancy Vulnerability Detection Method, Rui Ma, Zefeng Jian, Guangyuan Chen, Ke Ma, Yujia Chen - CTCIS 19MPro: Combining Static and Symbolic Analysis forScalable Testing of Smart Contract, William Zhang, Sebastian Banescu, Leodardo Pasos, Steven Stewart, Vijay Ganesh - ISSRE 2019ETHPLOIT: From Fuzzing to Efficient Exploit Generation against Smart Contracts, Qingzhao Zhang, Yizhuo Wang, Juanru Li, Siqi Ma - SANER 20Verification of Ethereum Smart Contracts: A Model Checking Approach, Tam Bang, Hoang H Nguyen, Dung Nguyen, Toan Trieu, Tho Quan - IJMLC 20

If you are using Slither on an academic work, consider applying to the Crytic $10k Research Prize.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:解决IDEA JDK9没有module
下一篇:Fire 一个使用 Swift 书写的轻量级 iOS/macOS/watchOS/tvOS 平台 HTTP/HTTPS 网络框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~