Abstract
Network protocol parsers serve as the primary defense for connected systems, yet they are notoriously difficult to validate due to the lack of formal specifications and the prevalence of "silent" logic bugs. We present ParCleanse, an automated framework that leverages Large Language Models (LLMs) to bridge the gap between natural language RFC documents and formal protocol specifications. By extracting traceable oracles from documentation, ParCleanse detects semantic inconsistencies that traditional fuzzers miss. Our evaluation across nine major protocols identified 69 unique bugs, demonstrating the efficacy of hierarchical document interpretation and SMT-based test generation.
Introduction
Validating network protocol parsers faces two primary hurdles: the Oracle Problem and the Traceability Problem. Traditional testing, such as fuzzing, typically focuses on memory safety (crashes). However, many parser bugs are logic-based—incorrectly accepting malformed packets or rejecting valid ones—which do not trigger crashes. Without a "ground truth" specification, these bugs remain hidden. Furthermore, when a bug is identified, developers often lack a direct link to the specific RFC (Request for Comments) section that was violated, complicating the debugging process.
Existing solutions like differential analysis fail when multiple implementations share the same bug, and manual formal specification is prohibitively time-consuming. ParCleanse addresses these issues by automatically deriving formal specifications directly from RFC documents.
The ParCleanse Framework
ParCleanse operates through a three-phase pipeline designed to handle the complexity and length of technical documentation while minimizing LLM hallucinations.
Phase 1: Protocol Format Extraction
RFCs are decomposed into a DocTree, a hierarchical knowledge graph. This "divide-and-conquer" approach allows the system to identify dependencies (e.g., sub-components like TLVs) across different sections, building a complete formal specification without overwhelming the LLM's context window.
Phase 2: Fine-Grained Test Generation
The extracted specification is transformed into a Format Graph. ParCleanse utilizes the Z3 SMT solver to generate both positive (valid) and negative (invalid) test cases. By performing property-level mutations—negating exactly one constraint at a time—the system can pinpoint exactly which protocol rule a parser fails to enforce.
Phase 3: Traceability-Assisted Identification
When a parser's behavior contradicts the generated specification, ParCleanse "backtraces" the constraint to the original RFC section. The LLM then re-evaluates the discrepancy to distinguish between a genuine implementation bug and an extraction error, effectively creating a self-refining oracle.
Evaluation and Key Results
ParCleanse was evaluated against nine network protocols (including BGP-4, IPv6, and TCP) across implementations in C, Go, and Python.
- High Accuracy: The framework achieved 100% precision in identifying message types and 99% precision for field names.
- Bug Discovery: The tool detected 69 unique bugs, 36 of which have already been confirmed by developers. In the FRRouting project, ParCleanse found 33 unique bugs, significantly outperforming state-of-the-art differential testers like ParDiff, which found only 4.
- Semantic Depth: By focusing on logic constraints (e.g., "this field MUST NOT be all zeros"), ParCleanse identifies deep semantic vulnerabilities that could lead to routing loops or security bypasses.
Conclusion and Future Work
ParCleanse demonstrates that hierarchical document interpretation is a powerful tool for protocol validation. By mirroring the structure of RFCs, the system handles complex specifications that would otherwise lead to LLM logic failures. Future work will focus on addressing implicit "industry standard" constraints (like bit-level alignment) and expanding the framework to handle stateful protocol logic beyond stateless packet parsing.
Summary updated