arXiv:2610.20245cs.CROct 2026

Manuscript Offprint

arXiv:2610.20245

P2Patch: Exploit-Guided Vulnerability Repair

Mohsen Iranmanesh, Sina Moradi Sabet, Sina Marefat, Ali Javidi Ghasr, Maxime Newman Nereyabagabo, Kousha Amouzesh, Jaivir Malhi, Vinci Velasco, Alex Chung, Mohammad A. Tayebi

Abstract

Large language models are increasingly deployed as autonomous agents for automated program repair, patching software vulnerabilities through multi-step reasoning and tool use. Yet these systems typically validate a patch against the same evidence used to construct it—a static alert, sanitizer trace, published exploit, or test suite. A patch that blocks that one piece of evidence can therefore look successful while remaining vulnerable to the same vulnerability with some variation. We present P2PATCH, a generative adversarial repair system that treats each patch as a new attack target. Starting from a normalized vulnerability finding, an exploitation agent constructs a reproducing proof of vulnerability (PoV), a patching agent repairs the program, and the exploitation agent then attacks the patched program for a distinct same-vulnerability exploit. Every successful exploit becomes a permanent repair requirement, and the final patch must block all PoVs accumulated during patching process, with construction-time PoVs kept strictly separate from held-out evaluation oracles. Across 101 C/C++ and Java CVE subjects, this adversarial loop surfaces a distinct confirmed exploit in 41% of runs after the patch has already blocked its original construction-time PoV. Against single-pass repair from the same finding using Claude Code, P2PATCH raises held-out fix-closed coverage from 78.1% to 84.7% and beyond-upstream coverage from 42.1% to 62.5%. Under the same held-out oracles, it also certifies more attack paths as blocked than recent state-of-the-art agentic repair systems on overlapping subjects. These results show that adversarial testing and independent security oracles expose repair gaps that one-shot validation misses.

1 Introduction

Automated vulnerability repair is only as reliable as the evidence used to guide and judge it. A static-analysis alert identifies a suspicious flow, but not necessarily the runtime conditions that make it exploitable [25, 27]. A sanitizer trace or proof of concept—an input that triggers a specific bug or flaw within a program—demonstrates one failing execution, but not every similar payload, encoding, entry point, or sibling path that should be blocked. A project test suite may preserve intended functionality, but it rarely defines the full security boundary. These signals are valuable but partial: they can explain why a revision merits repair without specifying what a complete repair must cover [21, 36].

These partial signals create an oracle-reuse problem. Automated repair systems often use one piece of evidence twice: first to guide patch construction, and then to decide whether the patch succeeded. A patch that blocks the supplied PoV, crashing input, sanitizer trace, or available test may therefore be accepted even if it only specializes to that evidence. This risk is well known in general program repair, where test-guided repair can overfit its construction suite [15, 33, 52, 66]. It is especially consequential for security repair: blocking one observed attack can be mistaken for resolving the underlying security issue. Recent vulnerability-repair evaluations likewise show that proof-of-concept plus functional-test validation can overestimate repair correctness [58, 60, 72].

Existing vulnerability-repair systems occupy several points in this design space. Some patch from vulnerable code, weakness semantics, and suspected locations, while others use crashing inputs, sanitizer reports, proofs of concept, or trace-derived triggers for localization, repair, and validation [13, 26, 29, 45, 51, 55, 71, 74, 76]. LoopRepair further iterates on vulnerable locations and taint-trace feedback [68]. These systems show that dynamic evidence and LLM agents can improve vulnerability repair, but their repair objective is typically fixed before patching begins: the system attempts to satisfy the same alert, crash, trace, or PoV after each repair attempt. The target does not adapt to the patched program.

We argue that vulnerability repair should be exploit-guided. Once a patch changes the program, the relevant question is not only whether the original PoV is blocked, but whether a distinct exploit can falsify the security claim that accepting the current patch implies. A path-traversal patch that rejects one relative path may still accept an absolute path; an injection

