Matryoshka: Fuzzing Deeply Nested Branches

Peng Chen, Jianzhong Liu, Hao Chen

Abstract

Greybox fuzzing is a highly effective technique for software vulnerability discovery, yet it frequently struggles with deeply nested conditional branches. When multiple branches depend on the same input bytes, traditional "greedy" mutation strategies often fail: satisfying an inner condition may inadvertently break an outer one, rendering the target code unreachable. This paper introduces Matryoshka, a novel fuzzer designed to solve these nested constraints by identifying dependencies and employing joint optimization. Matryoshka achieves significantly higher code coverage than state-of-the-art fuzzers and discovered 41 previously unknown bugs in popular open-source software.

Introduction

Modern fuzzers like AFL or Angora typically attempt to flip conditional branches one at a time. However, in complex parsers (e.g., image decoders or network protocols), branches are often nested like "Russian Dolls." If Branch B is nested within Branch A and both share input dependencies, a mutation that satisfies B might violate A. This "unreachable target" problem creates a significant barrier for automated testing.

Prevalence of nested constraints in various open-source programs.

As shown in the data above, nested constraints constitute a vast majority of unsolved constraints in real-world programs, often exceeding 80-90% of the total unsolved set. This highlights the necessity of a specialized approach for navigating deeply nested logic.

Methodology

Matryoshka addresses this by treating nested branches as a unified set of constraints rather than isolated hurdles. The system architecture extends the Angora fuzzer with a specialized pipeline for handling failures in standard gradient-descent-based solving.

The Matryoshka system architecture and its constraint-solving pipeline.

The methodology consists of three primary phases:

  1. Dependency Identification: The tool maps control-flow dependencies to determine which prior branches must be satisfied to reach a target. It then uses dynamic taint analysis to identify "effective" dependencies—those that share input bytes with the target branch. This drastically simplifies the problem by ignoring irrelevant code.
  2. Implicit Flow Detection: Matryoshka identifies hidden dependencies, such as branch choices affecting pointers used later, by executing the program multiple times and observing reachability under forced branch outcomes.
  3. Solving Strategies: Matryoshka employs three strategies to find a solution that fits all "locks" at once:
  4. Prioritize Reachability: Mutates only bytes that do not affect outer branches.
  5. Prioritize Satisfiability: Mutates target bytes while attempting to keep outer branches satisfied, using backtracking if conflicts arise.
  6. Joint Optimization: This is the core innovation. Matryoshka transforms the entire chain of nested branch conditions into a single mathematical function. By representing logical predicates as continuous functions, it can use gradient descent to find an input that satisfies all conditions simultaneously.

Evaluation and Results

The researchers evaluated Matryoshka against AFL, QSYM, and Angora using the LAVA-M benchmark and 13 real-world open-source programs (e.g., tcpdump, readpng, xmllint). Matryoshka demonstrated superior performance across all metrics:

  • Bug Discovery: It identified 41 unique new bugs, leading to 12 assigned CVEs.
  • Code Coverage: On xmllint, Matryoshka improved line coverage by 16.8% and branch coverage by 21.8% compared to Angora.
  • Benchmark Performance: In LAVA-M, it successfully triggered almost all injected bugs and even discovered "unlisted" bugs that were not part of the original benchmark's intended set.

Conclusion

While highly effective, Matryoshka currently requires source code for instrumentation. Future work may involve extending the tool to support binary-only targets and improving its handling of stateful, order-dependent branches. By shifting from a greedy, local search to a global, joint optimization approach, Matryoshka provides a powerful solution for exploring the deep logic of modern software.

Summary updated

BibTeX
@inproceedings{chen2019matryoshka,
  author = {Peng Chen and Jianzhong Liu and Hao Chen},
  title = {{Matryoshka: Fuzzing Deeply Nested Branches}},
  booktitle = {CCS},
  year = {2019},
  doi = {10.1145/3319535.3363225},
}
Figure