How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-bench
On the map: LLM agents and tool use → Agent threats, guardrails and governance
Abstract (arXiv)
Large language models (LLMs) and their agentic frameworks are increasingly adopted to perform development tasks such as automated program repair (APR). While prior work has identified security risks in LLM-generated code, most have focused on synthetic, simplified, or isolated tasks that lack the complexity of real-world program repair. In this study, we present the first large-scale security analysis of LLM-generated patches using 20,000+ GitHub issues. We evaluate patches proposed by developers, a standalone LLM (Llama 3.3 Instruct-70B), and three top-performing agentic frameworks (OpenHands, AutoCodeRover, HoneyComb). Finally, we analyze a wide range of code, issue, and project-level factors to understand the conditions under which generating insecure patches is more likely. Our findings reveal that Llama introduces many new vulnerabilities, exhibiting unique patterns not found in developers' code. Agentic workflows also generate a number of vulnerabilities, particularly when given more autonomy. We find that vulnerabilities in LLM-generated patches are associated with distinctive code characteristics and are commonly observed in issues missing specific types of information. These results suggest that contextual factors play a critical role in the security of the generated patches and point toward the need for proactive risk assessment methods that account for both issue and code-level information.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 33 of its 85 references that are in the map. First posted on arXiv 30 Jun 2025.
Builds on
33 of 85 references.
References · 33
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
- 2024SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineeringcited by 1,737
- 2024Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preferencecited by 1,184
- 2024OpenHands: An Open Platform for AI Software Developers as Generalist Agentscited by 1,002
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 192
- 2020Deep Learning based Vulnerability Detection: Are We There Yet?cited by 144
- 2024Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Codecited by 107
- 2024IRIS: LLM-Assisted Static Analysis for Detecting Security Vulnerabilitiescited by 103
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 97
- 2023How Secure is Code Generated by ChatGPT?cited by 81
- 2023Refining ChatGPT-Generated Code: Characterizing and Mitigating Code Quality Issuescited by 79
21 more
- 2024Automated Unit Test Improvement using Large Language Models at Metacited by 75
- 2023Using Large Language Models to Generate JUnit Tests: An Empirical Studycited by 53
- 2025Are "Solved Issues" in SWE-bench Really Solved Correctly? An Empirical Studycited by 49
- 2025LLMs in Software Security: A Survey of Vulnerability Detection Techniques and Insightscited by 47
- 2023Is Stack Overflow Obsolete? An Empirical Study of the Characteristics of ChatGPT Answers to Stack Overflow Questionscited by 42
- 2023SALLM: Security Assessment of Generated Codecited by 39
- 2022CCTEST: Testing and Repairing Code Completion Systemscited by 35
- 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 27
- 2025Enhancing repository-level software repair via repository-aware knowledge graphscited by 27
- 2024LLMs in Web Development: Evaluating LLM-Generated PHP Code Unveiling Vulnerabilities and Limitationscited by 22
- 2023How Can ChatGPT Support Human Security Testers to Help Mitigate Supply Chain Attacks?cited by 20
- 2024Comparison of Static Application Security Testing Tools and Large Language Models for Repo-level Vulnerability Detectioncited by 18
- 2024An Empirical Study of Static Analysis Tools for Secure Code Reviewcited by 17
- 2023Harnessing the Power of LLM to Support Binary Taint Analysiscited by 13
- 2024Just another copy and paste? Comparing the security vulnerabilities of ChatGPT generated code and StackOverflow answerscited by 13
- 2021A Critical Comparison on Six Static Analysis Tools: Detection, Agreement, and Precisioncited by 9
- 2024Enhancing Automated Program Repair with Solution Designcited by 8
- 2025The Art of Repair: Optimizing Iterative Program Repair with Instruction-Tuned Modelscited by 7
- 2021Anomalicious: Automated Detection of Anomalous and Potentially Malicious Commits on GitHubcited by 4
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMscited by 4
- 2025Do Prompt Patterns Affect Code Quality? A First Empirical Assessment of ChatGPT-Generated Codecited by 4
Built on by
Citing papers per year: 2026: 5.
5 papers.
- 2026Does Runtime Topology Context Improve LLM-Generated Kubernetes Security Patches?cited by 2
- 2026"Refactoring Runaway": Understanding and Mitigating Tangled Refactorings in Coding Agents for Issue Resolutioncited by 1
- 2026SecProbe: Adaptive Evaluation of Coding Agents on Cybersecurity Vulnerabilitiescited by 1
- 2026Beyond Execution: Auditing Experimental Fidelity in LLM-Driven Scientific Researchcited by 0
- 2026Reflections on Trusting Trust, Revisited: Contaminating Self-Modifying AI Coding Agents with Poisoned Benchmarkscited by 0
- 2026SecProbe: Adaptive Evaluation of Coding Agents on Cybersecurity Vulnerabilities27 Sep 2026
- 2026Reflections on Trusting Trust, Revisited: Contaminating Self-Modifying AI Coding Agents with Poisoned Benchmarks15 Sep 2026
- 2026Beyond Execution: Auditing Experimental Fidelity in LLM-Driven Scientific Research27 Aug 2026
- 2026Does Runtime Topology Context Improve LLM-Generated Kubernetes Security Patches?28 Jul 2026
- 2026"Refactoring Runaway": Understanding and Mitigating Tangled Refactorings in Coding Agents for Issue Resolution21 May 2026
Similar, not cited
Close in wording, no citation either way
- 2025From LLMs to Agents: A Comparative Evaluation of LLMs and LLM-based Agents in Security Patch Detection
- 2024AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testing
- 2025LLM Agents for Automated Web Vulnerability Reproduction: Are We There Yet?
- 2026RAVEN: Agentic RAG for Automated Vulnerability Repair
- 2025Red Teaming Program Repair Agents: When Correct Patches can Hide Vulnerabilities
- 2025SEC-bench: Automated Benchmarking of LLM Agents on Real-World Software Security Tasks
- 2026When Passing Tests Hides Vulnerabilities: An Empirical Study of Silent Failures in Agentic Systems
- 2025Application Modernization with LLMs: Addressing Core Challenges in Reliability, Security, and Quality