arXiv(opens in a new tab)cs.CRSep 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2609.04075

PatchBench: Evaluating AI Agents for Vulnerability Patching

Chihao Shen, Jiacheng Li, Aastha Mahajan, Jeffery Siyuan Tian, Yonghwi Kwon, Yizheng Chen

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

AI agents have recently demonstrated strong performance in automated vulnerability patching. However, existing evaluations often validate a patch only by testing whether the provided Proof-of-Concept (PoC) input still triggers a crash. This leaves two key threats to validity: agents may reproduce memorized historical developer patches, or they may generate surface-level fixes that only suppress the reported crash.

We study these concerns for C/C++ vulnerability patching. We introduce a patch similarity metric to detect memorized patches. On average, 25% of the agent patches exhibit substantial similarity to historical developer patches, indicating that patch memorization is a real threat to the validity of vulnerability patching evaluations. Meanwhile, agents also frequently exploit benchmark structures to pass patch validation by patching on the crash stack trace to suppress the crash, rather than localizing and fixing the root cause of the vulnerabilities.

To handle these issues, we propose PATCHBENCH, a new benchmark for evaluating AI agents on realistic vulnerability patching tasks. PATCHBENCH selects vulnerabilities whose ground-truth fixes lie outside the crash stack and uses vulnerability transplant and code mutations to migrate historical vulnerabilities into new repository contexts, reducing the risks of surface-level fixes and patch memorization. We develop new patch validation methods that thoroughly evaluate both security and semantic correctness of agent patches. Across 11 state-of-the-art agents, including the top three AIxCC agents, the original PoC-only validation inflates the patching task solve rate of agents by 1.83×1.83 \times on average. Our results reveal key limitations of current patching agents and point to future research directions for more reliable vulnerability repair.

1 Introduction

Patching software vulnerabilities is a crucial, yet expensive and time-consuming security task. Unpatched software vulnerabilities in systems can cost organizations millions of dollars annually [30] when exploited by adversaries. According to Project Zero [46], security vendors took 52 days on average to fix vulnerabilities in 2021. Recent advances in AI agents have shown a promising path toward automated software vulnerability patching, demonstrated by the AI industry [2, 38] and academic events such as the AI Cyber Challenge (AIxCC) [8]. However, rigorous evaluation of AI-assisted patching remains a relevant and challenging problem.

This paper focuses on evaluating AI agents for patching software vulnerabilities, tackling two aspects: memorization of historical security patches and shallow, surface-level patches. First, LLMs underlying the AI agents often memorize their training data [5, 6, 64], which likely contain bug reports and developer-written patches to known vulnerabilities [24, 43]. Hence, evaluation using known vulnerabilities [27] may end up testing memorized knowledge extraction, instead of agents' analysis and patching capabilities. Note that AIxCC has 63 manually written synthetic vulnerabilities (40 in C and 23 in Java) [70] to mitigate the memorization issue. Unfortunately, such a manual effort is expensive and not scalable for evaluating AI agents that patch vulnerabilities across diverse real-world projects.

Second, prior automatic patch validation methods fail to assess the semantic correctness of agent patches. Prior work often relies on testing against a few inputs, such as Proof-of-Concept (PoC) inputs and project-level functional test cases. Hence, they often fail to validate incomplete, surface-level fixes, frequently generated by agents that take shortcuts and guess at solutions [20]. Worse, they also fail to identify patches altering critical functionalities (e.g., patching by removing functionality containing vulnerabilities), leading to inflated performance. A study [70] reveals that Team Atlanta of AIxCC and Claude Code can pass all automatic patch validation, but 16% to 38% of patches they generated are still semantically incorrect.

In this paper, we first focus on measuring the impact of LLM memorization on patching. Specifically, we study the extent to which security patches are memorized by LLMs and how this affects AI agents. Note that while prior works have explored LLMs memorizing bug benchmarks [24, 43], their methods focus on function-level program repair tasks, which are not directly applicable to general security patching at the repository level. To this end, we develop a new similarity metric that aims to detect memorized patches generated by LLMs. We then conduct a study under two distinct settings using the state-of-the-art vulnerability patching benchmark SEC-BENCH [27] containing 300 patching tasks in C/C++: (1) local-context LLM-based patching and (2) repository-level agent-based patching. Surprisingly, we find that agents Codex, Claude Code and OpenHands produce a higher proportion of likely memorized patches, compared to the underlying LLM alone. Specifically, we find that an average of 25% of agent patches are extremely similar to, if not the same as, the historical ground-truth patches written by developers. We hypothesize that agent scaffolds provide better code context, which could enable the underlying LLM to produce more memorized content.

