How Secure is Code Generated by ChatGPT?
Not on the map. Why?
Abstract (arXiv)
In recent years, large language models have been responsible for great advances in the field of artificial intelligence (AI). ChatGPT in particular, an AI chatbot developed and recently released by OpenAI, has taken the field to the next level. The conversational model is able not only to process human-like text, but also to translate natural language into code. However, the safety of programs generated by ChatGPT should not be overlooked. In this paper, we perform an experiment to address this issue. Specifically, we ask ChatGPT to generate a number of program and evaluate the security of the resulting source code. We further investigate whether ChatGPT can be prodded to improve the security by appropriate prompts, and discuss the ethical aspects of using AI to generate code. Results suggest that ChatGPT is aware of potential vulnerabilities, but nonetheless often generates source code that are not robust to certain attacks.
Key facts. Cited by 77 papers in the map (data through 7 Oct 2026). First posted on arXiv 19 Apr 2023.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2023: 8; 2024: 26; 2025: 27; 2026: 16.
77 papers.
Sort:
By area:
- 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 130
- 2023A Survey of Safety and Trustworthiness of Large Language Models through the Lens of Verification and Validationcited by 91
- 2024When LLMs Meet Cybersecurity: A Systematic Literature Reviewcited by 70
- 2024Instruction Tuning for Secure Code Generationcited by 63
- 2023Are ChatGPT and GPT-4 General-Purpose Solvers for Financial Text Analytics? A Study on Several Typical Taskscited by 59
- 2024Securing Large Language Models: Threats, Vulnerabilities and Responsible Practicescited by 36
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2024AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testingcited by 34
- 2023The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verificationcited by 32
- 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 26
- 2024Security of AI Agentscited by 24
- 2025The Scales of Justitia: A Comprehensive Survey on Safety Evaluation of LLMscited by 24
38 more
- 2024How secure is AI-generated Code: A Large-Scale Comparison of Large Language Modelscited by 23
- 2025Speed at the Cost of Quality: How Cursor AI Increases Short-Term Velocity and Long-Term Complexity in Open-Source Projectscited by 23
- 2023LLM for SoC Security: A Paradigm Shiftcited by 22
- 2025Security and Quality in LLM-Generated Code: A Multi-Language, Multi-Model Analysiscited by 18
- 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representationscited by 17
- 2024RePair: Automated Program Repair with Process-based Feedbackcited by 16
- 2023Efficient Avoidance of Vulnerabilities in Auto-completed Smart Contract Code Using Vulnerability-constrained Decodingcited by 14
- 2024HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Datacited by 14
- 2024Black-Box Adversarial Attacks on LLM-Based Code Completioncited by 13
- 2025Benchmarking Prompt Engineering Techniques for Secure Code Generation with GPT Modelscited by 12
- 2024An Investigation into Misuse of Java Security APIs by Large Language Modelscited by 11
- 2024Code Security Vulnerability Repair Using Reinforcement Learning with Large Language Modelscited by 10
- 2025SandboxEval: Towards Securing Test Environment for Untrusted Codecited by 10
- 2025Teaching an Old LLM Secure Coding: Localized Preference Optimization on Distilled Preferencescited by 10
- 2024From Vulnerabilities to Remediation: A Systematic Literature Review of LLMs in Code Securitycited by 9
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generationcited by 9
- 2025Hallucination by Code Generation LLMs: Taxonomy, Benchmarks, Mitigation, and Challengescited by 9
- 2025I Know Which LLM Wrote Your Code Last Summer: LLM generated Code Stylometry for Authorship Attributioncited by 9
- 2025Do LLMs Consider Security? An Empirical Study on Responses to Programming Questionscited by 8
- 2024A Controlled Experiment on the Energy Efficiency of the Source Code Generated by Code Llamacited by 7
- 2024INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulnesscited by 7
- 2024How Well Do Large Language Models Serve as End-to-End Secure Code Agents for Python?cited by 7
- 2025The Hidden Risks of LLM-Generated Web Application Code: A Security-Centric Evaluation of Code Generation Capabilities in Large Language Modelscited by 7
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2023Exploring the Limits of ChatGPT in Software Security Applicationscited by 5
- 2024Code Hallucinationcited by 5
- 2025Achilles Heel of Distributed Multi-Agent Systemscited by 5
- 2025How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-benchcited by 5
- 2023LUNA: A Model-Based Universal Analysis Framework for Large Language Modelscited by 4
- 2024Stars, Stripes, and Silicon: Unravelling the ChatGPT's All-American, Monochrome, Cis-centric Biascited by 4
- 2025Automated Consistency Analysis of LLMscited by 4
- 2025Paladin: Defending LLM-enabled Phishing Emails with a New Trigger-Tag Paradigmcited by 4
- 2024CodeCloak: A Method for Evaluating and Mitigating Code Leakage by LLM Code Assistantscited by 3
- 2024"You still have to study" -- On the Security of LLM generated codecited by 3
- 2024Can LLM Prompting Serve as a Proxy for Static Analysis in Vulnerability Detectioncited by 3
- 2025Is Your Prompt Poisoning Code? Defect Induction Rates and Security Mitigation Strategiescited by 3
- 2026The End of Code Review: Coding Agents Supersede Human Inspectioncited by 3
- 2024A Comprehensive Framework for Evaluating API-oriented Code Generation in Large Language Modelscited by 2
50 most cited of 77 All 77 (JSON)
- 2026Beyond Static Guarantees: Measuring the Static-Pass Dynamic-Fail Gap in Security-Sensitive and LLM-Generated Python Code9 Sep 2026
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration26 Aug 2026
- 2026Vibe Coding and Web Application Security: A Twin-Prompt Study21 Aug 2026
- 2026Large Language Models for Code Generation from Multilingual Prompts: A Curated Benchmark and a Study on Code Quality16 Jul 2026
- 2026Understanding the Impact of AI Code Assistants on Security API Usage: An Empirical Study13 Jul 2026
- 2026An Empirical Study of Security Calibration in Large Language Models for Code30 Jun 2026
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026Activating Latent Security Knowledge through LLM-Guided Risk Analysis for Secure Code Generation15 Jun 2026
- 2026AI-driven Software Development: A Pragmatic Path to Agentic Development Processes13 Jun 2026
- 2026The End of Code Review: Coding Agents Supersede Human Inspection11 Jun 2026
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods22 May 2026
- 2026Security of LLM-generated Code: A Comparative Analysis21 May 2026
38 more
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Development20 Apr 2026
- 2026Surgical Repair of Insecure Code Generation in LLMs17 Apr 2026
- 2026DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregation10 Apr 2026
- 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision2 Mar 2026
- 2025LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Models24 Nov 2025
- 2025Speed at the Cost of Quality: How Cursor AI Increases Short-Term Velocity and Long-Term Complexity in Open-Source Projects6 Nov 2025
- 2025Is Your Prompt Poisoning Code? Defect Induction Rates and Security Mitigation Strategies27 Oct 2025
- 2025CLASP: Training-Free LLM-Assisted Source Code Watermarking via Semantic-Preserving Transformations13 Oct 2025
- 2025TypePilot: Leveraging the Scala Type System for Secure LLM-generated Code13 Oct 2025
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practices8 Oct 2025
- 2025Secure-Instruct: An Automated Pipeline for Synthesizing Instruction-Tuning Datasets Using LLMs for Secure Code Generation8 Oct 2025
- 2025Paladin: Defending LLM-enabled Phishing Emails with a New Trigger-Tag Paradigm8 Sep 2025
- 2025Amazon Nova AI Challenge -- Trusted AI: Advancing secure, AI-assisted software development13 Aug 2025
- 2025Small Data Explainer -- The impact of small data methods in everyday life15 Jul 2025
- 2025How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-bench30 Jun 2025
- 2025I Know Which LLM Wrote Your Code Last Summer: LLM generated Code Stylometry for Authorship Attribution18 Jun 2025
- 2025Do Generative AI Tools Ensure Green Code? An Investigative Study10 Jun 2025
- 2025The Scales of Justitia: A Comprehensive Survey on Safety Evaluation of LLMs6 Jun 2025
- 2025Teaching an Old LLM Secure Coding: Localized Preference Optimization on Distilled Preferences31 May 2025
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs27 May 2025
- 2025Hallucination by Code Generation LLMs: Taxonomy, Benchmarks, Mitigation, and Challenges29 Apr 2025
- 2025The Hidden Risks of LLM-Generated Web Application Code: A Security-Centric Evaluation of Code Generation Capabilities in Large Language Models29 Apr 2025
- 2025Achilles Heel of Distributed Multi-Agent Systems10 Apr 2025
- 2025SandboxEval: Towards Securing Test Environment for Untrusted Code27 Mar 2025
- 2025Do LLMs Consider Security? An Empirical Study on Responses to Programming Questions20 Feb 2025
- 2025Automated Consistency Analysis of LLMs10 Feb 2025
- 2025Benchmarking Prompt Engineering Techniques for Secure Code Generation with GPT Models9 Feb 2025
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generation5 Feb 2025
- 2025Security and Quality in LLM-Generated Code: A Multi-Language, Multi-Model Analysis3 Feb 2025
- 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representations22 Jan 2025
- 2025Cyber Shadows: Neutralizing Security Threats with AI and Targeted Policy Measures3 Jan 2025
- 2024From Vulnerabilities to Remediation: A Systematic Literature Review of LLMs in Code Security19 Dec 2024
- 2024Can LLM Prompting Serve as a Proxy for Static Analysis in Vulnerability Detection16 Dec 2024
- 2024Evaluating and Improving the Robustness of Security Attack Detectors Generated by LLMs27 Nov 2024
- 2024Stars, Stripes, and Silicon: Unravelling the ChatGPT's All-American, Monochrome, Cis-centric Bias2 Oct 2024
- 2024A Comprehensive Framework for Evaluating API-oriented Code Generation in Large Language Models23 Sep 2024
- 2024AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testing16 Sep 2024
- 2024HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Data10 Sep 2024
50 newest of 77 All 77 (JSON)
- 2024AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testingcited by 34
- 2024Security of AI Agentscited by 24
- 2025Speed at the Cost of Quality: How Cursor AI Increases Short-Term Velocity and Long-Term Complexity in Open-Source Projectscited by 23
- 2024How Well Do Large Language Models Serve as End-to-End Secure Code Agents for Python?cited by 7
- 2025Achilles Heel of Distributed Multi-Agent Systemscited by 5
- 2025How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-benchcited by 5
- 2026The End of Code Review: Coding Agents Supersede Human Inspectioncited by 3
- 2026AI-driven Software Development: A Pragmatic Path to Agentic Development Processescited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forwardcited by 0
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaborationcited by 0
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration26 Aug 2026
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026AI-driven Software Development: A Pragmatic Path to Agentic Development Processes13 Jun 2026
- 2026The End of Code Review: Coding Agents Supersede Human Inspection11 Jun 2026
- 2025Speed at the Cost of Quality: How Cursor AI Increases Short-Term Velocity and Long-Term Complexity in Open-Source Projects6 Nov 2025
- 2025How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-bench30 Jun 2025
- 2025Achilles Heel of Distributed Multi-Agent Systems10 Apr 2025
- 2024AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testing16 Sep 2024
- 2024How Well Do Large Language Models Serve as End-to-End Secure Code Agents for Python?20 Aug 2024
- 2024Security of AI Agents12 Jun 2024
- 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 130
- 2023A Survey of Safety and Trustworthiness of Large Language Models through the Lens of Verification and Validationcited by 91
- 2024When LLMs Meet Cybersecurity: A Systematic Literature Reviewcited by 70
- 2024Instruction Tuning for Secure Code Generationcited by 63
- 2023Are ChatGPT and GPT-4 General-Purpose Solvers for Financial Text Analytics? A Study on Several Typical Taskscited by 59
- 2024Securing Large Language Models: Threats, Vulnerabilities and Responsible Practicescited by 36
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2023The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verificationcited by 32
- 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 26
- 2025The Scales of Justitia: A Comprehensive Survey on Safety Evaluation of LLMscited by 24
- 2024How secure is AI-generated Code: A Large-Scale Comparison of Large Language Modelscited by 23
- 2023LLM for SoC Security: A Paradigm Shiftcited by 22
12 most cited of 59 All 59 (JSON)
- 2026Beyond Static Guarantees: Measuring the Static-Pass Dynamic-Fail Gap in Security-Sensitive and LLM-Generated Python Code9 Sep 2026
- 2026Vibe Coding and Web Application Security: A Twin-Prompt Study21 Aug 2026
- 2026Large Language Models for Code Generation from Multilingual Prompts: A Curated Benchmark and a Study on Code Quality16 Jul 2026
- 2026Understanding the Impact of AI Code Assistants on Security API Usage: An Empirical Study13 Jul 2026
- 2026An Empirical Study of Security Calibration in Large Language Models for Code30 Jun 2026
- 2026Activating Latent Security Knowledge through LLM-Guided Risk Analysis for Secure Code Generation15 Jun 2026
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods22 May 2026
- 2026Security of LLM-generated Code: A Comparative Analysis21 May 2026
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Development20 Apr 2026
- 2026Surgical Repair of Insecure Code Generation in LLMs17 Apr 2026
- 2026DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregation10 Apr 2026
- 2025LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Models24 Nov 2025
12 newest of 59 All 59 (JSON)