An LLM Agent for Functional Bug Detection in Network Protocols

Mingwei Zheng, Chengpeng Wang, Xuwei Liu, Jinyao Guo, Shiwei Feng, Xiangyu Zhang · DOI

Introduction

Network protocols, such as DHCP, BFD, and Babel, serve as the fundamental building blocks of modern internet infrastructure. These protocols are defined by extensive and complex documents known as Requests for Comments (RFCs). While traditional software testing tools like fuzzers are effective at identifying memory safety issues or crashes, they often fail to detect functional bugs—logic errors where the implementation deviates from the official RFC specification.

Detecting these semantic gaps is a significant challenge. Formal verification requires manual translation of natural language specifications into mathematical logic, which is labor-intensive and difficult to scale. RFCAUDIT is introduced as the first autonomous LLM-based agent designed to bridge this gap by understanding both the natural language of RFCs and the intent of source code to identify functional inconsistencies.

Methodology: The RFCAUDIT Framework

RFCAUDIT operates through a collaborative multi-agent system designed to mimic the workflow of a human auditor. The system architecture consists of two primary components: the Indexing Agent and the Detection Agent.

The RFCAUDIT architecture featuring the Indexing and Detection Agents.

The Indexing Agent

To handle large-scale codebases without exceeding the context limits of Large Language Models (LLMs), RFCAUDIT employs a "bottom-up" indexing strategy. The Indexing Agent summarizes functions, files, and directories into concise natural language descriptions, creating a Hierarchical Semantic Index. This index allows the system to navigate the codebase efficiently, mapping high-level RFC requirements to specific code locations.

Example of the Indexing Agent generating a hierarchical semantic map from source code.

The Detection Agent

The Detection Agent follows an iterative state-machine logic to identify bugs:

  1. Localize: It uses the semantic index to pinpoint functions relevant to a specific RFC requirement.
  2. Detect: It performs a side-by-side comparison between the code and the RFC text.
  3. Retrieve: If additional context is needed (e.g., understanding a called function's behavior), the agent uses symbolic tools to fetch relevant code on-demand.
  4. Validate: To minimize hallucinations, a self-critique step reviews the reasoning to confirm if a detected violation is a genuine bug.

Experimental Evaluation

The authors evaluated RFCAUDIT using six major open-source protocol implementations from the FRRouting and lwIP stacks, including Babel, BFD, NHRP, RIPng, DHCP, and IGMP. The implementations ranged from 5.2K to 17.3K lines of code (LoC). Additionally, the system was stress-tested on industry-scale stacks like aws-c-http (74K LoC) and the Linux TCP/IP stack (~190K LoC).

Key Results and Insights

RFCAUDIT demonstrated remarkable efficacy in real-world scenarios:

  • Bug Discovery: The agent identified 83 inconsistencies, resulting in 47 unique functional bugs. Notably, 40 of these were "zero-day" vulnerabilities. At the time of publication, 20 bugs had already been confirmed or fixed by developers.
  • High Precision: The system achieved an overall precision of 81.9%. The self-critique validation step was particularly effective, reducing false positives by 71.7%.
  • Performance Comparison: RFCAUDIT significantly outperformed general-purpose AI coding assistants like GitHub Copilot, which suffered from high false-positive rates (averaging 77.5%) and missed deeper logic errors.
  • Cost Efficiency: The average cost to audit an entire protocol implementation was approximately $5.03 in API tokens, highlighting the scalability of the approach.

Discussion and Future Work

While RFCAUDIT represents a significant advancement, it faces certain limitations. Its performance is tied to the quality and structure of the RFC; ambiguous specifications can lead to difficulties in extracting mandatory properties. Furthermore, while rare, the LLM can occasionally misinterpret complex pointer arithmetic or control flows.

Future research will focus on expanding RFCAUDIT to other domains with rich documentation, such as cloud APIs and OS kernel interfaces. The authors also plan to refine the agent's ability to distinguish between "mandatory" and "optional" requirements within technical specifications to further improve detection accuracy.

Summary updated

BibTeX
@misc{zheng2025llm,
  author = {Mingwei Zheng and Chengpeng Wang and Xuwei Liu and Jinyao Guo and Shiwei Feng and Xiangyu Zhang},
  title = {{An LLM Agent for Functional Bug Detection in Network Protocols}},
  year = {2025},
  eprint = {2506.00714},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.00714},
}
Figure