Moreover, we observe that AI agents' patches frequently appear in functions on the crash stack trace, regardless of the vulnerable code's location. Overall, 81% of Codex + GPT-5.6 Sol's patches modify functions on the crash stack trace. Even when the root cause of the vulnerability is not located in the functions in the crash stack trace as indicated by the historical developer patch, 64% of such agent patches are still found in functions on the trace. These patches may only suppress the crash of a single PoC but do not fix the root cause of the vulnerability. Therefore, PoC input-based benchmarks (e.g., in SEC-BENCH) cannot precisely reflect the patches' validity.

To this end, we propose a rigorous vulnerability patching benchmark PATCHBENCH, which comprehensively evaluates the capabilities of AI agents in generating quality security patches, including 213 patching tasks across 16 CWEs and 32 real-world projects. Specifically, to tackle AI agents relying on the crash stack trace for localizing vulnerabilities, we focus on vulnerabilities whose ground-truth patches do not appear in functions of the crash stack trace. They help differentiate agents that take shortcuts from those that conduct localization. In addition, to measure agents' capability beyond patch memorization, we transplant historical vulnerabilities to newer versions of their repositories and mutate the code at the patch sites, so that agents face unseen context and cannot reproduce a historical patch verbatim. Finally, we manually audit the reference patch of every task. We find that commits labeled as security fixes do not always eliminate the root cause, and many carry code changes unrelated to the vulnerability [15, 18]. We therefore discard tasks of the former kind and strip the unrelated changes from the latter, so that the reference patch of each task is a manually curated fix for the root cause rather than the original developer patch.

Furthermore, we validate patches in both security and semantic aspects. Our security validation checks whether a patch eliminates the target vulnerability on fuzz-generated crashing inputs in the vulnerable repository, while our se-

Figure

Figure 1: The top three agents achieve Single-PoC pass rates above 97%, while their pass rates drop to 75–82% after security validation with multiple PoCs, and to roughly half with additional semantic validation, which checks whether patches preserve intended program behavior.

mantic validation checks whether a patch preserves expected behavior on benign inputs and project unit tests against the reference-patched repository. A patch is considered semantically valid if and only if it satisfies all three of the following conditions: (1) The agent-patched repository does not trigger sanitizer errors on benign inputs. (2) The program-level output state on benign inputs match that of the reference-patched repository. (3) It passes all working unit tests from the reference-patched repository. Compared to our work, the most comprehensive patch validation techniques from AIXCC teams do not use program-level output state validation for benign inputs, and not all teams check multiple PoCs, which could lead to semantically incorrect patches [70].

We evaluate PATCHBENCH on 11 state-of-the-art patching agents, including the top three AIXCC agents [8] and 8 general-purpose agents spanning commercial scaffolds, such as Codex [39] and Claude Code [1], and an open-source scaffold, OpenHands [55], with different large language models. As shown in Figure 1, PoC-only validation inflates solve rates by 1.83x on average, and even the strongest agents are affected: the top three pass over 97% of the original PoCs but solve roughly half of tasks under our Security + Semantic Validation. We observe that the current patching agents frequently fail to preserve functional correctness on valid inputs. PATCHBENCH contains 67 patching tasks that are not solved by any of the 11 agents, regardless of the patching budget allocated to LLMs (performance plateaus well before a 5× budget cap; see Section 5.2). We make the following contributions:

  • We study security patch memorization of AI agents and large language models, using a new patch similarity metric. We find that memorization is a critical challenge for the evaluation of patching agents.
