How Well Do Large Language Models Serve as End-to-End Secure Code Agents for Python?
On the map: LLM agents and tool use → Agent threats, guardrails and governance
Abstract (arXiv)
The rapid advancement of large language models (LLMs) such as GPT-4 has revolutionized the landscape of software engineering, positioning these models at the core of modern development practices. As we anticipate these models to evolve into the primary and trustworthy tools used in software development, ensuring the security of the code they produce becomes paramount. How well can LLMs serve as end-to-end secure code producers? This paper presents a systematic investigation into LLMs' inherent potential to generate code with fewer vulnerabilities. Specifically, We studied GPT-3.5 and GPT-4's capability to identify and repair vulnerabilities in the code generated by four popular LLMs including themselves (GPT-3.5, GPT-4, Code Llama, and CodeGeeX2). By manually or automatically reviewing 4,900 pieces of code, our study reveals that: (1) large language models lack awareness of scenario-relevant security risks, which leads to the generation of over 75% vulnerable code on the SecurityEval benchmark; (2) LLMs such as GPT-3.5 and GPT-4 are unable to precisely identify vulnerabilities in the code they generated; (3) GPT-3.5 and GPT-4 can achieve 33.2%~59.6% success rates in repairing the insecure code produced by the 4 LLMs, but they both perform poorly when repairing self-produced code, indicating self-repair "blind spots". To address the limitation of a single round of repair, we developed a lightweight tool that prompts LLMs to construct safer source code through an iterative repair procedure based on the insights gained from our study. Experiments show that assisted by semantic analysis engines, our tool significantly improves the success rates of repair to 65.9%~85.5%.
Key facts. Cited by 7 papers in the map (data through 7 Oct 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 12 of its 30 references that are in the map. First posted on arXiv 20 Aug 2024.
Builds on
12 of 30 references.
References · 12
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 94
- 2023How Secure is Code Generated by ChatGPT?cited by 77
- 2022Is GitHub's Copilot as Bad as Humans at Introducing Vulnerabilities in Code?cited by 63
- 2023How Effective Are Neural Networks for Fixing Security Vulnerabilitiescited by 50
- 2023No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPTcited by 45
- 2023ChatGPT for Vulnerability Detection, Classification, and Repair: How Far Are We?cited by 44
- 2024Multitask-based Evaluation of Open-Source LLM on Software Vulnerabilitycited by 23
- 2024DLAP: A Deep Learning Augmented Large Language Model Prompting Framework for Software Vulnerability Detectioncited by 13
- 2024A Study of Vulnerability Repair in JavaScript Programs with Large Language Modelscited by 7
Built on by
Citing papers per year: 2024: 1; 2025: 4; 2026: 2.
7 papers.
- 2024From Vulnerabilities to Remediation: A Systematic Literature Review of LLMs in Code Securitycited by 9
- 2025A Systematic Literature Review on Detecting Software Vulnerabilities with Large Language Modelscited by 8
- 2025Is Your Prompt Poisoning Code? Defect Induction Rates and Security Mitigation Strategiescited by 3
- 2025An Empirical Study of Vulnerabilities in Python Packages and Their Detectioncited by 2
- 2025The 4/δ Bound: Designing Predictable LLM-Verifier Systems for Formal Method Guaranteecited by 1
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Developmentcited by 0
- 2026Benchmarking Mythos-Linked Bug Rediscoverycited by 0
- 2026Benchmarking Mythos-Linked Bug Rediscovery17 May 2026
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Development20 Apr 2026
- 2025The 4/δ Bound: Designing Predictable LLM-Verifier Systems for Formal Method Guarantee30 Nov 2025
- 2025Is Your Prompt Poisoning Code? Defect Induction Rates and Security Mitigation Strategies27 Oct 2025
- 2025An Empirical Study of Vulnerabilities in Python Packages and Their Detection4 Sep 2025
- 2025A Systematic Literature Review on Detecting Software Vulnerabilities with Large Language Models30 Jul 2025
- 2024From Vulnerabilities to Remediation: A Systematic Literature Review of LLMs in Code Security19 Dec 2024
Similar, not cited
Close in wording, no citation either way
- 2026Enhancing Reliability in LLM-Based Secure Code Generation
- 2025When Code Crosses Borders: A Security-Centric Study of LLM-based Code Translation ↗
- 2026Poster: Rethinking Security in LLM Code Generation through Real-World Risk Scenarios
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods
- 2025Rethinking the Evaluation of Secure Code Generation
- 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?
- 2023A Survey on Large Language Model (LLM) Security and Privacy: The Good, the Bad, and the Ugly
- 2025Holistic Evaluation of State-of-the-Art LLMs for Code Generation