How secure is AI-generated Code: A Large-Scale Comparison of Large Language Models
Not on the map. Why?
Abstract (arXiv)
This study compares state-of-the-art Large Language Models (LLMs) on their tendency to generate vulnerabilities when writing C programs using a neutral zero-shot prompt. Tihanyi et al. introduced the FormAI dataset at PROMISE'23, featuring 112,000 C programs generated by GPT-3.5-turbo, with over 51.24% identified as vulnerable. We extended that research with a large-scale study involving 9 state-of-the-art models such as OpenAI's GPT-4o-mini, Google's Gemini Pro 1.0, TII's 180 billion-parameter Falcon, Meta's 13 billion-parameter Code Llama, and several other compact models. Additionally, we introduce the FormAI-v2 dataset, which comprises 331 000 compilable C programs generated by these LLMs. Each program in the dataset is labeled based on the vulnerabilities detected in its source code through formal verification, using the Efficient SMT-based Context-Bounded Model Checker (ESBMC). This technique minimizes false positives by providing a counterexample for the specific vulnerability and reduces false negatives by thoroughly completing the verification process. Our study reveals that at least 62.07% of the generated programs are vulnerable. The differences between the models are minor, as they all show similar coding errors with slight variations. Our research highlights that while LLMs offer promising capabilities for code generation, deploying their output in a production environment requires proper risk assessment and validation.
Key facts. Cited by 24 papers in the map (data through 14 Oct 2026). Builds on 43 of its 114 references that are in the map. First posted on arXiv 29 Apr 2024.
Builds on
43 of 114 references.
References · 43
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2023A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPTcited by 619
- 2023The Falcon Series of Open Language Modelscited by 535
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 399
- 2022A Systematic Evaluation of Large Language Models of Codecited by 363
- 2023The Curse of Recursion: Training on Generated Data Makes Models Forgetcited by 356
- 2023MathPrompter: Mathematical Reasoning using Large Language Modelscited by 236
- 2024Foundational Challenges in Assuring Alignment and Safety of Large Language Modelscited by 199
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 192
- 2023Software Testing with Large Language Models: Survey, Landscape, and Visioncited by 166
31 more
- 2023Keep the Conversation Going: Fixing 162 out of 337 bugs for 0.42 each using ChatGPTcited by 125
- 2023InferFix: End-to-End Program Repair with LLMscited by 114
- 2021Jigsaw: Large Language Models meet Program Synthesiscited by 103
- 2023DiverseVul: A New Vulnerable Source Code Dataset for Deep Learning Based Vulnerability Detectioncited by 102
- 2023The Programmer's Assistant: Conversational Interaction with a Large Language Model for Software Developmentcited by 96
- 2023How Secure is Code Generated by ChatGPT?cited by 81
- 2024Benchmark Self-Evolving: A Multi-Agent Framework for Dynamic LLM Evaluationcited by 75
- 2023Large Language Models for Test-Free Fault Localizationcited by 67
- 2023Understanding the Effectiveness of Large Language Models in Detecting Security Vulnerabilitiescited by 59
- 2023Copiloting the Copilots: Fusing Large Language Models with Completion Engines for Automated Program Repaircited by 55
- 2023How Effective Are Neural Networks for Fixing Security Vulnerabilitiescited by 52
- 2023Prompt-Enhanced Software Vulnerability Detection Using ChatGPTcited by 51
- 2023RAP-Gen: Retrieval-Augmented Patch Generation with CodeT5 for Automatic Program Repaircited by 44
- 2024Finetuning Large Language Models for Vulnerability Detectioncited by 40
- 2022Transformer-Based Language Models for Software Vulnerability Detectioncited by 39
- 2023The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verificationcited by 34
- 2023GAMMA: Revisiting Template-based Automated Program Repair via Mask Predictioncited by 23
- 2020Evaluating Representation Learning of Code Changes for Predicting Patch Correctness in Program Repaircited by 22
- 2023Domain Knowledge Matters: Improving Prompts with Fix Templates for Repairing Python Type Errorscited by 22
- 2022Dataflow Analysis-Inspired Deep Learning for Efficient Vulnerability Detectioncited by 19
- 2023INTERVENOR: Prompting the Coding Ability of Large Language Models with the Interactive Chain of Repaircited by 18
- 2023E&V: Prompting Large Language Models to Perform Static Analysis by Pseudo-code Execution and Verificationcited by 10
- 2024Code Security Vulnerability Repair Using Reinforcement Learning with Large Language Modelscited by 10
- 2022The Best of Both Worlds: Combining Learned Embeddings with Engineered Features for Accurate Prediction of Correct Patchescited by 9
- 2023Turbulence: Systematically and Automatically Testing Instruction-Tuned Large Language Models for Codecited by 9
- 2024Learning in the Wild: Towards Leveraging Unlabeled Data for Effectively Tuning Pre-trained Code Modelscited by 9
- 2023Fixing Rust Compilation Errors using LLMscited by 7
- 2018SMT-Based Refutation of Spurious Bug Reports in the Clang Static Analyzercited by 5
- 2023The EarlyBIRD Catches the Bug: On Exploiting Early Layers of Encoder Models for More Efficient Code Classificationcited by 5
- 2023A Chain of AI-based Solutions for Resolving FQNs and Fixing Syntax Errors in Partial Codecited by 4
- 2022ESBMC-Jimple: Verifying Kotlin Programs via Jimple Intermediate Representationcited by 1
Built on by
Citing papers per year: 2024: 2; 2025: 8; 2026: 14.
24 papers.
Sort:
By area:
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injectioncited by 16
- 2025CASTLE: Benchmarking Dataset for Static Code Analyzers and LLMs towards CWE Detectioncited by 10
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generationcited by 9
- 2025I Know Which LLM Wrote Your Code Last Summer: LLM generated Code Stylometry for Authorship Attributioncited by 9
- 2025Vulnerability Detection: From Formal Verification to Large Language Models and Hybrid Approaches: A Comprehensive Overviewcited by 7
- 2024Helping LLMs Improve Code Generation Using Feedback from Testing and Static Analysiscited by 6
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2026A Guide to Large Language Models in Modeling and Simulation: From Core Techniques to Critical Challengescited by 3
- 2025The Hidden DNA of LLM-Generated JavaScript: Structural Patterns Enable High-Accuracy Authorship Attributioncited by 2
- 2026Enhancing Reliability in LLM-Based Secure Code Generationcited by 2
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularitiescited by 1
- 2026Adaptive Hierarchical Evaluation of LLMs and SAST tools for CWE Prediction in Pythoncited by 1
12 more
- 2026Rethinking Code Review in the Age of AI: A Vision for Agentic Code Reviewcited by 1
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generationcited by 1
- 2025GitHub's Copilot Code Review: Can AI Spot Security Flaws Before You Commit?cited by 0
- 2026Deep Learning-based Binary Analysis for Vulnerability Detection in x86-64 Machine Codecited by 0
- 2026Human-Certified Module Repositories for the AI Agecited by 0
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Developmentcited by 0
- 2026Builder, Defender, Breaker: Measurable Independence and Bounded Autonomy When Generative Models Build, Defend and Test Softwarecited by 0
- 2026From Adoption to Deployment: A Qualitative Study on AI Integration in Software Development Practicecited by 0
- 2026From Evaluation to Optimisation: Hierarchy-Aware Training Signals for CWE Prediction in Pythoncited by 0
- 2026Evaluating and Preventing Security Smells in AI-Generated Ansible Codecited by 0
- 2026Compared to What? A Human-Anchored Security Benchmark for LLM-Generated Infrastructure-as-Codecited by 0
- 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generationcited by 0
- 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generation10 Oct 2026
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generation2 Sep 2026
- 2026Compared to What? A Human-Anchored Security Benchmark for LLM-Generated Infrastructure-as-Code28 Aug 2026
- 2026Evaluating and Preventing Security Smells in AI-Generated Ansible Code25 Aug 2026
- 2026From Evaluation to Optimisation: Hierarchy-Aware Training Signals for CWE Prediction in Python23 Jul 2026
- 2026From Adoption to Deployment: A Qualitative Study on AI Integration in Software Development Practice18 Jul 2026
- 2026Builder, Defender, Breaker: Measurable Independence and Bounded Autonomy When Generative Models Build, Defend and Test Software3 Jul 2026
- 2026Enhancing Reliability in LLM-Based Secure Code Generation22 May 2026
- 2026Rethinking Code Review in the Age of AI: A Vision for Agentic Code Review17 May 2026
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Development20 Apr 2026
- 2026Human-Certified Module Repositories for the AI Age3 Mar 2026
- 2026A Guide to Large Language Models in Modeling and Simulation: From Core Techniques to Critical Challenges5 Feb 2026
12 more
- 2026Deep Learning-based Binary Analysis for Vulnerability Detection in x86-64 Machine Code14 Jan 2026
- 2026Adaptive Hierarchical Evaluation of LLMs and SAST tools for CWE Prediction in Python4 Jan 2026
- 2025The Hidden DNA of LLM-Generated JavaScript: Structural Patterns Enable High-Accuracy Authorship Attribution12 Oct 2025
- 2025GitHub's Copilot Code Review: Can AI Spot Security Flaws Before You Commit?17 Sep 2025
- 2025I Know Which LLM Wrote Your Code Last Summer: LLM generated Code Stylometry for Authorship Attribution18 Jun 2025
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs27 May 2025
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection23 Apr 2025
- 2025Vulnerability Detection: From Formal Verification to Large Language Models and Hybrid Approaches: A Comprehensive Overview13 Mar 2025
- 2025CASTLE: Benchmarking Dataset for Static Code Analyzers and LLMs towards CWE Detection12 Mar 2025
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generation5 Feb 2025
- 2024Helping LLMs Improve Code Generation Using Feedback from Testing and Static Analysis19 Dec 2024
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularities2 Sep 2024
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injectioncited by 16
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generationcited by 9
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generationcited by 1
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generation2 Sep 2026
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection23 Apr 2025
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generation5 Feb 2025
- 2025CASTLE: Benchmarking Dataset for Static Code Analyzers and LLMs towards CWE Detectioncited by 10
- 2025I Know Which LLM Wrote Your Code Last Summer: LLM generated Code Stylometry for Authorship Attributioncited by 9
- 2025Vulnerability Detection: From Formal Verification to Large Language Models and Hybrid Approaches: A Comprehensive Overviewcited by 7
- 2024Helping LLMs Improve Code Generation Using Feedback from Testing and Static Analysiscited by 6
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2026A Guide to Large Language Models in Modeling and Simulation: From Core Techniques to Critical Challengescited by 3
- 2025The Hidden DNA of LLM-Generated JavaScript: Structural Patterns Enable High-Accuracy Authorship Attributioncited by 2
- 2026Enhancing Reliability in LLM-Based Secure Code Generationcited by 2
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularitiescited by 1
- 2026Adaptive Hierarchical Evaluation of LLMs and SAST tools for CWE Prediction in Pythoncited by 1
- 2025GitHub's Copilot Code Review: Can AI Spot Security Flaws Before You Commit?cited by 0
- 2026Deep Learning-based Binary Analysis for Vulnerability Detection in x86-64 Machine Codecited by 0
12 most cited of 19 All 19 (JSON)
- 2026Compared to What? A Human-Anchored Security Benchmark for LLM-Generated Infrastructure-as-Code28 Aug 2026
- 2026Evaluating and Preventing Security Smells in AI-Generated Ansible Code25 Aug 2026
- 2026From Evaluation to Optimisation: Hierarchy-Aware Training Signals for CWE Prediction in Python23 Jul 2026
- 2026From Adoption to Deployment: A Qualitative Study on AI Integration in Software Development Practice18 Jul 2026
- 2026Builder, Defender, Breaker: Measurable Independence and Bounded Autonomy When Generative Models Build, Defend and Test Software3 Jul 2026
- 2026Enhancing Reliability in LLM-Based Secure Code Generation22 May 2026
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Development20 Apr 2026
- 2026Human-Certified Module Repositories for the AI Age3 Mar 2026
- 2026A Guide to Large Language Models in Modeling and Simulation: From Core Techniques to Critical Challenges5 Feb 2026
- 2026Deep Learning-based Binary Analysis for Vulnerability Detection in x86-64 Machine Code14 Jan 2026
- 2026Adaptive Hierarchical Evaluation of LLMs and SAST tools for CWE Prediction in Python4 Jan 2026
- 2025The Hidden DNA of LLM-Generated JavaScript: Structural Patterns Enable High-Accuracy Authorship Attribution12 Oct 2025
12 newest of 19 All 19 (JSON)