Developer Patch@@ -1283,0 +1283,5 @@ fasthuf_initialize (+ if (currByte >= topByte) {+ if (pctx) + pctx->print_error(..., "Error decoding ...");+ return EXR_ERR_CORRUPT CHUNK;+ }Agent Patch@@ -1283,0 +1283,5 @@ fasthuf_initialize (+ if (currByte >= topByte) {+ if (pctx) // Avoid reading past ...+ pctx->print_error(..., "Fail to ...");+ return EXR_ERR_CORRUPT CHUNK;+ }
@@ -1300,1 +1305,1 @@ fasthuf_initialize (- for (int i = 0; i < MAX_CODE_LEN; ++i)+ for (int i = 0; i <= MAX_CODE_LEN; ++i)

Figure 2: Comparison between the developer patch and the agent patch for OSS-Fuzz bug 42517450 in openexr. Codex generates a patch that matches the developer patch at the same program location and introduces the same guard condition, despite superficial textual differences in the comment, error message, and an additional diff hunk.

  • We propose PATCHBENCH, a new benchmark to evaluate AI agents for patching C/C++ vulnerabilities, that mitigates the vulnerability memorization issue.

  • We propose patch validation techniques, comprehensively covering both security and semantic validation.

  • We thoroughly evaluate 11 state-of-the-art patching agents including commercial agents and top three AIxCC agents. Our results reveal bottlenecks and provide insights for developing stronger patching agents.

  • We release our code and benchmark at https://github.com/ai-sec-lab/PatchBench.

References (58)

  • SWE-Search: Enhancing software agents with Monte Carlo tree search and iterative refinement
  • KLEE: Unassisted and automatic generation of high-coverage tests for complex systems programs
  • Quantifying memorization across neural language models
  • naturalizing
  • AFL++: Combining incremental steps of fuzzing research
  • Verifying security patches
  • Beyond tests: Program vulnerability repair via crash constraint extraction
  • Time travel in LLMs: Tracing data contamination in large language models
  • Magma: A ground-truth fuzzing benchmark
  • Large language models for code: Security hardening and adversarial testing
  • Seed selection for successful fuzzing
  • SoK: Automated vulnerability repair: Methods, tools, and assessments
  • Evocatio: Conjuring bug capabilities from a single PoC
  • Defects4J: a database of existing faults to enable controlled testing studies for Java programs
  • The missing infrastructure for AI agent evaluation
  • Automatic patch generation learned from human-written patches
  • PatchVerif: Discovering faulty patches in robotic vehicles
  • Logs in, patches out: Automated vulnerability repair via Tree-of-Thought LLM analysis
  • Demystifying memorization in LLM-based program repair via a general hypothesis testing framework
  • S3: Syntax-and semantic-guided repair synthesis via programming by examples
  • Every patch agent has its own story (1) — Martian: Exploring the unknown with sophisticated tools
  • SEC-bench: Automated benchmarking of LLM agents on real-world software security tasks
  • PatchPilot: A cost-efficient software engineering agent with early attempts on formal verification
  • SoK: Towards effective automated vulnerability repair
  • Navigating the AI rush without sidelining security
  • Marscode agent: AI-native automated bug fixing (opens arXiv in a new tab)
  • SPIDER: Enabling fast patch propagation in related software repositories
  • ARVO: Atlas of reproducible vulnerabilities for open-source software
  • National Vulnerability Database, 2015
  • APPATCH: Automated adaptive prompting large language models for real-world software vulnerability patching
  • BLEU: a method for automatic evaluation of machine translation
  • Examining zero-shot vulnerability repair with large language models
  • Symbolic execution with SymCC: Don't interpret, compile! In 29th USENIX Security Symposium (USENIX Security 20), pages 181–198, 2020
  • Are large language models memorizing bug benchmarks? In 2025 IEEE/ACM International Workshop on Large Language Models for Code (LLM4Code), page 1–8
  • CODEMORPH: Mitigating data leakage in large language model assessment
  • CodeBLEU: a method for automatic evaluation of code synthesis, 2020 (opens arXiv in a new tab)
  • A walk through Project Zero metrics
  • Localizing vulnerabilities statistically from one exploit
  • GitBug-Java: A reproducible benchmark of recent Java bugs
  • Anti-patterns in search-based program repair
  • OpenHands: An open platform for AI software developers as generalist agents
  • Sleuth: A switchable dual-mode fuzzer to investigate bug impacts following a single PoC
  • PATCHEVAL: A new benchmark for evaluating LLMs on patching real-world vulnerabilities, 2025 (opens arXiv in a new tab)
  • BenchChecker: Assessing the credibility of bug-fixing benchmarks for LLMs
  • VeriBin: Adaptive verification of patches at the binary level
  • Identifying test-suite-overfitted patches through test case generation
  • Leveraging syntax-related code for automated program repair
  • Identifying patch correctness in test-based program repair
  • SWE-agent: Agent-computer interfaces enable automated software engineering
  • Unveiling memorization in code models
  • Large language model unlearning
  • PATCHAGENT: A practical program repair agent mimicking human expertise
  • QSYM: A practical concolic execution engine tailored for hybrid fuzzing
  • Patching vulnerabilities with coding agents in 2026
  • SoK: DARPA's AI Cyber Challenge (AIxCC): Competition design, architectures, and lessons learned
  • AutoCodeRover: Autonomous program improvement
  • Fixing security vulnerabilities with agentic AI in OSS-Fuzz
  • FIXREVERTER: A realistic bug injection methodology for benchmarking fuzz testing