Stateful Greybox Fuzzing

Jinsheng Ba, Marcel Böhme, Zahra Mirzamomen, Abhik Roychoudhury · DOI

Introduction

Modern network protocols, such as HTTP/2, TLS, and RTSP, are fundamentally stateful. A server's response to a specific message is dictated not just by the message content, but by the sequence of messages previously processed. For instance, an HTTP/2 server requires a valid HEADER frame before it will accept a DATA frame.

While traditional greybox fuzzers like AFL and LibFuzzer have proven highly effective at discovering vulnerabilities by maximizing code coverage, they are often "state-blind." They may successfully execute the code paths for individual message handlers but fail to explore the complex, state-dependent logic that arises from specific sequences of inputs. Existing stateful fuzzing approaches often rely on manual protocol specifications or coarse-grained network response codes, which are either labor-intensive to create or insufficient for capturing deep internal logic.

The SGFUZZ Approach

This paper introduces SGFUZZ, a stateful greybox fuzzer designed to automatically identify and navigate a protocol’s state space. SGFUZZ leverages a key programmatic intuition: developers typically use enumerated types (enum) to represent and track the internal state of a protocol (e.g., STATE_IDLE, STATE_RECV_HEADERS, STATE_CLOSED).

Automatic State Identification

SGFUZZ begins with an offline analysis of the target's source code. It identifies all variables defined as enumerated types, treating them as potential "state variables." This heuristic allows the fuzzer to operate without manual annotations or formal protocol specifications.

State Transition Tree (STT)

During the fuzzing process, SGFUZZ instruments the target code to monitor the values assigned to these identified variables. It constructs a dynamic State Transition Tree (STT). In this tree, each node represents a specific state, and each path from the root represents a unique sequence of state transitions triggered by a sequence of input messages.

State-Aware Energy Scheduling

To move beyond simple code coverage, SGFUZZ implements a specialized energy scheduling mechanism. It prioritizes inputs that:

  1. Reach Rare States: Inputs that lead to rarely visited nodes in the STT are given more "energy" (mutation attempts).
  2. Facilitate State Discovery: Inputs whose mutations frequently result in new or different state paths are prioritized, as they likely represent critical junctions in the protocol logic.

Additionally, SGFUZZ employs byte-level prioritization, identifying which specific bytes in an input message are responsible for triggering state transitions and focusing mutation efforts on those high-impact regions.

Evaluation and Results

The researchers evaluated SGFUZZ against eight major protocol implementations, including OpenSSL, H2O, and Curl, using the PROFUZZBENCH suite and OSS-FUZZ benchmarks.

Performance Metrics

SGFUZZ demonstrated significant improvements over state-of-the-art fuzzers like LibFuzzer, AFLNet, and IJON:

  • State Depth: SGFUZZ explored an average of 33x more unique state sequences than LibFuzzer and 15x more than IJON.
  • Efficiency: It achieved baseline branch coverage 2.3x faster on average.
  • Bug Discovery: The tool identified 12 previously unknown bugs in mature software projects, including heap-based overflows and memory leaks. Eight of these vulnerabilities were assigned CVE IDs, highlighting their impact on internet security infrastructure.

Discussion and Limitations

The "Enum" heuristic proved remarkably effective; an analysis of 50 open-source protocol implementations showed that all of them used named constants to manage state. However, SGFUZZ does face limitations. It primarily tracks explicit states stored in variables and may overlook "implicit" states residing in the file system, databases, or complex heap structures. Furthermore, while the tool is highly effective, approximately 32% of identified enums were "noise" (e.g., configuration settings), though this did not significantly impede performance.

Conclusion

SGFUZZ demonstrates that tracking internal state variables is a powerful, automatable method for fuzzing complex protocols. By shifting the focus from simple code coverage to state-sequence coverage, SGFUZZ can uncover deep-seated logic errors that traditional fuzzers miss, providing a scalable solution for securing the stateful systems that underpin modern networking.

Summary updated

BibTeX
@inproceedings{ba2022stateful,
  author = {Jinsheng Ba and Marcel Böhme and Zahra Mirzamomen and Abhik Roychoudhury},
  title = {{Stateful Greybox Fuzzing}},
  booktitle = {USENIX Security},
  year = {2022},
}
Figure