Security Vulnerability Patterns in AI-Generated Code: A Cross-Model Comparative Study

· Source: cs.SE updates on arXiv.org · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Cybersecurity & Data Privacy, Software Development & Engineering · Depth: Advanced, extended

Summary

A cross-model comparative study revealed that LLM-generated automation code for non-expert users consistently contains exploitable security vulnerabilities. Researchers used ChatGPT, Microsoft Copilot, and Google Gemini to generate nine Python automation scripts across three domains: web scraping, email automation, and file/workflow automation. Claude Code performed a standardized vulnerability review, identifying 45 findings, which deduplicated to 17 distinct vulnerability classes. Every script contained exploitable weaknesses. Nine of these 17 vulnerability classes appeared in code from all three models, and 14 appeared in at least two. Weighted CVSS v3.1 scores across platforms differed by less than 10%, indicating the risk is tied to the task category rather than a specific LLM. The study mapped vulnerabilities to OWASP Top 10:2021 and MITRE ATT&CK, highlighting critical risks like SSRF, path traversal, and template injection, which account for 80% of the total weighted exposure.

Key takeaway

For IT Professionals or Directors of AI/ML deploying LLM-generated automation scripts, recognize that these tools consistently introduce exploitable vulnerabilities, regardless of the specific model. Your organization should implement mandatory security reviews for all LLM-generated code entering enterprise workflows. Do not trust functional correctness as an indicator of security. Focus remediation efforts on high-impact vulnerabilities like SSRF and path traversal, and consider security-aware prompting as an initial mitigation.

Key insights

LLM-generated automation code inherently contains exploitable vulnerabilities, consistently across models and tasks.

Principles

Method

The study generated Python automation scripts from three LLMs using identical prompts, then reviewed them with Claude Code. Identified vulnerabilities were scored using CVSS v3.1 and mapped to OWASP Top 10:2021 and MITRE ATT&CK.

In practice

Topics

Best for: CTO, VP of Engineering/Data, Executive, AI Security Engineer, Director of AI/ML, IT Professional

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by cs.SE updates on arXiv.org.