Manuscript Offprint

arXiv:2610.40721

MetaVul: Agentic Harness Discovery for Vulnerability Detection

Ira Ceka, Arnav Garg, Ryan Lutz, Ting Zhang, Ratnadira Widyasari, Gail Kaiser, Baishakhi Ray

ABSTRACT

Large Language Model (LLM) agents are increasingly used to automate vulnerability detection, but reliable detection is challenging because agents must distinguish subtle, security-relevant fixes from benign code variation. While underlying LLM capability has improved significantly, the accuracy of the agent still depends heavily on the harness: the code that defines the scaffolding around the LLM. Harnesses are typically fixed, and largely hand-written, limiting adaptation to evaluator feedback. Additionally, when harnesses are static, improvements on one dataset or model may not necessarily transfer to others. To address these challenges, we introduce MetaVul, a self-improving framework for harness discovery in vulnerability detection. Starting from a seed structured reasoning scaffold, MetaVul uses a workflow-based optimization loop to iteratively refine the harness using feedback from paired vulnerable and patched functions, all while preserving the structured reasoning and verdict format. At each iteration, it searches over the full history of prior candidate harnesses, with access to their trajectories, logs, and metrics, and it returns a set of Pareto-optimal harnesses rather than a single best candidate. We apply MetaVul to discover agent harnesses for architectures including Codex CLI and Claude Code. A validation set (202 pairs) from TitanVul and CWEval is used for optimization, while the unseen PrimeVul dataset (430 pairs) is kept as the held-out set. We later test whether harnesses learned from one model transfer to others not seen during optimization. Results on both frontier and small LLMs show that the optimized harnesses improve pairwise vulnerability detection up to 23.3 percentage points on the validation set (Opus 4.6) and up to 25.8 points on the held-out set with a Pareto-frontier harness (DeepSeek V4 Flash). Harnesses learned with one model also transfer to others. We show that harnesses optimized with Opus 4.6 transfer to Opus 5, improving held-out pairwise accuracy by 14.7 points without the need for further optimization. Code is available at https://github.com/ARiSE-Lab/MetaVul (ARiSE Lab, 2026).

1 INTRODUCTION

Artificial intelligence (AI) agents utilize a large language model (LLM) as their core reasoning component for taking actions toward a given goal. “Vibe coding,” or using AI tools, particularly by way of coding agents, is becoming increasingly prevalent across the software industry. Consequently, the growing volume and pace of AI-assisted code generation increase the importance of effective vulnerability detection. LLM agents rely not only on the capabilities of their underlying model, but also on the harnesses that structure how those agents reason, interact with tools, and arrive at a decision. Designing these harnesses, known as harness engineering, has become a practice of its own (Lopopolo, 2026; Rajasekaran, 2026). For vulnerability detection, these harnesses are typically hand-designed and are fixed during deployment, even though their structure and context can substantially alter an agent’s results. In practice, vulnerability detection is substantially affected by how the agent inspects the code, and how the harness will shape that workflow (Yildiz et al., 2025).

This understanding directly motivates a harness that can learn its design systematically through evaluation feedback.

Recent work studies the evaluation, evolution, and adaptation of agent harnesses using graded scores, verifiers, execution traces, or prior experience (Lee et al., 2026; Ursekar et al., 2026; Huang et al., 2026a; Zhang et al., 2026; Huang et al., 2026b; Esakkiraja et al., 2026; Nie et al., 2026), while OneDayAgent develops a fixed long-horizon harness (Zheng et al., 2026); however, none investigates harness optimization for vulnerability detection or incorporates security-specific objectives such as CWE identification, vulnerability localization, and vulnerable-patched discrimination. Harness engineering for vulnerability detection, however, poses challenges.

