Towards Smart Hybrid Fuzzing for Smart Contracts

Christof Ferreira Torres, Antonio Ken Iannillo, Arthur Gervais, Radu State

Abstract

Smart contracts are Turing-complete programs executed across a blockchain. Unlike traditional programs, once deployed, they cannot be modified. As smart contracts carry more value, they become more of an exciting target for attackers. Over the last years, they suffered from exploits costing millions of dollars due to simple programming mistakes. As a result, a variety of tools for detecting bugs have been proposed. Most of these tools rely on symbolic execution, which may yield false positives due to over-approximation. Recently, many fuzzers have been proposed to detect bugs in smart contracts. However, these tend to be more effective in finding shallow bugs and less effective in finding bugs that lie deep in the execution, therefore achieving low code coverage and many false negatives. An alternative that has proven to achieve good results in traditional programs is hybrid fuzzing, a combination of symbolic execution and fuzzing. In this work, we study hybrid fuzzing on smart contracts and present ConFuzzius, the first hybrid fuzzer for smart contracts. ConFuzzius uses evolutionary fuzzing to exercise shallow parts of a smart contract and constraint solving to generate inputs that satisfy complex conditions that prevent evolutionary fuzzing from exploring deeper parts. Moreover, ConFuzzius leverages dynamic data dependency analysis to efficiently generate sequences of transactions that are more likely to result in contract states in which bugs may be hidden. Our evaluation on a curated dataset of 128 contracts and 21K real-world contracts shows that our hybrid approach detects more bugs (up to 23%) while outperforming state-of-the-art in terms of code coverage (up to 69%), and that data dependency analysis boosts bug detection up to 18%.

Introduction

Smart contracts are high-stakes, immutable programs. Once deployed to a blockchain, they cannot be patched, and a single bug can lead to the loss of millions of dollars. Current bug-detection tools generally fall into two camps: symbolic execution and fuzzing. Symbolic execution is precise but slow, suffering from "path explosion" where the number of possible execution paths grows exponentially. Conversely, traditional fuzzers are fast but "blind," struggling to bypass complex guard conditions (e.g., if (input == 0x12345678)) because the probability of randomly guessing a specific 256-bit value is near zero. Furthermore, smart contracts are stateful; a bug might only appear if a specific sequence of functions is called, a pattern random fuzzers often fail to generate.

ConFuzzius is the first hybrid fuzzer designed specifically for Ethereum smart contracts, combining the speed of evolutionary fuzzing with the precision of symbolic execution. By leveraging dynamic data dependency analysis to order transactions and an SMT solver to crack "magic value" conditions, it achieves significantly higher code coverage and bug detection rates than existing tools.

The ConFuzzius Architecture

The system utilizes a three-pronged architecture to bridge the gap between broad exploration and deep path discovery.

The ConFuzzius architecture combines an evolutionary fuzzing engine with an execution trace analyzer.
  1. Evolutionary Fuzzing Engine: This engine uses a Genetic Algorithm (GA) to evolve a population of transaction sequences. It employs a fitness function based on both code coverage and data dependencies to prioritize sequences that explore new contract states.
  2. Execution Trace Analyzer: This component performs symbolic taint analysis. When the fuzzer's coverage plateaus, the analyzer generates mathematical constraints for unreached branches and uses the Z3 SMT solver to find the exact inputs needed to satisfy them. These "magic values" are then added to mutation pools for future generations.
  3. Instrumented EVM: ConFuzzius executes transactions within a modified Ethereum Virtual Machine to monitor runtime behavior, including storage reads and writes.

Dynamic Data Dependency Analysis

A core innovation of ConFuzzius is its use of dynamic data dependency analysis. Unlike prior work that relied on static analysis, ConFuzzius monitors "Read-After-Write" (RAW) dependencies at runtime by watching EVM storage instructions (SLOAD and SSTORE).

Dynamic analysis tracks how functions read and write to contract state to prioritize effective transaction sequences.

If the system detects that Function A writes to a storage variable that Function B reads, it prioritizes sequences where A precedes B. This makes stateful exploration much more efficient than random shuffling, as it targets the specific inter-function dependencies that often hide vulnerabilities.

Evaluation and Results

The researchers evaluated ConFuzzius using a massive collection of 21,147 real-world contracts from Etherscan and a curated dataset of 128 contracts with 148 manually annotated vulnerabilities.

  • Superior Coverage: ConFuzzius achieved 91% coverage on small contracts and 81% on large contracts. In contrast, Mythril, a popular symbolic execution tool, dropped to 53% on large contracts due to path explosion.
  • Higher Bug Detection: In the curated dataset, ConFuzzius detected 106 out of 148 vulnerabilities (71%), outperforming Mythril and M-Pro, which found only 68.
  • Efficiency: In a motivating example of a vulnerable token sale, ConFuzzius identified the bugs in less than 10 seconds, while state-of-the-art fuzzers like ILF failed to find them after an hour.
  • Ablation Study: The authors demonstrated that data dependency analysis alone boosted bug detection by up to 18%, confirming that "state-aware" fuzzing is critical for the smart contract domain.

Conclusion

ConFuzzius demonstrates that hybrid fuzzing, augmented by dynamic data dependency analysis, is a highly effective approach for securing smart contracts. By combining the strengths of evolutionary algorithms and symbolic logic, it overcomes the limitations of path explosion and "blind" random testing, providing a robust tool for detecting deep-seated vulnerabilities in the blockchain ecosystem.

Summary updated

BibTeX
@inproceedings{torres2021towards,
  author = {Christof Ferreira Torres and Antonio Ken Iannillo and Arthur Gervais and Radu State},
  title = {{Towards Smart Hybrid Fuzzing for Smart Contracts}},
  booktitle = {EuroS\&P},
  year = {2021},
  url = {https://openreview.net/forum?id=jFEChiVllI},
}
Figure