ZhangZhuoSJTU / Web3Bugs

Demystifying Exploitable Bugs in Smart Contracts
1.55k stars 210 forks source link

Demystifying Exploitable Bugs in Smart Contracts Logo

integrity validation

loading-ag-167 This project aims to provide a valuable resource for Web3 developers and security analysts by facilitating their understanding of exploitable bugs in smart contracts. We conduct a thorough analysis of exploitable bugs extracted from [code4rena](https://code4rena.com/) and classify each bug according to its nature. Our initial research suggests that a notable proportion of exploitable bugs in smart contracts are functional bugs, which cannot be detected using simple and general oracles like reentrancy. We aim to raise awareness about the significance of such bugs and encourage practitioners to develop more sophisticated and nuanced automatic semantical oracles to detect them.


𝙰 πšœπš’πšπš—πš’πšπš’πšŒπšŠπš—πš πš—πšžπš–πš‹πšŽπš› 𝚘𝚏 πšŽπš‘πš™πš•πš˜πš’πšπšŠπš‹πš•πšŽ πš‹πšžπšπšœ πš’πš— πšœπš–πšŠπš›πš πšŒπš˜πš—πšπš›πšŠπšŒπšπšœ πšπšŠπš•πš• πšžπš—πšπšŽπš› πšπš‘πšŽ πšŒπšŠπšπšŽπšπš˜πš›πš’ 𝚘𝚏 πšπšžπš—πšŒπšπš’πš˜πš—πšŠπš• πš‹πšžπšπšœ, πš πš‘πš’πšŒπš‘ πšŒπšŠπš—πš—πš˜πš πš‹πšŽ 𝚍𝚎𝚝𝚎𝚌𝚝𝚎𝚍 πšžπšœπš’πš—πš πšœπš’πš–πš™πš•πšŽ πšŠπš—πš πšπšŽπš—πšŽπš›πšŠπš• πš˜πš›πšŠπšŒπš•πšŽπšœ.


Please be aware that this repository is currently undergoing active development, and the data may change over time due to ongoing code4rena contests.

Dataset Description

Folder Structure

The dataset is organized into four folders:

Bug Labels

We classify the surveyed bugs into three main categories based on their nature:

As classifying functional bugs can be ambiguous, we welcome suggestions to improve our classification standards. You can find more detailed label information in our documentation, and we encourage you to refer to our current classification guidelines for more information.

Recommended Security Analysis Tools

Our goal is to create a comprehensive list of vulnerability detection techniques that will be a valuable resource for Web3 developers and security analysts. We will focus on two main categories:

We warmly welcome any additional suggestions or contributions from the community to help expand and improve the list.

Vulnerability Detection with Automatic Semantical Oracles

We believe that future web3 security efforts will prioritize identifying functional bugs and developing corresponding oracles. To this end, we intend to compile a list of techniques that provide guidance in the creation of automatic semantic oracles. These techniques will be sourced from various materials, such as peer-reviewed research papers, pre-prints, industry tools, and online resources.

Technique Bug Category
Finding Permission Bugs in Smart Contracts with Role Mining Access Control
AChecker: Statically Detecting Smart Contract Access Control Vulnerabilities Access Control
Towards Automated Verification of Smart Contract Fairness Fairness Property
Clockwork Finance: Automated Analysis of Economic Security in Smart Contracts TBD
Confusum Contractum: Confused Deputy Vulnerabilities in Ethereum Smart Contracts Confused Deputy
Not your Type! Detecting Storage Collision Vulnerabilities in Ethereum Smart Contracts Storage Collision

Publicly Available Security Analysis Techniques

This section will include open-source techniques that are publicly available and currently in active development. These techniques can be used either directly by Web3 developers and security analysts or as building blocks for other tools. We give priority to source-code level techniques, which are better suited for Web3 development and auditing contexts.

Technique Developer(s) Description Security-related Keywords
Slither Trail of Bits Static Analysis Framework Vulnerability Detectors, SlithIR
Aderyn Cyfrin Static Analysis Framework Static Analyzer, Custom Detectors, Markdown Reports
Foundry Paradigm Development Toolchain Fuzzing, Stateful Fuzzing (Invariant Testing), Differential Testing
Echidna Trail of Bits Fuzzer Fuzzing , Stateful Fuzzing (Invariant Testing), CI/CD
Optik Trail of Bits Hybrid Fuzzer (Symbolic Execution + Fuzzing) Fuzzing, Stateful Fuzzing, Symbolic Execution
Woke Ackee Blockchain Development Toolchain Cross-chain Testing, Invariant Testing, Vulnerability Detectors, IR
4naly3er Picodes Static Scanner Code4rena Pre-content Testing
Manticore Trail of Bits Symbolic Execution Tool Symbolic Execution, Property Testing
Halmos a16z Symbolic Bounded Model Checker Symbolic Execution, Bound Checker
Solidity SMTChecker Ethereum Foundation Formal Verification by Symbolic Execution Solidity, Formal Verification, Symbolic Execution
Mythril Consensys Symbolic Execution Tool Symbolic Execution, On-Chain Analysis, Vulnerability Detectors, Taint Analysis
Pyrometer [WIP] Nascent Symbolic Execution Tool Symbolic Execution, Abstract Interpretation
greed UCSB Seclab Static/Symbolic Analysis Framework Symbolic Execution, Bound Checker, Static Analyses, Property Testing
ethpwn ethpwn Dynamic analysis/Debugging EVM simulations, EVM debugging
In addition, we curate a catalogue of security utilities applicable to smart contract programming languages beyond Solidity.
| Technique | Language | Description | Security-related Keywords | | :------------------------------------------------------------------------------- | :--------------------------------------------------------- | :------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [Move Prover](https://github.com/move-language/move/tree/main/language/move-prover) | [Move](https://github.com/move-language) | Formal Specification and Verification | Formal Verification |

Valuable Resources for Web3 Security

This section comprises a compilation of resources that pertain to web3 security.
| Resource | Keywords | | :-------- | :------- | | [Academic Smart Contract Papers](https://github.com/hzysvilla/Academic_Smart_Contract_Papers) | Academic Paper List | | [DeFi Hacks Reproduce - Foundry](https://github.com/SunWeb3Sec/DeFiHackLabs) | Attack Replication | | [Smart Contract Security Verification Standard](https://github.com/ComposableSecurity/SCSVS) | Security Checklist | | [Awesome MythX Smart Contract Security Tools](https://github.com/muellerberndt/awesome-mythx-smart-contract-security-tools) | Security Analysis Service | | [Common Security Properties of Smart Contracts](https://github.com/crytic/properties) | Security Compliance Suite | | [Immunefi PoC Templates](https://github.com/immunefi-team/forge-poc-templates) | PoC Templates | | [Awesome MEV Resources](https://github.com/0xalpharush/awesome-MEV-resources) | MEV Resources | | [Front-Running Attack Benchmark Construction and Vulnerability Detection Technique Evaluation](https://arxiv.org/abs/2212.12110) | Front-Running Dataset | | [Ultimate DeFi & Blockchain Research Base](https://github.com/OffcierCia/ultimate-defi-research-base) | Blockchain Security All-in-One | | [Common Fork Bugs](https://github.com/YAcademy-Residents/defi-fork-bugs) | Exploit Dataset |

Contributing

We welcome all types of contributions to our project, including but not limited to:

Further details can be found in our contribution guidelines.

Cite

If you are using our dataset for an academic publication, we would really appreciate a citation to the following work:

@inproceedings{DBLP:conf/icse/ZhangZXL23,
  author       = {Zhuo Zhang and
                  Brian Zhang and
                  Wen Xu and
                  Zhiqiang Lin},
  title        = {Demystifying Exploitable Bugs in Smart Contracts},
  booktitle    = {{ICSE}},
  pages        = {615--627},
  publisher    = {{IEEE}},
  year         = {2023}
}

Clarification

Please refer to our classification documentation.

Acknowledgments

We would like to extend our sincere thanks to code4rena for making this valuable information publicly available.

Our appreciation also goes out to the following contributors for their valuable input.
+ [__ItsNio__](https://github.com/niothefirst) + [__Wen Xu__](https://github.com/tarafans) + [__Patrick Collins__](https://github.com/PatrickAlphaC) + [__Meng Xu__](https://twitter.com/meng_xu_cs) + [__y3s0n__](https://github.com/CharesFang) + [__William Aaron Cheung__](https://github.com/Troublor) + [__soaphorn__](https://github.com/soaphorn) + [__Fabio Gritti__](https://github.com/degrigis) + [__Yannick__](https://twitter.com/MillusPontius)