TL;DR
The paper introduces agentic model checking, a novel verification paradigm that pairs LLM agents with bounded model checking (BMC) solvers under the philosophy: agents propose, solvers verify. By delegating semantic judgment (like inferring specifications and auditing counterexamples) to LLMs while leaving soundness decisions to deterministic solvers, the system automatically uncovers deep safety and functional bugs in complex C and Rust codebases without requiring manual annotations.
What Problem Does This Paper Address?
Large Language Models (LLMs) are increasingly used to generate low-level systems code (e.g., kernels, drivers, compilers). However, verifying this code is notoriously difficult. Systems code often lacks formal specifications, and safety contracts are typically encoded implicitly at call sites rather than explicitly enforced at function boundaries.
Traditional formal verification tools struggle here: bounded model checkers suffer from state-space explosion on large codebases, and deductive verifiers require massive manual effort to write specifications. Conversely, LLM-only verification pipelines can explain code but are notoriously unsound for arithmetic and memory safety. This paper bridges the gap by combining the semantic flexibility of LLMs with the rigorous guarantees of hardware-proving solvers.
Methods
The authors introduce BMC-Agent, an automated pipeline that splits labor between LLM agents and deterministic verification backends (CBMC for C, Kani for Rust).
The core architecture relies on four main pillars:
- Top-Down Specification Inference: An LLM agent traverses the program's call graph top-down, generating function pre- and postconditions in a restricted Domain-Specific Language (DSL) that translates directly into solver
assumeandassertprimitives. - Compositional Verification: Instead of analyzing the whole program at once, BMC-Agent checks each function in isolation. Stub functions replace actual callees, constrained by the LLM-inferred postconditions. This keeps the state space small and allows parallel processing.
- Multi-Stage Validation Pipeline: Counterexamples generated by the solver aren't immediately reported as bugs. They pass through a four-stage pipeline: checking input reachability, callee feasibility, dynamic host-side replay (compiling a GCC harness to catch real signals like
SIGSEGV), and an LLM-driven realism audit. - Specification-Level CEGAR Loop: If a counterexample is deemed "spurious" (a modeling artifact rather than a real bug), the LLM refines and tightens the function's preconditions, and the solver re-runs the check.
Datasets
The approach was evaluated across four distinct corpora spanning both C and Rust:
- VibeOS: A 15,000-line, LLM-generated bare-metal ARM64 hobby operating system written in C.
- Mature OSS Libraries: Five heavily fuzzed C libraries from the OpenSSF Internet Bug Bounty corpus (
jq 1.8.1,OpenSSL master,libcurl,libxml2 2.16.0, andprotobuf upb). - Realtek r8125 Linux Driver: An out-of-tree Linux network driver (C).
- claudes-c-compiler (CCC): A 50,000-line C compiler and ELF linker generated entirely by Claude in Rust.
Key Insights and Ideas
- The "Implicit Contract" Anti-Pattern: A fascinating finding is that LLM-generated systems code consistently implements safety checks implicitly at call sites (e.g., inside loops or caller validation logic) but leaves helper functions exposed without bounds or overflow guards.
- Agents Propose, Solvers Verify: By forcing every LLM output through a deterministic check (a DSL parser, a solver query, or concrete execution), the system eliminates the hallucination problem inherent to LLMs while exploiting their strength in semantic reasoning.
- Counterexamples are Not Bug Reports: In systems verification, many solver-generated counterexamples are just artifacts of incomplete environment models. The paper's multi-stage validation pipeline successfully separates active in-tree crashes from latent API vulnerabilities.
Key Results
BMC-Agent successfully uncovered 62 total real bugs across the evaluated codebases:
- VibeOS: Confirmed 34 realistic bugs (including integer overflows in
mallocandhal_dma_fb_copy, and null pointer dereferences). 16 of these were dynamically reproduced as runtime faults. - claudes-c-compiler (CCC): Discovered 25 real bugs in the Rust codebase, primarily panic-class defects on public-API byte helpers, alongside a functional-correctness violation in an alignment helper (
align_up) that silent overflow protections missed. - Real-World OSS: Found 2 pointer-arithmetic undefined-behavior defects in
jq, which were subsequently filed as official security advisories (GHSA). - Positive Verification: On highly hardened codebases like OpenSSL ASN.1 and
libxml2, the pipeline successfully cleared dozens of functions as verified clean, demonstrating its ability to prove the absence of bugs within bounded limits.
Limitations and Future Work
- Reliance on LLM Spec Accuracy: If the LLM generates an over-weak specification, bugs can be missed silently. The pipeline cannot self-detect uniformly permissive specs that yield no counterexamples.
- Unwinding Bounds: The system defaults to a loop unwinding bound of $k=4$. Bugs that require deeper loop iterations to manifest will go undetected.
- Token Costs: Running entire codebases through multi-stage LLM prompts can be expensive.
Future Directions: The authors plan to scale up quantitative evaluations, implement "spec triangulation" across multiple LLM sources to improve accuracy, and optimize token costs by reusing spec stores across iterative codebase sweeps.
Summary updated