VYPR
researchPublished Jul 24, 2026· 1 source

AI-Generated Code Across Major Models Riddled with Exploitable Security Flaws

A new study reveals that automation scripts generated by ChatGPT, Copilot, and Gemini consistently contain exploitable security vulnerabilities, posing significant risks to enterprises.

A recent academic study from Beacom College of Computer & Cyber Sciences has uncovered a systemic issue in AI-assisted code generation: every automation script produced by leading models like ChatGPT, Microsoft Copilot, and Google Gemini contained exploitable security vulnerabilities. This finding is particularly concerning as organizations increasingly turn to AI tools to accelerate software development and streamline workflows, potentially introducing significant risks if unreviewed AI-generated code is deployed directly into production environments.

To conduct the research, identical, standardized prompts were issued to ChatGPT, Copilot, and Gemini to generate Python scripts for three common enterprise tasks: web scraping, email automation, and file workflow automation. The goal was to evaluate the security quality of the AI-generated code without the influence of prompt bias. The researchers then used an automated review process, simulating how a non-expert user might vet the code, to identify security findings.

This automated review process surfaced a total of 45 individual security findings, which were then deduplicated into 17 distinct vulnerability classes. Each identified vulnerability was scored using the CVSS 3.1 framework, mapped to the OWASP Top 10, and cross-referenced with the MITRE ATT&CK framework. The study's results indicate that the security flaws are not unique to any single AI provider but are rather systemic across the board.

Vulnerability counts were remarkably consistent across the platforms: ChatGPT's scripts contained 13 vulnerabilities, Copilot's had 14, and Gemini's featured 12. The overlap was also significant, with 9 out of the 17 unique vulnerability classes appearing in code generated by all three AI models (a 53% overlap), and 14 present in at least two platforms (an 82% overlap). This suggests that the inherent nature of the requested tasks, rather than the specific AI model chosen, is the primary driver of these security risks.

Among the most prevalent vulnerabilities identified were Server-Side Request Forgery (SSRF) in web scraper scripts, allowing potential attackers to probe internal networks; Path Traversal flaws in scraper, email, and file-watcher scripts due to unsanitized file paths; Injection Flaws, including email header and template injection, in email automation scripts enabling message tampering; and Symlink Vulnerabilities in file-watcher scripts leading to arbitrary file manipulation. Additionally, overly broad exception handling was noted, which could silently swallow security-critical errors.

The detailed CVSS 3.1 scoring revealed that critical flaws span network handling, file systems, and input parsing logic. A Pareto analysis indicated that just 11 of the 17 vulnerability classes account for approximately 80% of the total weighted risk, with SSRF, template injection, email header injection, and path traversal topping the list. When mapped against the Lockheed Martin Cyber Kill Chain, these flaws cover critical stages such as initial access, execution, credential access, and lateral movement.

The implications are significant because automation scripts often run with the permissions of the executing user or host environment. An unvetted script could interact with sensitive corporate resources like shared drives or internal SMTP servers without requiring secondary privilege escalation. These risks are compounded by broader threats in the AI ecosystem, such as prompt injection attacks or vulnerabilities in AI workflows that could expose underlying enterprise services.

To mitigate these risks, organizations are advised to establish clear guardrails for AI-assisted software development. This includes mandating security reviews for all AI-written code before production deployment, restricting execution permissions for LLM-generated scripts, prioritizing fixes for high-severity vulnerabilities like SSRF and path traversal, and educating staff on the distinction between functional and secure code. The study underscores the critical need for human oversight and robust security practices when integrating AI into the software development lifecycle.

Synthesized by Vypr AI