Artificial-Intelligence Generated Code Considered Harmful: A Road Map for Secure and High-Quality Code Generation
Not on the map. Why?
Abstract (arXiv)
Generating code via a LLM (rather than writing code from scratch), has exploded in popularity. However, the security implications of LLM-generated code are still unknown. We performed a study that compared the security and quality of human-written code with that of LLM-generated code, for a wide range of programming tasks, including data structures, algorithms, cryptographic routines, and LeetCode questions. To assess code security we used unit testing, fuzzing, and static analysis. For code quality, we focused on complexity and size. We found that LLM can generate incorrect code that fails to implement the required functionality, especially for more complicated tasks; such errors can be subtle. For example, for the cryptographic algorithm SHA1, LLM generated an incorrect implementation that nevertheless compiles. In cases where its functionality was correct, we found that LLM-generated code is less secure, primarily due to the lack of defensive programming constructs, which invites a host of security issues such as buffer overflows or integer overflows. Fuzzing has revealed that LLM-generated code is more prone to hangs and crashes than human-written code. Quality-wise, we found that LLM generates bare-bones code that lacks defensive programming constructs, and is typically more complex (per line of code) compared to human-written code. Next, we constructed a feedback loop that asked the LLM to re-generate the code and eliminate the found issues (e.g., malloc overflow, array index out of bounds, null dereferences). We found that the LLM fails to eliminate such issues consistently: while succeeding in some cases, we found instances where the re-generated, supposedly more secure code, contains new issues; we also found that upon prompting, LLM can introduce issues in files that were issues-free before prompting.
Key facts. Cited by 11 papers in the map (data through 7 Oct 2026). Builds on 15 of its 42 references that are in the map. First posted on arXiv 27 Sep 2024.
Builds on
15 of 42 references.
References · 15
- 2016Communication-Efficient Learning of Deep Networks from Decentralized Datacited by 7,592
- 2017Deep reinforcement learning from human preferencescited by 3,846
- 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,222
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2024Cybench: A Framework for Evaluating Cybersecurity Capabilities and Risks of Language Modelscited by 156
- 2024LLM Critics Help Catch LLM Bugscited by 138
- 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 112
- 2021Differential Privacy for Text Analytics via Natural Text Sanitizationcited by 74
- 2023Investigating and Designing for Trust in AI-powered Code Generation Toolscited by 34
- 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detectioncited by 32
- 2023Fully Autonomous Programming with Large Language Modelscited by 31
Built on by
Citing papers per year: 2025: 5; 2026: 6.
11 papers.
- 2025Speed at the Cost of Quality: How Cursor AI Increases Short-Term Velocity and Long-Term Complexity in Open-Source Projectscited by 23
- 2025Security Degradation in Iterative AI Code Generation -- A Systematic Analysis of the Paradoxcited by 10
- 2025Securing LLM-Generated Embedded Firmware through AI Agent-Driven Validation and Patchingcited by 3
- 2026Accountable Agents in Software Engineering: An Analysis of Terms of Service and a Research Roadmapcited by 3
- 2025Autonomous Legacy Web Application Upgrades Using a Multi-Agent Systemcited by 1
- 2025LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Modelscited by 1
- 2026Can AI Agents Generate Microservices? How Far are We?cited by 1
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Codecited by 1
- 2026LLMs + Security = Troublecited by 0
- 2026The Perfection Paradox: From Architect to Curator in AI-Assisted API Designcited by 0
- 2026The Vibe Shift in Software Engineering: Evaluating AI-Led Conversational Programming for Performance, Cognition, and Responsible Adoptioncited by 0
- 2026The Vibe Shift in Software Engineering: Evaluating AI-Led Conversational Programming for Performance, Cognition, and Responsible Adoption9 Sep 2026
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Code6 May 2026
- 2026Accountable Agents in Software Engineering: An Analysis of Terms of Service and a Research Roadmap6 May 2026
- 2026The Perfection Paradox: From Architect to Curator in AI-Assisted API Design12 Mar 2026
- 2026Can AI Agents Generate Microservices? How Far are We?9 Mar 2026
- 2026LLMs + Security = Trouble9 Feb 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
- 2025Securing LLM-Generated Embedded Firmware through AI Agent-Driven Validation and Patching12 Sep 2025
- 2025Security Degradation in Iterative AI Code Generation -- A Systematic Analysis of the Paradox19 May 2025
- 2025Autonomous Legacy Web Application Upgrades Using a Multi-Agent System31 Jan 2025