mlsanityData to 7 Oct 2026

Artificial-Intelligence Generated Code Considered Harmful: A Road Map for Secure and High-Quality Code Generation

arXiv 2409.19182 ↗First posted 27 Sep 2024cs.CR cs.AIcited by 11

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

  1. 2016Communication-Efficient Learning of Deep Networks from Decentralized Datacited by 7,592
  2. 2017Deep reinforcement learning from human preferencescited by 3,846
  3. 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,222
  4. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  5. 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
  6. 2024Cybench: A Framework for Evaluating Cybersecurity Capabilities and Risks of Language Modelscited by 156
  7. 2024LLM Critics Help Catch LLM Bugscited by 138
  8. 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 112
  9. 2021Differential Privacy for Text Analytics via Natural Text Sanitizationcited by 74
  10. 2023Investigating and Designing for Trust in AI-powered Code Generation Toolscited by 34
  11. 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detectioncited by 32
  12. 2023Fully Autonomous Programming with Large Language Modelscited by 31
3 more
  1. 2024Rectifier: Code Translation with Corrector via LLMscited by 20
  2. 2024Unprecedented Code Change Automation: The Fusion of LLMs and Transformation by Examplecited by 15
  3. 2024The Fire Thief Is Also the Keeper: Balancing Usability and Privacy in Promptscited by 13

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 5; 2026: 6.

11 papers.