TL;DR
REPOAUDIT is a purely LLM-driven, compilation-free code auditing agent that mimics how human experts review large software repositories. By combining demand-driven graph traversal, localized program abstraction, and multi-perspective validation, it bypasses the context-window limitations and path-explosion problems that cripple standard LLM prompting. In testing, it uncovered 185 new bugs in high-profile open-source projects with high precision, costing just a few dollars per repository.
What Problem Does This Paper Address?
Finding critical vulnerabilities—like Null Pointer Dereferences (NPD), Memory Leaks (MLK), and Use-After-Free (UAF) errors—requires tracking how data flows across an entire software repository. Traditional static and dynamic analysis tools struggle here because they depend heavily on successful code compilation and execution, which is rarely guaranteed during active development.
While Large Language Models (LLMs) are great at understanding code snippets without compilation, they fail miserably when handed an entire repository. If you pass a whole codebase to an LLM, you run into context window limits, massive token costs, and severe hallucinations. Furthermore, repository-level code is essentially a massive graph of interconnected functions and statements. Trying to find bugs via direct prompting triggers a "path explosion" problem, where the number of possible execution paths grows exponentially, causing the LLM to lose track and report high rates of false positives.
Methods
REPOAUDIT solves this by abandoning the idea of feeding the whole repository to the LLM at once. Instead, it acts as an autonomous agent that navigates the codebase function-by-function on demand, mimicking a human auditor.
The system consists of three core components backed by an Agent Memory:
- The Initiator: Uses lightweight
tree-sitterparsing to identify potential bug sources (e.g., where a pointer is initialized toNULL). - The Explorer: Starting from a source, the Explorer queries the LLM to analyze one function at a time. It prompts the LLM to perform program abstraction (stripping away irrelevant code) and pointer handling to map out feasible data-flow paths. If the data-flow escapes the function boundary (via a return value or parameter), the Explorer dynamically follows the call graph to the next relevant function.
- The Validator: To eliminate LLM hallucinations, a dual-validation mechanism is used. First, a parsing-based tool ensures the LLM's reported data-flow aligns with the actual control flow. Second, the LLM is prompted to cross-examine the inter-procedural path conditions to ensure they are logically satisfiable and don't contradict each other.
An example of how REPOAUDIT tracks an NPD bug across multiple functions and files is illustrated below:
Datasets
The authors evaluated REPOAUDIT using two main datasets:
- Historical Benchmark: A collection of 15 real-world open-source projects (averaging 251,000 lines of code each) containing previously documented NPD, MLK, and UAF bugs.
- Wild Dataset: 9 actively maintained, high-profile open-source GitHub repositories spanning diverse domains, including
clickhouse-odbc,htop,nginx,memcached, andRedis.
Key Insights and Ideas
- Leveraging Local Strengths for Global Problems: LLMs are bad at global graph reasoning but remarkably good at localized intuition (like abstracting a single function or resolving pointer targets). REPOAUDIT structures the agent workflow so the LLM only ever has to reason within a single function scope at any given time.
- Demand-Driven vs. Exhaustive Analysis: Previous LLM-based static analyzers tried to generate data-flow summaries for every function in a repository. REPOAUDIT only analyzes functions on a need-to-know basis, following the active propagation of a suspected bug. This makes it orders of magnitude cheaper and faster.
- Neuro-Symbolic Synergy: Purely LLM-driven auditing suffers from hallucinations, while purely symbolic auditing suffers from rigid compilation requirements. By using lightweight syntax parsing to constrain and validate the LLM's semantic leaps, REPOAUDIT achieves industrial-grade precision without needing a compiler.
Key Results
REPOAUDIT was initially powered by Claude 3.5 Sonnet and compared against industrial tools and alternative LLM approaches:
- Accuracy: On the historical benchmark, it successfully reproduced all 21 known bugs and found 19 new ones, achieving a precision of 78.43%.
- Baselines: It significantly outperformed industrial static analyzers. Meta INFER only found 7 true bugs (and crashed on several projects due to compilation issues), while Amazon CodeGuru flagged 18 false positives and 0 true bugs. It also vastly outperformed naive single-function and multi-function LLM prompting baselines.
- Efficiency: Code auditing took an average of just 0.44 hours and cost $2.54 in API tokens per project.
- Real-World Impact: When deployed on active repositories, REPOAUDIT discovered 185 new bugs, of which 95 have already been confirmed by developers and 79 fixed.
- Reasoning Models: Upgrading the agent's brain to newer reasoning models like DeepSeek R1 and Claude 3.7 Sonnet pushed precision even higher, reaching 88.46% and 86.79% respectively.
Limitations and Future Work
Despite its success, REPOAUDIT has a few limitations:
- Source Sensitivity: The tool's token cost and execution time scale with the number of initial starting points identified by the Initiator. A repository with thousands of potential sources will see a steep rise in overhead.
- Bounded Context: To prevent infinite loops and excessive costs, the authors capped the inter-procedural analysis depth to 4 functions ($K=4$). Consequently, bugs buried across exceptionally long call chains may be missed.
Future work includes integrating compilation-free retrieval tools to better map out complex loops and branches, as well as fine-tuning smaller, open-source models specifically for the localized function abstraction tasks.
Summary updated