AI-Generated Code Vulnerability Varies Greatly by Framework, Study Finds
A new report reveals that the security risks introduced by AI-generated code are not uniform, but rather depend heavily on the programming framework used, with some combinations proving significantly more vulnerable than others.

A comprehensive study by software governance firm Secure Code Warrior, in collaboration with RMIT University, has quantified the security risks associated with AI-generated code, revealing that the choice of programming framework plays a more critical role than the specific AI model used. The "AI Trust Index" evaluated 1,760 codebases generated by 16 leading AI models from major vendors like OpenAI, Anthropic, and Google. The findings indicate that AI-generated code introduces an average of 15 vulnerabilities per codebase, with over 4 vulnerabilities rated as critical or high severity, totaling more than 27,000 vulnerabilities across all tested samples.
While the study aimed to rank AI models based on the security of the code they produce, it found no single "best" or "worst" AI model across the board. Instead, the research highlighted that each AI model exhibits a distinct "security fingerprint," consistently producing predictable patterns of vulnerabilities. For instance, models from Anthropic and OpenAI appeared at both the top and bottom of the overall trust scores, suggesting that general performance is less indicative of risk than specific use cases.
The most significant revelation from the AI Trust Index is the strong correlation between AI model performance and the programming framework it is paired with. A model that performs exceptionally well within one framework, such as Django, might falter significantly or miss crucial security controls when used with another, like C-Basic. This variability underscores the need for organizations to understand these specific model-framework interactions rather than relying on generalized AI model security ratings.
Researchers also noted that the cost of using an AI model had little to no bearing on the security of the code it generated. The most common security failures stemmed from omissions, such as a lack of authentication checks or input validation, rather than actively malicious code. Furthermore, the study found that the risk introduced by AI-generated code was largely predictable, with the combination of model and framework determining the likelihood and type of vulnerabilities that would emerge.
According to Secure Code Warrior CEO Pieter Danhieux, the risk disparity between the highest and lowest scoring framework-model pairings was substantial, with some combinations being up to 40 times riskier than others. Frameworks like JavaScript and Java EE/JSP were identified as carrying significant exposure, while C# and Java Spring showed much lower vulnerability rates. This suggests that organizations should pay close attention to the frameworks they employ for AI-assisted development.
Danhieux advises organizations to implement security gates and mandatory training for teams working with AI in high-risk development environments. He also recommends prioritizing security training on the most common and impactful vulnerabilities that appear across all tested models, such as sensitive data leakage into logs, cross-site scripting (XSS), hard-coded credentials, predictable session tokens, and path traversal. These are well-understood threats for which established defense playbooks already exist.
The findings suggest that while AI coding tools offer efficiency gains, their integration requires a nuanced approach. Organizations must move beyond simply adopting AI tools and instead focus on understanding the specific security implications of each model-framework combination. This includes rigorous testing, tailored training, and the implementation of robust security practices to mitigate the predictable risks associated with AI-generated code.
Ultimately, the report emphasizes that the responsibility lies with organizations to manage the security of AI-assisted development. By understanding the framework-dependent nature of AI-generated code vulnerabilities and focusing on established security best practices, businesses can harness the power of AI while minimizing their exposure to new and evolving security threats.