mlsanityData to 7 Oct 2026

How Well Do Large Language Models Serve as End-to-End Secure Code Agents for Python?

arXiv 2408.10495 ↗First posted 20 Aug 2024cs.SE cs.AIcited by 7

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

  1. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  2. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  3. 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
  4. 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 94
  5. 2023How Secure is Code Generated by ChatGPT?cited by 77
  6. 2022Is GitHub's Copilot as Bad as Humans at Introducing Vulnerabilities in Code?cited by 63
  7. 2023How Effective Are Neural Networks for Fixing Security Vulnerabilitiescited by 50
  8. 2023No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPTcited by 45
  9. 2023ChatGPT for Vulnerability Detection, Classification, and Repair: How Far Are We?cited by 44
  10. 2024Multitask-based Evaluation of Open-Source LLM on Software Vulnerabilitycited by 23
  11. 2024DLAP: A Deep Learning Augmented Large Language Model Prompting Framework for Software Vulnerability Detectioncited by 13
  12. 2024A Study of Vulnerability Repair in JavaScript Programs with Large Language Modelscited by 7

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 1; 2025: 4; 2026: 2.

7 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026Enhancing Reliability in LLM-Based Secure Code Generation
  2. 2025When Code Crosses Borders: A Security-Centric Study of LLM-based Code Translation ↗
  3. 2026Poster: Rethinking Security in LLM Code Generation through Real-World Risk Scenarios
  4. 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods
  5. 2025Rethinking the Evaluation of Secure Code Generation
  6. 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?
  7. 2023A Survey on Large Language Model (LLM) Security and Privacy: The Good, the Bad, and the Ugly
  8. 2025Holistic Evaluation of State-of-the-Art LLMs for Code Generation