How secure is AI-generated code: a large-scale comparison of large language models
Open accessThe DOI matches its Crossref record; 116 of the 134 references it cites were found in a registry or an index, and 17 are not checked yet.
Abstract
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.
Overview
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Integrity signals
Registry
Cites
Statistics
Verification
Claims the paper makes
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Self-check
Percentages, sums and reported differences re-computed from the paper’s own numbers.
The self-check needs the paper’s full text.
Citations
Cites
Compilers: Principles, Techniques, and Tools
Aho, A. V., Sethi, R., & Ullman, J. D. (1986) · Cited by 8,480
Tree of Thoughts: Deliberate Problem Solving with Large Language Models
Yao, S., Yu, D., Zhao, J., Shafran, I., Griffiths, T. L., Cao, Y., & Narasimhan, K. (2023) · arXiv · doi:10.48550/arxiv.2305.10601 · Cited by 7,650
McCabe, T. J. (1976) · IEEE Transactions on Software Engineering · doi:10.1109/tse.1976.233837 · Cited by 6,059
Chain-Of-Thought Prompting Elicits Reasoning in Large Language Models
Wei, J., Wang, X., Schuurmans, D., Bosma, M., Ichter, B., Xia, F., Chi, E., Le, Q. V., & Zhou, D. (2022) · Advances in Neural Information Processing Systems 35 · doi:10.52202/068431-1800 · Cited by 4,505
Evaluating Large Language Models Trained on Code
Chen, M., Tworek, J., Jun, H., Yuan, Q., Pinto, H. P. D. O., Kaplan, J., Edwards, H., Burda, Y., Joseph, N., Brockman, G., et al. (2021) · arXiv · doi:10.48550/arxiv.2107.03374 · Cited by 1,436
Large Language Models for Software Engineering: A Systematic Literature Review
Hou, X., Zhao, Y., Liu, Y., Yang, Z., Wang, K., Li, L., Luo, X., Lo, D., Grundy, J., & Wang, H. (2024) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3695988 · Cited by 1,029
Gemini: A Family of Highly Capable Multimodal Models
Gemini Team, Anil, R., Borgeaud, S., Alayrac, J.-B., Yu, J., Soricut, R., Schalkwyk, J., Dai, A. M., Hauth, A., Millican, K., et al. (2023) · arXiv · doi:10.48550/arxiv.2312.11805 · Cited by 990
A systematic evaluation of large language models of codePreprint
Xu, F. F., Alon, U., Neubig, G., & Hellendoorn, V. (2022) · MAPS@PLDI · doi:10.48550/arxiv.2202.13169 · Cited by 932
A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT
White, J., Fu, Q., Hays, S., Sandborn, M., Olea, C., Gilbert, H., Elnashar, A., Spencer-Smith, J., & Schmidt, D. C. (2023) · arXiv · doi:10.48550/arxiv.2302.11382 · Cited by 838
AI models collapse when trained on recursively generated data
Shumailov, I., Shumaylov, Z., Zhao, Y., Papernot, N., Anderson, R., & Gal, Y. (2024) · Nature · doi:10.1038/s41586-024-07566-y · Cited by 793
Research works printed but not linked: 3
- Gadelha, M.R., Monteiro, F.R., Morse, J., Cordeiro, L.C., Fischer, B., Nicole, D.A.: Esbmc 5.0: an industrial-strength c model checker. In: Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, pp. 888-891. ACM, Montpellier, France (2018) · DOI
- Paul, R., Mohib Hossain, M., Hasan, M., Iqbal, A.: Automated program repair based on code review: How do pre-trained transformer models perform? arXiv e-prints, 2304 (2023)
- Sandoval, G., Pearce, H., Nys, T., Karri, R., Garg, S., Dolan-Gavitt, B.: Lost at c: A user study on the security implications of large language model code assistants. In: 32nd USENIX Security Symposium (USENIX Security 23), pp. 2205-2222 (2023). USENIX Association
Cited by
Items 101–134 of 134
MIUN BiasPatrol at SemEval-2026 Task 13: Why TF-IDF can Beat Transformers for OOD Code Detection
Sahlen, L., Springfeldt, T., Fatima, M., & Shahzad, R. K. (2026) · International Workshop on Semantic Evaluation (SemEval) · doi:10.18653/v1/2026.semeval-1.312
Is AI-Generated Web Code Vulnerability-Free?
Mansour, M., & AlMajali, A. (2026) · IEEE Jordan Conference on Applied Electrical Engineering and Computing Technologies · doi:10.1109/aeect69724.2026.11657834
Heidaripour, M., Maleki, H., Patel, P., Dal, A., Mitchell, N., & Sanders, A. L. (2026) · Lecture notes in computer science · doi:10.1007/978-3-032-35576-8_4
Security Analysis of LLM-Generated Web API Backends
Khan, A. A., Rauti, S., & Mäkilä, T. (2026) · IEEE Access · doi:10.1109/access.2026.3727682
Petrovič, P., Tran, C. V., Trung, H. N., & Babič, F. (2026) · IEEE International Conference on Intelligent Engineering Systems (INES) · doi:10.1109/ines69513.2026.11661226
Tarakcı, İ., Koyuncu, S., & Nazlıoğlu, S. (2026) · Journal of Systems and Software · doi:10.1016/j.jss.2026.113123
Alzoubi, Y. I., & Mishra, A. (2026) · Journal of Responsible Technology · doi:10.1016/j.jrt.2026.100187
Evaluating and Preventing Security Smells in AI-Generated Ansible CodePreprint
Konala, P. R. R., Kumar, V., Bainbridge, D., & Haseeb, J. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2608.24962
Heurix: A Framework to Automatically Learn Heuristics for Abstract Interpretation
Mattar, M., Alberti, M., Perrelle, V., & Sadou, S. (2026) · Lecture notes in computer science · doi:10.1007/978-3-032-40374-2_16
de Moura, T. S., Matuschek, F., Toffalini, F., & Noller, Y. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.08240
Hidden in the Comments: A Context-Injection Attack Surface in Code LLMsPreprint
Munir, N., Quinzan, F., & Roberts, S. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.05139
A Security Risk Assessment Framework for AI-Powered Development ToolsPreprint
AlJanah, S. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2609.18658
Farfoura, M. E., Alia, M. A. K., Mashal, I., Hnaif, A. A., & Odeh, M. (2026) · Journal of Sustainable Smart Systems in Education & Environment · doi:10.66823/2egmd793
Security of Cross-Platform and Cross-Language Software Technologies: A Systematic Review
Zhou, M., Zhang, Y., Han, J., Li, L., & Luo, X. (2026) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3841182
Assessing Postcondition Completeness in Auto-Generated Function Contracts for Software Verification
Silveira, C. V. P., & Ferreira, M. F. T. (2026) · Simpósio Brasileiro de Testes de Software Sistemático e Automatizado (SAST) · doi:10.5753/sast.2026.30683
Esnaola, L. (2026) · El Servicio de Difusión de la Creación Intelectual (National University of La Plata) · doi:10.35537/10915/197781
Security in LLM-Assisted Coding: A Systematic Literature Review
Yuan, L., Najafabadi, M. K., Rana, M., & Vetrova, V. V. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.15482
CAT-RAG: Improving Secure Code Generation with Category-Aware Agentic RetrievalPreprint
Abazar, M., Carli, L. D., & Tan, B. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.24907
A gradual and general method to understand why Functional Programming is important
O’Connor, F. A. S., López, P. E. M., & Garzón, M. (2026) · JAIIO, Jornadas Argentinas de Informática
Look Before You Prompt, and After: Scaffolding Human-AI Collaboration in Software Tutorial CreationPreprint
Bhat, A., Bui, V., & Guo, J. L. C. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2609.05563
Arcentales, A. M. A., Avilés, V. A. F., & Alvarado, J. L. (2026) · Research Club Scientia · doi:10.65415/6mgvny75
PIA-TECH SRL, P., Pantilică, M.-R., & Ene, C. (2026) · Economic Insights – Trends and Challenges · doi:10.51865/eitc.2025.04.09
ARQ: Agentic CodeQL Query Refinement for C/C++ Vulnerability DetectionPreprint
Wang, C., Ke, Y., Yang, J., Tsai, Y.-Y., & Li, P. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2608.20637
Validation-Gated GenAI Migration of Legacy Java to Cloud-Native Microservices
Pandey, A. K. (2026) · International Journal of Intelligent Systems and Applications in Engineering · doi:10.5281/zenodo.22097887
Secure and Functional Code Generation with Self-EvaluationPreprint
Mamun, M. A. A., & Uddin, G. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.33450
PreMaQ: Predicting Maintainability-Related Quality of LLM-Generated Code Before GenerationPreprint
Wakamatsu, T., Ishimoto, Y., Kondo, M., & Kamei, Y. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.05858
A quality framework for infrastructure as code in the modern DevSecOps era
Konala, P. (2026) · Research Commons (University of Waikato)
Fischer, M. (2026) · Zürcher Hochschule für Angewandte Wissenschaften digital collection (Zurich University of Applied Sciences) · doi:10.21256/zhaw-38183
Editorial: Vibe Coding and AI: The New Frontier of User Innovation
Bilgram, V., & Brem, A. (2026) · IEEE Engineering Management Review · doi:10.1109/emr.2026.3719567
Chen, X., Xu, J., Wu, B., Cui, C., Fang, C., Wen, W., Li, T., Huang, R., & Chen, T. Y. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.34431
Can VIBE Drive Development? Threats and Opportunities
Mukhopadhyay, M. (2026) · Communications of the ACM · doi:10.1145/3806208
Bhatt, M., Pochincharla, S., Khilji, A., & Timoshenko, D. (2026) · doi:10.1109/gaiss66401.2026.11779568
Metadata
- Authors
- Tihanyi, N., Bisztray, T., Ferrag, M. A., Jain, R., & Cordeiro, L. C.
- Affiliations
- Eötvös Loránd University (HU)
- University of Guelma (DZ)
- Technology Innovation Institute (AE)
- University of Manchester (GB)
- Corresponding author
- Tihanyi, Norbert
- Venue
- Empirical Software Engineering
- Published
- 2024-12-21
- Volume
- 30
- Issue
- 2
- Pages
- 47
- ISSN
- 1382-3256 (ISSN-L)
- 1573-7616
- OpenAlex
- W4396820575
- Semantic Scholar
- 41c9d8b2b499d30ef0bc4347df4e5251c37faf39
- Cited by
- 133
- References
- 130
- Citations by year
- 2026: 91 · 2025: 39 · 2024: 3
- FWCI
- 25.24
- Type
- journal article
- Language
- en
- Open access
- green
- arxiv.org
- Licence
- www.springernature.com/gp/researchers/text-and-data-mining (tdm)
- www.springernature.com/gp/researchers/text-and-data-mining (vor)
- Locations
- Empirical Software Engineering (publishedVersion)
- arXiv (Cornell University) (submittedVersion)
- arXiv (Cornell University)
- Funders
- Engineering and Physical Sciences Research Council (EP/T026995/1)
- Topics
- Physical Sciences › Computer Science › Information Systems › Software Engineering Research
- Physical Sciences › Computer Science › Software › Software Testing and Debugging Techniques
- Physical Sciences › Computer Science › Artificial Intelligence › Adversarial Robustness in Machine Learning
- Keywords
- AI-generated code, large language models, software vulnerabilities, C programs, ESBMC, SMT-based verification, formal verification, code generation security, model comparison, falcons, CodeLlama, GPT-4o-mini, Gemini Pro
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review
Data sources
Bibliographic data: Semantic Scholar, OpenAlex, Crossref.
Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).
Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.