∗^{*}Equal contribution.

patch that blocks one payload may miss an alternate encoding; a repair at one sink may leave a sibling sink reachable. In these cases, the next useful evidence is not another explanation of the original bug, but a working same-vulnerability exploit against the current patch. This framing resembles counterexample-guided synthesis, but our verifier is an incomplete, budgeted exploiter rather than a complete decision procedure [54].

This paper presents P2PATCH, an execution-refereed exploit-patch repair system. We call this exploit-guided repair: a security instantiation of counterexample-guided synthesis in which the counterexample is an executable exploit against the current patch rather than a logical model [11, 54]. P2PATCH starts from a normalized vulnerability finding and a pinned project revision. The protocol is evidence-source independent: the finding may come from a static alert or source-to-sink trace [3], a vulnerability description, a sanitizer report, or a successful exploitation. Our evaluation uses source-to-sink traces, with all findings redacted so that agents do not receive the CVE identifier, upstream fix, advisory exploit text, or held-out proofs of vulnerability (PoVs). Existing work has studied LLM-assisted static analysis and PoV generation as upstream capabilities [14, 35, 37, 44, 56]. P2PATCH uses such evidence differently: an exploitation agent (the exploiter) turns the finding into a reproducing PoV, a patching agent (the patcher) modifies the program until that PoV is blocked, and the exploiter then attacks the patched program for a new distinct same-vulnerability PoV that bypasses the patch. Every execution-confirmed bypassing PoV becomes a permanent repair requirement.

The design is execution-mediated. Agents may propose PoVs and patches, but they do not certify success [77]. The orchestrator executes PoVs in the project container, distinguishes reproduction, blocking, and inconclusive infrastructure outcomes, runs differential regression checks, protects role-specific artifacts, and replays accumulated hardening PoVs after the adversarial rounds. Thus, the interaction is a bounded repair process over a changing executable program, not a natural-language debate between agents.

P2PATCH separates construction-time evidence from evaluation-time evidence. Live PoVs drive repair, but we do not treat them as an independent measure of completeness to avoid the oracle-reuse problem. We instead evaluate final patches with independently certified and held-out PoV suites. Fix-closed PoVs reproduce on the vulnerable revision and are blocked by the recorded official fix, measuring held-out attack-path coverage. Residual PoVs reproduce both before and after the official fix, measuring beyond-upstream hardening. This distinction matters because released security patches can themselves be incomplete [34, 69].

We evaluate P2PATCH on 101 project-level CVE subjects spanning C/C++ and Java. The exploiter finds a distinct execution-confirmed bypass in 41% of runs after the patch blocks its original PoV. Against single-pass repair from the same finding, P2PATCH raises held-out fix-closed coverage from 78.1% to 84.7% and beyond-upstream coverage from 42.1% to 62.5%. Fourteen certified residual gaps were later closed upstream, up to nine and a half years after the original fix. Under the same held-out oracles, P2PATCH covers more certified attack paths than published repair systems on overlapping subjects and exposes patches that passed their validation while leaving certified paths open.

This paper makes the following contributions:

• We introduce a counterexample-guided exploit–patch protocol in which each execution-confirmed bypass of the current patch becomes a permanent repair requirement.

• We design an execution-mediated orchestrator that separates exploiter and patcher roles, protects role-specific artifacts, distinguishes blocked exploits from inconclusive outcomes, performs differential regression checks, and replays accumulated PoVs.

• We release VULNREPAIRBENCH, a benchmark of 101 project–CVE subjects whose independently certified fix-closed and residual PoV suites separate held-out attack-path coverage from beyond-upstream hardening.

• We evaluate P2PATCH across C/C++ and Java CVE subjects against a single-pass baseline, loop ablations, model variants, and published repair systems, showing that adaptive counterexample growth improves security coverage and exposes gaps missed by conventional validation.

References (71)