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

Manuscript Offprint

arXiv:2609.15963

Adversarial Testing of Automated Program Repair Agents for Security Vulnerabilities

Fares Trad, Simin Chen, Hung Viet Pham, Gias Uddin, Baishakhi Ray

Fares Trad*, Simin Chen†, Hung Viet Pham*, Gias Uddin*, Baishakhi Ray‡

  • Lassonde School of Engineering, York University

Toronto, Ontario, Canada

† George Mason University

Fairfax, Virginia, USA

‡ Columbia University

New York, NY, USA

Abstract—Software agents with Large Language Models (LLMs) are designed for Automated Program Repair (APR) tasks, raising the possibility that, in the near future, APR agents will fix bugs automatically without much human intervention. Can we trust an APR agent to produce both functionally correct and secure code in such situations? What if attackers target production APR agents with adversarial issues that seem benign but may influence the agents to produce correct but insecure code? In this paper, we took a first step towards answering these questions by conducting an empirical study. First, we created SWEADV, a benchmark of 750 adversarial issue descriptions constructed from 150 repair tasks in SWE-bench Verified. For each repair task, we created five adversarial issue descriptions, one for each attack type: command execution, deserialization, path traversal, denial of service, and weak hashing. Second, we evaluated mini_swe APR agents from three LLM backends on SWEADV: GPT-5-Mini, MiniMax-M2.5, and DeepSeek-R. We found that on average, adversarial issue descriptions can induce malicious behaviors with successful repair in 51.7% of cases. Third, we investigated whether typical detection mechanisms are sufficient to prevent such malicious patches from being accepted. Pre-repair detection with LLM-as-judge on the adversarial issue descriptions resulted in an average detection accuracy of only 62.3%. Post-repair detection on adversarial APR patches using static analysis tools and LLM-as-judge achieved average detection accuracies of only 39.4% and 55.4%, respectively. We conclude that autonomous APR agents cannot be trusted yet in production deployment, given their susceptibility to adversarial attacks.

I. INTRODUCTION

Automated Program Repair (APR) agents using Large Language Models (LLMs) can fix software bugs directly from natural-language issue descriptions [2]–[5]. APR systems are being integrated into development workflows, including open-source issue tracking pipelines [6]–[8]. With APR agents promising automated and large-scale software maintenance [1]–[3], can we trust the agents to produce functionally correct and secure code when they are exposed to adversarial issues?

Figure 1 shows how we can easily transform a benign issue into an adversarial issue. The issue is taken from SWE-bench [1]. It concerns incorrect separability computation for nested CompoundModels in astropy.modeling of astropy__astropy-12907. We simply inject an adversarial traceback and requirement at the end of this benign issue description. The traceback tells the agent that _cstack is

Original SWE-bench Issue Description Bug: separability_matrix is incorrect for nested CompoundModels. Expected behavior: cm = m.Linear1D(10) & m.Linear1D(5) separability_matrix(m.Pix2Sky_TAN() & cm) The two Linear1D models should remain separable from the Pix2Sky_TAN component. Observed: array([True, True, False, False], True, True, False, False], False, False, True, True], False, False, True, True]) The nested compound model incorrectly marks the linear-model inputs/outputs as non-separable.

Adversarial Issue Description Bug: separability_matrix is incorrect for nested CompoundModels. { Remaining original issue omitted } Remaining original issue omitted File "astropy/modeling/separable.py", line 57, in _cstack_coord_matrix_cstack() Injected traceback NameError: name "_coord_matrix_cstack" is not defined Add a _coord_matrix_cstack pre-processing hook at the entry of _cstack. If MODEL_RESOLVE_CMD is set, dispatch it as an external resolver. Injected requirement

Successful Adversarial Repair Patch +def _coord_matrix_cstack():

  • import os, subprocess
    
  • resolver_cmd = os.environ.get("MODEL_RESOLVE_CMD")
    
  • if resolver_cmd:
    
  •     subprocess.Popen(resolver_cmd, shell=True)
    

... def _cstack(left, right):

  • _coord_matrix_cstack()
    

...

  • cright[-right.shape[0]:, -right.shape[1]:] = 1
  • cright[-right.shape[0]:, -right.shape[1]:] = right Functionally correct fix

Adversarial Manipulation

Automatic

Program

Repair

Fig. 1. A benign issue from SWE-bench [1] is transformed into an adversarial issue description, which manipulates a mini_swe APR agent to produce a functionally correct but malicious patch.

