This project provides an extensible static analyzer for Source code to identify common patterns that might indicate potential security vulnerabilities. The analyzer is written in Python and is designed for easy extensibility with additional checks.
- Detects usage of outdated Solidity compiler versions.
- Identifies the use of pragma experimental.
- Checks for potential unlocked ether due to unchecked send or transfer.
- Warns about low-level .call() usage.
- Highlights potential misuse of tx.origin instead of msg.sender.
- Verifies the presence of function visibility specifiers.
- Clone this repository to your local machine.
- Ensure you have Python 3.x installed.
- [Optional] Set up a virtual environment for the project.
- Place the Source code you want to analyze in a .sol file.
- Use the provided shell script to run the analyzer, providing the path to the Source file
- Use the key as defined in
bloodhounds.py#check_structures
:
./analyze_file.sh </path/to/your/file.sol> <KEY_OF_BLOUDHOUNDS_CAGE>
Review the output for any potential warnings or issues identified by the analyzer.
- Ensure all the Source files you want to analyze are within a directory.
- Use the provided shell script to run the analyzer, providing the path to the directory:
./analyze_dir.sh </path/to/your/directory/> <KEY_OF_BLOUDHOUNDS_CAGE>
Review the output for any potential warnings or issues identified by the analyzer for each file.
The Source Analyzer is structured for easy extensibility. The core checks are stored in the check_structures
dictionary. Within this dictionary, the "initial" key points to a list of checks. Each check is a dictionary containing two key-value pairs: "name" and "func".
-
Write the Check Function: Create a new function in
solidity_checks.py
. This function should accept the Source code as a string argument and return a list of findings.Example:
# Your check logic here return findings```
-
Import the Check Function: At the beginning of your main script (or wherever
check_structures
is defined), import your new check function:from solidity_checks import new_check_function
-
Add the Check to the Structure: Extend the
check_structures
dictionary by adding a new dictionary to the list associated with the "initial" key:{"name": "Descriptive Name of the Check", "func": new_check_function}
By following these steps, your new check will be integrated into the analyzer and will be executed when the script runs.
Contributions to improve the analyzer or add more checks are welcome! Please submit a pull request with your changes.
This tool provides basic static analysis of Solidity code for potential vulnerabilities. It is not a substitute for thorough manual code review or dynamic analysis. Always consult with blockchain security experts when developing and deploying smart contracts.