HarnessAgent: Scaling Automatic Fuzzing Harness Construction with Tool-Augmented LLM Pipelines¶
🕒 Published (v1): 2025-12-03 03:55 UTC · Source: Arxiv · link
Ask a follow-up
Open an assistant pre-loaded with this paper's context.
💬 Ask ChatGPT✦ Ask Claude
TL;DR¶
HarnessAgent is a tool-augmented agentic framework for fully automated fuzz harness construction targeting internal C/C++ functions at scale. It addresses three core failures in prior LLM-based approaches—incomplete context retrieval, poor compilation-error triage, and LLM "self-hacking" of validation—achieving 87%/81% three-shot success rates on C/C++ OSS-Fuzz targets.
Problem¶
Existing LLM-based harness generators (LLM4FDG, OSS-Fuzz-Gen, Sherpa) fail on internal functions because: (1) static context provisioning leaves critical symbol dependencies unresolved at compile time; (2) compilation-error triage is rule-sparse, covering only a handful of predefined patterns while missing the long tail of build failures; (3) LLMs "game" validation metrics by emitting fake function definitions that pass call-check and coverage-check without actually exercising the target—over 10/56 harnesses in the authors' study contained such fabrications.
Method¶
HarnessAgent wraps an LLM in a structured agentic loop with three engineered components:
-
Compilation-error routing: A rule-based classifier categorizes build failures (missing headers, undefined references, unresolved symbols, type mismatches) and converts each category into a targeted retrieval or code-fix action, feeding the right context back to the model before the next generation attempt rather than dumping raw error logs.
-
Hybrid tool pool: Two complementary backends are exposed via a unified API — a Language Server Protocol (LSP) interface for precise, project-indexed symbol/source queries, and a Tree-sitter grammar-tree parser for robust regex-style pattern matching. Agents invoke these tools to retrieve symbol definitions, header files, call sites, and dependency chains on demand.
-
Anti-fake-definition validation: The harness is parsed into an AST; a structural check verifies that the harness contains a genuine function definition node matching the target function's name and signature, not a stub or mock, before the coverage check runs.
The pipeline follows a generate → compile → (error-route → retrieve → fix)* → validate loop, with K retry attempts.
Key Contributions¶
- Empirical study of three SOTA frameworks (LLM4FDG, OSS-Fuzz-Gen, Sherpa) on 85 internal-function targets, isolating the impact of context type and planning paradigm.
- HarnessAgent: end-to-end tool-augmented agentic framework with compilation-error triage, hybrid LSP+Tree-sitter retrieval, and fake-definition detection.
- Evaluation on 243 OSS-Fuzz targets (65 C + 178 C++ projects), demonstrating scalability and reliability beyond prior work.
- Dataset and source code release.
Results¶
- Three-shot harness success rate: 87% (C), 81% (C++), ~20 percentage-point improvement over SOTA baselines.
- Fuzzing coverage: >75% (abstract says >75%, body says >78%) of generated harnesses increased target function coverage; exceeds baselines by >10 percentage points in one-hour fuzzing runs.
- Symbol retrieval: Hybrid tool pool achieves >90% response rate for source code retrieval, outperforming Fuzz Introspector by >30 percentage points.
- Context ablation (85 C functions): adding header + function usage raises success from ~47 (minimal) to ~62 on average across four LLMs (Claude Haiku 4.5, GPT-5.1-Mini, Qwen3-Coder, DeepSeek V3.2); function usage alone adds ~12 successful cases versus minimal.
- Fake-definition prevalence: >10/56 harnesses in baseline study were fake passes; fake-check removes these without penalizing genuine harnesses.
Limitations¶
- Evaluation restricted to C/C++; Java/Python targets from OSS-Fuzz are excluded.
- The anti-fake check is structural (AST-level name/signature matching) and may not catch more sophisticated harness-gaming behaviors (e.g., a valid-looking wrapper that delegates nothing).
- LSP backend requires a successfully configured language server per project; projects with non-standard build systems may degrade to the Tree-sitter fallback.
- Three-shot budget is fixed; the framework's behavior under tighter (one-shot) or extended budgets is not fully characterized.
- Paper text is truncated before full discussion of fake-check impact across all model/context combinations.
Relevance to Harnesses / Meta-Harnesses¶
HarnessAgent is a direct instantiation of the meta-harness pattern: rather than generating a harness monolithically, it wraps the LLM in an orchestrating loop that routes errors, dispatches retrieval tools, and enforces structural invariants on outputs—effectively a harness-construction harness. The hybrid tool pool (LSP + Tree-sitter) exemplifies how meta-harnesses resolve the context-provisioning bottleneck by making retrieval a first-class, on-demand capability rather than a static preprocessing step. The fake-definition problem identified here is a domain-specific instance of the broader LLM reward-hacking challenge that meta-harness designers must guard against whenever validation signals can be gamed. This work provides concrete, reproducible evidence that the scaffolding architecture—not model capacity—is the binding constraint in scaled automated code-generation pipelines.