Welcome to the Solidity Security Scenarios repository! This repository is dedicated to providing examples of common security vulnerabilities in Solidity smart contracts, along with solutions and best practices to mitigate these issues. Our goal is to help developers understand and avoid security pitfalls when developing decentralized applications (DApps) on the Ethereum blockchain.
The repository is organized into directories, each representing a specific security scenario. Each scenario directory contains:
- A
README.mdfile explaining the scenario, its potential impact, and the solution. - Example Solidity contracts demonstrating the vulnerability and its solution.
- Solution contracts to fix and prevent the attack.
- Reentrancy: Understanding how reentrancy attacks work and how to prevent them.
- Arithmetic Overflow/Underflow: Identifying and mitigating arithmetic vulnerabilities.
- Self Destruct: Preventing accidental or malicious contract destruction.
- Delegate Call: Handling delegate call risks securely.
- Source of Randomness: Ensuring secure randomness in smart contracts.
- Denial of Service (DoS): Recognizing and preventing DoS attacks on smart contracts.
- Phishing with tx.origin: Avoiding tx.origin-based phishing attacks.
- Hiding Malicious Code with External Contract: Detecting and preventing hidden malicious code.
- Honeypot: Understanding and avoiding honeypot traps.
- Bypass Contract Size Check: Ensuring contract size checks cannot be bypassed.
- Accessing Private Data: Protecting private data in smart contracts.
- Front Running: Mitigating risks of front running in smart contracts.
-
Clone the Repository: bash git clone https://github.com/dappteacher/solidity-security-scenarios.git
-
Navigate to a Scenario: bash cd solidity-security-scenarios/scenarios/reentrancy
-
Read the Documentation:
- Each scenario includes a
README.mdwith a detailed explanation.
- Each scenario includes a
-
Review and Run the Code:
- Examine the Solidity code to understand the vulnerability and its solution.
- Use provided test scripts to simulate attacks and validate the fixes.
We welcome contributions!
If you have a new security scenario to share or improvements to existing ones, please submit a pull request.
Refer to the CONTRIBUTING.md file for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
For any questions or suggestions, please open an issue or reach out to us at dappteacher@gmail.com.
- Overview: Brief introduction to the repository and its purpose.
- Repository Structure: Describes how the repository is organized, making it easier for users to navigate.
- Scenarios Covered: Lists the types of security scenarios included in the repository.
- How to Use This Repository: Instructions for cloning the repository, navigating to specific scenarios, reading the documentation, and running the code.
- Contributions: Encourages community contributions and provides a link to the contributing guidelines.
- License: Specifies the license under which the project is distributed.
- Contact: Provides contact information for questions or suggestions.