Firstly, false alarms are costly. In practical security settings, analysts receive far more alerts than they can effectively triage. Several industry studies identify alert fatigue and analyst burnout as major problems (Tariq et al., 2025). This problem is well documented among traditional vulnerability-detection tools (Charoenwet et al., 2024; Sajadi et al., 2026) and persists with recent LLM-based detectors (Li et al., 2026a). As recently as April 2026, an independent security company reported poor discriminative performance on PrimeVul (Ding et al., 2024)¹; even Claude Opus 4.6, a flagship model shown by Anthropic to discover previously unknown vulnerabilities Carlini et al. (2026), struggled to reliably distinguish vulnerable functions from their patched counterparts (Walker, 2026). These findings further our motivation and demonstrate the outstanding and relevant nature of vulnerability discrimination, which remains an open and significant problem in practice. Moreover, these findings reinforce the notion that strengthening the underlying models does not eliminate the need for a robust design surrounding the agentic workflow. Rather, harnesses and their associated design choices matter as they directly affect downstream behavior.

Secondly, harness optimization is non-trivial. A vulnerability detection harness controls how an agent inspects code, how it structures its analysis, and how it reasons about security. Vulnerability detection as a task, however, poses a multi-objective challenge. A strong harness not only has to accurately classify vulnerabilities, but also localize them, identify their CWE(s), ground the conclusions in code evidence, as well as distinguish the vulnerable functions from their patched counterparts. Ding et al. (2024) show why traditional classification metrics, such as accuracy and F1, are insufficient on their own: models that perform well on conventional benchmarks approach random guessing on PrimeVul's paired evaluation. Optimizing for a single metric may therefore reward superficial patterns rather than robust vulnerability reasoning. HarnessDev (Wu et al., 2026) shows that a harness can overfit to the model that wrote it, memorize development examples, or improve one capability while silently regressing another. It can also overfit its search tasks: Wang et al. (2026) found that, when harness evolution and evaluation share the same tasks, the resulting improvements largely disappear on held-out tasks, which suggests that optimization can learn task-specific shortcuts rather than generalizable harness improvements.

Finally, defense must keep pace with AI-driven offense. With the rise of AI-driven exploit generation, attackers are moving at immense speed. In October 2026 alone, two critical PHP vulnerabilities were disclosed after AI-assisted research revealed that a 14-year-old memory-safety flaw in the PHP runtime engine allowed unauthenticated attackers to execute malicious code remotely on servers hosting PHP-based web applications, triggering a global security crisis (Wiz Research, 2026). These attacks involve auditing millions of lines of code, mapping out reliable exploit strategies, and adapting to multiple configurations. While offensive security is bottlenecked by compute, defense has another challenge to tackle: to survive this offensive scale, defenders must automate triage and blocking, but doing so can be catastrophic due to the false positives mentioned previously. It is thus paramount for defense to have scalable methods for identifying suspicious code and evaluating, triaging, and applying potential fixes quickly.

We address these challenges with MetaVul, which improves vulnerability detection through iterative harness construction, driven by validation feedback. The “meta” in MetaVul comes from the way MetaVul finds better ways to find vulnerabilities, with the optimizer and detector operating on two different levels: the optimizer designs the harness, and the detector uses it. A sandboxed detection agent evaluates each candidate harness during the discovery phase, and MetaVul returns a Pareto frontier of harnesses that trade off discrimination and localization ability. The discovered harnesses

¹ Following PrimeVul, we adopt pairwise accuracy as a core metric alongside accuracy and F1. High pairwise accuracy indicates that the detector can distinguish vulnerable code from its fixed version, reducing false alerts and, consequently, alert fatigue. We explain this further in Sec. 4.2.

are then evaluated against held-out datasets and unseen models, hence testing generalization. We ask whether MetaVul improves vulnerability-detection harnesses and whether the gains transfer to unseen data and unseen models (RQ1). We then evaluate how MetaVul compares with other LLM-based or multi-agent vulnerability detection methods (RQ2). Finally, we ask whether MetaVul's gains rely on "shortcut" exploitation, like data leakage signals, embedded answers, or trivial verdict bias (RQ3). We find that MetaVul improves pairwise accuracy by 11.4 to 23.3 points (1.6×-4.3×) on validation and by up to 25.8 points (2.9×) on 430 unseen PrimeVul pairs. Harnesses also transfer to models that took no part in optimization, with gains up to 14.7 points (1.7×). MetaVul outperforms prior LLM-based and multi-agent detectors and does so without evidence of "shortcut" exploitation.

References (31)