# Security Degradation in Iterative AI Code Generation -- A Systematic Analysis of the Paradox

arXiv: https://arxiv.org/abs/2506.11022 · HTML: https://mlsanity.com/paper/2506.11022/

## Key facts

- Cited by 10 papers in the map (data through 14 Oct 2026).
- Builds on 7 of its 21 references that are in the map.
- First posted on arXiv 19 May 2025.

## Builds on (most cited first, 7 of 7)

- [Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributions](https://mlsanity.com/paper/2108.09293/) (2021)
- [Do Users Write More Insecure Code with AI Assistants?](https://mlsanity.com/paper/2211.03622/) (2022)
- [LLM Critics Help Catch LLM Bugs](https://mlsanity.com/paper/2407.00215/) (2024)
- [Programming Is Hard -- Or at Least It Used to Be: Educational Opportunities And Challenges of AI Code Generation](https://mlsanity.com/paper/2212.01020/) (2022)
- [Refining ChatGPT-Generated Code: Characterizing and Mitigating Code Quality Issues](https://mlsanity.com/paper/2307.12596/) (2023)
- [Artificial-Intelligence Generated Code Considered Harmful: A Road Map for Secure and High-Quality Code Generation](https://mlsanity.com/paper/2409.19182/) (2024)
- [LLM4CVE: Enabling Iterative Automated Vulnerability Repair with Large Language Models](https://mlsanity.com/paper/2501.03446/) (2025)

## Built on by (most cited first, 10 of 10)

- [AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Software](https://mlsanity.com/paper/2512.18567/) (2025)
- [VibeCodeHPC: An Agent-Based Iterative Prompting Auto-Tuner for HPC Code Generation Using LLMs](https://mlsanity.com/paper/2510.00031/) (2025)
- [The Kitchen Loop: User-Spec-Driven Development for a Self-Evolving Codebase](https://mlsanity.com/paper/2603.25697/) (2026)
- [Unlocking LLM Code Correction with Iterative Feedback Loops](https://mlsanity.com/paper/2606.17514/) (2026)
- [SoK: Understanding (New) Security Issues Across AI4Code Use Cases](https://mlsanity.com/paper/2512.18456/) (2025)
- [Human-Certified Module Repositories for the AI Age](https://mlsanity.com/paper/2603.02512/) (2026)
- [Secure Coding Drift in LLM-Assisted Post-Quantum Cryptography Development: A Gamified Fix](https://mlsanity.com/paper/2606.19474/) (2026)
- [The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Reprompting](https://mlsanity.com/paper/2607.23710/) (2026)
- [Vibe Coding and Web Application Security: A Twin-Prompt Study](https://mlsanity.com/paper/2608.20963/) (2026)
- [A Study of the Reliability of Agentic AI-Generated Programs](https://mlsanity.com/paper/2609.18298/) (2026)

## Abstract (arXiv)

The rapid adoption of Large Language Models(LLMs) for code generation has transformed software development, yet little attention has been given to how security vulnerabilities evolve through iterative LLM feedback. This paper analyzes security degradation in AI-generated code through a controlled experiment with 400 code samples across 40 rounds of "improvements" using four distinct prompting strategies. Our findings show a 37.6% increase in critical vulnerabilities after just five iterations, with distinct vulnerability patterns emerging across different prompting approaches. This evidence challenges the assumption that iterative LLM refinement improves code security and highlights the essential role of human expertise in the loop. We propose practical guidelines for developers to mitigate these risks, emphasizing the need for robust human validation between LLM iterations to prevent the paradoxical introduction of new security issues during supposedly beneficial code "improvements".
