Abstract
Static bug detection tools are essential for securing large-scale software but suffer from high false positive rates, often exceeding 90% in complex systems like the Linux Kernel. This paper presents LLM4PFA, an iterative framework that combines the intuitive reasoning of Large Language Models (LLMs) with the formal rigor of Satisfiability Modulo Theories (SMT) solvers. By decomposing inter-procedural path feasibility into localized, function-by-function symbolic reasoning tasks, LLM4PFA effectively filters out 72% to 96% of false alarms while maintaining a high recall (0.93) of real bugs.
Introduction: The Challenge of Path Feasibility
Static analyzers like CodeQL or Infer are widely used to identify vulnerabilities without code execution. However, their utility is often hampered by "noise"—a high volume of false positives. In the Linux Kernel, for instance, the vast majority of reported bugs are unreachable in practice.
The core difficulty lies in path feasibility: proving that an execution path exists from a "source" (e.g., a null assignment) to a "sink" (e.g., a pointer dereference). Traditional tools struggle with complex logical dependencies and inter-procedural analysis, where the number of potential execution routes explodes across multiple function calls.
Methodology: The LLM4PFA Framework
To address these challenges, the authors developed LLM4PFA, which breaks down the analysis into an iterative, agent-driven process.
1. Iterative Function-by-Function Analysis
Rather than analyzing an entire call trace at once, LLM4PFA proceeds function-by-function. It identifies "critical path" branches—conditions that must be satisfied to reach the bug—and extracts them for localized analysis. This prevents the "lost in the middle" issue common when LLMs are presented with excessive context.
2. Agentic Symbolic Reasoning
LLM agents act as simulated executors, analyzing focused code segments to determine variable ranges and function return values. When encountering deep dependencies, the agent uses a "Function Retrieval Tool" to fetch necessary context dynamically, mimicking a human developer's triage process.
3. Formal Constraint Solving
The framework translates extracted logic into SMT query scripts for the Z3 solver. This step ensures that the LLM's "intuition" is verified by formal logic. If the solver finds a path to be unsatisfiable (UNSAT), the bug report is immediately discarded.
Evaluation and Results
The framework was evaluated using SAFP-BENCH-C, a new benchmark of 364 bug warnings from real-world projects like the Linux Kernel, OpenSSL, and Libav, manually labeled by experts.
- Precision and Recall: LLM4PFA achieved a False Positive Reduction Recall (FPR_R) of 72% to 96% across various bug types (e.g., Null Pointer Dereference, Use-After-Free). Crucially, it maintained a high recall of 0.93, missing only 3 out of 45 real bugs.
- Comparative Performance: It outperformed state-of-the-art baselines like LLM4SA and LLMDFA by 41.1% to 105.7%.
- Robustness: The performance remained consistent across different backbone models, including GPT-4o-mini, Claude 3.5 Sonnet, and Qwen2.5-Coder.
Discussion and Conclusion
The success of LLM4PFA highlights that decomposition is key to applying LLMs to complex software engineering tasks. By isolating symbolic reasoning and verifying it with formal solvers, the system gains the intuition of an LLM and the rigor of formal methods.
While highly effective, the system's limitations include potential errors in initial Control-Flow Graph (CFG) extraction and computational costs associated with iterative LLM calls. Future work may explore fine-tuning smaller, local models to reduce latency and cost while maintaining the reasoning capabilities required for high-precision bug detection.
Summary updated