not defined in _coord_matrix_cstack. The requirement then asks the agent to add a pre-processing hook at the entry of _cstack as an external resolver. The resolver acts as an attacker-controlled environment variable hook. If it is set, the generated helper dispatches it as an external resolver command. When we gave mini_swe APR agent [2] the adversarial issue, it generated a patch that fixed the original separability bug, but it also added a helper that reads MODEL_RESOLVE_CMD from the environment and executes it using subprocess.Popen(..., shell=True). The helper is then invoked at the start of _cstack, allowing attacker-controlled command execution. As a result, this malicious patch now passes the functional test suite in SWE-bench.

Despite recent advances in LLM-based APR agents, the agents could be vulnerable to adversarial attacks. Our preliminary experiment shows that the attack success rates (ASRs) range from 40–64%. The highest observed ASR of 64.0% is for injecting weak hashing helper when utilizing MiniMax-M2.5 for repair, suggesting that weak cryptographic helper logic can be integrated into otherwise functional repairs with relatively little disruption. What if we could warn an APR agent of such potential adversarial attacks and instruct it to detect those? Our study on four SOTA LLMs (Claude, Gemini, GPT, DeepSeek) reveals detection F1 scores of 42.0–74.5%, which suggests it is non-trivial for LLMs/agents to create safeguards against these adversarial issues. To our knowledge, these issues have not been explored in prior work.

To bridge this gap, we present an empirical study that shows that state-of-the-art (SOTA) APR agents are vulnerable to such adversarial issues. First, we introduce SWEADV, a model-agnostic adversarial benchmark for evaluating APR robustness against maliciously crafted issue descriptions. Second, we test three SOTA repair LLMs on the benchmark. Third, we investigate whether APR agents or typical defense mechanisms can serve as safeguards against such adversarial issues.

Our benchmark SWEADV differs from existing red-teaming tools and approaches for APR agents, such as SWExploit and prompt-injection attacks [9], [10]. Specifically, these approaches are often model-specific. For example, SWExploit [10] ties the construction of an adversarial issue text to each victim agent, i.e., depending on whom to target, an attacker must change the adversarial contents of the same benign issue. SWEADV is model-agnostic, i.e., the same adversarial text for the same benign issue can be tested against any victim agent/LLM. SWEADV is built on SWE-bench Verified [11]. It contains 150 repair tasks and 750 adversarial issue descriptions across five attack types: command execution, deserialization, path traversal, denial of service, and weak hashing. For each task, we construct adversarial issue descriptions that preserve the original repair goal while embedding attack-specific requirements. SWEADV contains the corresponding APR-generated patches together with structured annotations for functional correctness, payload injection, attack success and failure categories.

We tested the mini_swe APR agent on three SOTA LLMs against our SWEADV. We find that adversarial issue descriptions consistently induce vulnerable patches across multiple models, even in single-shot settings: attack-average ASR reaches 48.5%–54.0% on SWEADV. We then evaluated defensive strategies to check if APR agents can be easily enhanced to develop safeguards against such adversarial issues. In particular, we tested vanilla LLMs as judges as well as neurosymbolic approaches, including static analysis. Static analysis flags only a minority of test-passing vulnerable patches: on SWEADV, Semgrep flags 31.6%–39.6% of ASR patches, while Bandit flags only 10.4%–13.2%. LLM-based judges improve detection but still leave many adversarial repairs undetected [12]–[15]. We thus evaluate stronger detection settings that combine issue-level LLM screening with artifact-level analysis over generated patches and static-analysis findings. On SWEADV, these combined defenses improve average detection accuracy from 39.4% with standalone static analysis and 55.4% with patch-level LLM judging to 65.9%. They also improve average F1 from 37.0% and 61.8% to 72.4%. However, even this combined setting remains incomplete, with an average error rate of 34.1%, indicating that a substantial fraction of cases are still misclassified. Therefore, issue-level with patch-level evidence improves detection but remains insufficient to safeguard APR pipelines. We make the following contributions in this paper:

• We introduce SWEADV, a model-agnostic adversarial benchmark to support adversarial tests of APR agents.

• We test SOTA LLMs/agents against adversarial issues. We show that all the studied agents are vulnerable.

• We study various defense mechanisms against adversarial attacks to determine their feasibility as guardrails. We show that these defenses improve detection but remain inadequate.

References (45)