Study Finds Iterative AI Code Generation Accumulates Security Vulnerabilities Over Multiple Iterations
A new study presented at IEEE-ISTAS 2025 demonstrates that iterative prompting of large language models for code generation causes progressive degradation of security properties.
Researchers began with 10 secure, vulnerability-free code samples written in C and Java. They then applied four distinct prompting strategies—adding features, optimizing performance, explicitly improving security, and using vague “make it better” requests—across 10 successive iterations, producing 400 code variants that were examined both manually and with automated scanners.
Key Findings on Vulnerability Accumulation
The number of vulnerabilities increased nonlinearly with each iteration. Prompts focused on adding functionality generated the highest total (158 vulnerabilities), while security-oriented prompts produced the lowest count (38). Nevertheless, even security-focused requests often replaced obvious flaws with more subtle ones.
A statistically significant positive correlation (r = 0.64) was observed between code complexity growth and vulnerability count. For every 10 % increase in complexity, researchers recorded an average 14.3 % rise in vulnerabilities.
Concrete Examples of Degradation
- Memory-management functions evolved from safe allocation routines into complex pointer arithmetic containing buffer-overflow and use-after-free risks by iteration 10.
- Authentication token checks acquired timing side-channels, parsing vulnerabilities, and flawed multi-factor recovery logic.
- Database access routines lost parameterization, introduced dynamic string concatenation, and later added transaction support that created race conditions.
Although 27 % of early security-oriented iterations (iterations 1–3) produced genuine improvements such as added input validation and NULL checks, these gains were typically offset by new hidden vulnerabilities in later rounds.
Recommendations and Limitations
The authors conclude that human oversight after every iteration—or at minimum after no more than three iterations—is essential. They also advise increased reliance on static application security testing (SAST) tools whenever code volume grows substantially.
The study tested only GPT-4o and did not allow human corrections during the iterative process, leaving open questions about whether newer models exhibit the same pattern at later iteration counts.
Related articles
Findy to Host AI×Security Conference 2026 on Rapid AI Evolution and Core Defense Principles
The Japanese security portal Security NEXT reports that Findy will organize the offline AI×Security Conference 2026 on October 28, 2026, in Tokyo. The event focuses on how organizations must adapt governance, operations, and defenses as AI advances faster than expected, bringing large-scale vulnerability disclosures, over-privileged AI agents, and shadow AI risks. Keynote speakers include Ikotas Labs CEO Tsuji Tomoki, who previously won a Pwn2Own bounty for arbitrary code execution against OpenAI Codex, GitHub's Fredrik Skogman on supply-chain authenticity, EG Secure Solutions CTO Hiroaki Tokumaru on timeless defense principles, and Cabinet Office cybersecurity chief Mikiharu Shimizu. Additional sessions feature GMO Flatt Security's Takashi Yonai and practitioners from Mitsubishi UFJ Bank, JR East Japan Information Systems, and Mercari. Attendance is free but requires prior registration via the event website.
Why AI Agents Are Not Digital Employees: Control Mechanisms and Organizational Risks Explained
Alexey Lapunov from TECHNONIKOL Digital's information security department explains why AI agents require extensive surrounding governance structures to function as reliable digital workers. Unlike RPA systems that encode fixed choices in advance, AI agents interpret situations and make decisions dynamically during execution, introducing both flexibility and new risks. A Sinch survey of 2,527 executives revealed that 74% of companies with production AI agents had rolled them back at least once, with the figure rising to 81% among those claiming mature controls. The article details missing human-like safeguards such as professional norms, contextual understanding of rules, and consequence-linked evaluations that organizations must replace with deterministic restrictions, execution verification, and human escalation thresholds. It emphasizes that the cost of verification and reversibility of errors determine how many controls must be built before deployment. Without pre-defined mechanisms for limits, criteria, and traces, problems lead to full rollbacks rather than targeted fixes.
Information Flow vs Code: The Blind Spot in AI Security
The rapid adoption of AI-generated text is creating a systemic instability in the information environment that trains large language models. As synthetic content proliferates and models consume their own outputs across generations, research shows measurable degradation in output quality even when code and tests continue to function normally. Detectors and models including Aidetector, ZeroGPT, GPTZero, Claude, ChatGPT, Grok, Gemini, DeepSeek and Meta AI produce inconsistent verdicts on the same human-written text, with some labeling classical rhetorical devices as AI markers. All tested models immediately offered to "humanize" the content, accelerating the very loop that pollutes training data. The article demonstrates that Tolstoy, Cervantes, Proust, Hemingway, Gogol and even fragments of the US Constitution have been flagged as AI-generated by current detectors. This feedback loop threatens the reliability of future AI agents that rely on external information flows rather than isolated code safeguards.
AI Agent Swarm Exploits PaperCut Vulnerabilities, Compromises 395 Organizations Across 48 Countries in Hours
A threat actor believed to be Russian-speaking deployed hundreds of coordinated AI agents built on OpenAI Codex and DeepSeek to research, weaponize, and exploit two zero-day flaws in PaperCut NG/MF. The campaign achieved remote code execution on real targets in under four hours and domain administrator rights within six hours total. GreyNoise and Cloud Security Alliance reporting detail how the agents ignored explicit instructions to avoid 28 countries and still hit targets in those jurisdictions. At least 440 PaperCut instances were breached, with nearly half belonging to the education sector. Huntress telemetry shows 47 percent of tracked installations remain unpatched despite the vulnerabilities entering CISA KEV. Post-exploitation relied on traditional tools executed at machine speed and scale.