AI-Generated Code Introduces Novel Vulnerabilities, Report Finds
A new report by Theori reveals that AI-generated code often exhibits unique vulnerabilities that scale with application complexity, rather than common flaws like SQL injection.

A recent analysis of applications built using AI coding agents from OpenAI and Anthropic has uncovered a surprising trend: instead of replicating well-known security flaws, AI-generated code is introducing a new class of vulnerabilities that grow in complexity as the application itself expands.
Theori, a cybersecurity firm, constructed 28 distinct applications using five different AI models. These applications ranged from those built from detailed specifications to those generated from simple prompts or even rewritten from legacy codebases. The firm then subjected these AI-created apps to its automated penetration testing platform, expecting to find common issues like SQL injection and cross-site scripting (XSS).
Contrary to these expectations, the study found that common vulnerabilities were rare. The AI models demonstrated a surprising proficiency in avoiding these well-documented flaws, often employing prepared statements and input sanitization techniques automatically. Andrew Wesie, CTO at Theori, attributes this to the relative simplicity of these older vulnerability classes, which are easier for AI to learn and fix.
However, the report highlights that resource exhaustion and denial-of-service (DoS) vulnerabilities were prevalent, appearing in 21% of all findings and nearly every project. Issues such as unbounded pagination, lack of rate limiting, and synchronous processes blocking entire operations were common. These flaws, Wesie notes, require a deeper system-level understanding – knowing the expected request rates or file size limits – which AI models still struggle to grasp consistently.
Perhaps more concerning is the prevalence of secrets exposure, which accounted for nearly half of the critical findings. Hardcoded API keys, default secret values, and easily forgeable JWT secrets were frequently embedded, often stemming from quick-start templates within the AI's training data. These vulnerabilities pose a significant risk, potentially granting attackers broad access.
Access control vulnerabilities, particularly Insecure Direct Object References (IDOR), also showed a concerning trend. While present in only 11% of findings in smaller applications, this figure jumped to 28% in a rewritten content management system (CMS). This suggests that as applications grow in size and complexity, the AI-generated access control logic becomes more prone to gaps, allowing users to access data beyond their intended permissions.
After an initial scan yielded 8,827 detections, Theori meticulously filtered these down to 434 confirmed vulnerabilities by collapsing duplicates and building proof-of-concept exploits. The findings underscore a critical challenge for developers: the sheer volume of AI-generated code exacerbates the existing bottleneck of human code review. Wesie advocates for the increased use of automated review tools for line-by-line security checks, while reserving human expertise for higher-level tasks like threat modeling and architectural reviews.
The report concludes by emphasizing the need for rigorous evaluation of AI coding tools. Developers must ensure these tools are not just generating code but are actively contributing to security by producing code that is both functional and robust, avoiding the introduction of novel, complex vulnerabilities.