TL;DR
This paper introduces xFuzz, a novel machine learning-guided fuzzing framework designed to tackle the challenging problem of cross-contract vulnerabilities in smart contracts. By leveraging ML to intelligently prune the search space and prioritize execution paths, xFuzz significantly improves the efficiency and effectiveness of detecting these often-missed vulnerabilities.
What Problem Does This Paper Address?
The increasing complexity of smart contract ecosystems means that transactions often involve interactions between multiple contracts. While tools exist to find vulnerabilities within single contracts or between two contracts, a significant gap remains in detecting vulnerabilities that arise from the interplay of three or more contracts. These "cross-contract vulnerabilities" are particularly dangerous and difficult to find because the number of possible interaction sequences explodes, making traditional testing methods computationally infeasible. Existing tools are often limited to analyzing at most two contracts simultaneously, leading to a large number of missed vulnerabilities.
Methods
xFuzz tackles this challenge with a two-pronged approach:
- Machine Learning Guidance: At its core, xFuzz uses a machine learning model trained on features extracted from smart contract code (including word vectors and static analysis features) to predict which functions are most likely to be vulnerable. This allows xFuzz to focus its testing efforts on the "hotspots" and avoid wasting time on clearly benign code.
- Path Prioritization: Beyond just identifying suspicious functions, xFuzz employs a sophisticated path prioritization algorithm. This algorithm considers both the ML model's predictions and other factors like caller complexity and parameter complexity to rank execution paths. Paths deemed more likely to lead to vulnerabilities are explored first, further optimizing the fuzzing process.
The ML model is trained using a voting mechanism from multiple static analysis tools to reduce individual tool bias. The framework then uses this trained model to guide a fuzzer, intelligently selecting which contracts and functions to test and in what order.
Datasets
The authors collected a large dataset of 100,139 smart contracts from Etherscan. This dataset was labeled using the results from three well-regarded static analyzers (Slither, Solhint, and Securify) to identify potential vulnerabilities. For evaluation, they used two datasets:
- Dataset1: A collection of labeled vulnerabilities from existing research and security websites, used for comparing xFuzz against other tools.
- Dataset2: A larger set of 7,391 contracts downloaded from Etherscan, specifically curated to include contracts with external calls and exclude toy examples, used for evaluating cross-contract and non-cross-contract fuzzing effectiveness.
Key Insights and Ideas
- ML as a Bias Reducer: Using an ML model trained on multiple static analysis tools helps overcome the limitations and biases inherent in any single static analysis technique.
- The Power of Prioritization: Simply identifying suspicious functions isn't enough; intelligently prioritizing which execution paths to explore first is crucial for efficiently finding complex vulnerabilities.
- Cross-Contract Complexity is a Major Hurdle: Existing tools struggle significantly with cross-contract analysis, often missing vulnerabilities that require interactions between more than two contracts.
- Efficiency Gains are Substantial: By intelligently guiding the fuzzing process, xFuzz can achieve significant speedups without sacrificing (and often improving) its ability to find vulnerabilities.
Key Results
- Novel Vulnerability Discovery: xFuzz detected 18 exploitable cross-contract vulnerabilities, with 15 of them being newly discovered and reported for the first time.
- High Precision and Recall: The ML model achieved a recall of 95% and the overall xFuzz system demonstrated a precision of 95.5% and a recall of 84.6% on non-cross-contract evaluations.
- Significant Speedup: xFuzz used less than 20% of the time compared to other fuzzing tools for detecting non-cross-contract vulnerabilities, while finding twice as many.
- Improved Cross-Contract Detection: Compared to state-of-the-art tools like CLAIRVOYANCE, xFuzz showed a much higher precision (100% vs. 43.7%) and recall for cross-contract vulnerabilities. CONTRACTFUZZER and SFUZZ reported zero cross-contract vulnerabilities.
- Effective Path Prioritization: The path prioritization strategy allowed xFuzz to find a significantly higher proportion of vulnerabilities within the first 10 explored paths compared to SFUZZ.
Limitations and Future Work
- Complex Path Conditions: The authors acknowledge that xFuzz, like other fuzzers, struggles with extremely complex path conditions involving multiple variables and values, leading to missed vulnerabilities.
- Future Work: They suggest integrating symbolic execution techniques (like Z3) with xFuzz to handle these complex path conditions more effectively, potentially creating a hybrid fuzzing approach. They also aim to extend xFuzz to support more types of vulnerabilities.
Summary updated