Skip to content
CyberReviewed

AI-Generated Code Security Statistics 2026

CyberReviewed Research Desk ·

Our analysts reviewed Veracode's GenAI Code Security Reports from July 2025 through its October 2026 update, a USENIX Security 2025 study of package hallucinations across 576,000 code samples, Apiiro's analysis of AI-assisted commits in enterprise repositories, the BaxBench secure coding benchmark, and the Stack Overflow 2025 Developer Survey, to measure how secure AI-generated code is as of Q4 2026.1

Key Findings

  • AI models passed an average of 62% of Veracode security tests in October 2026, up from 56% in July 2026 and 55% in the first report in 2025.
  • Cross-site scripting and log injection remain the weakest spots: models passed only 18% and 12.6% of those tests, against 83% for SQL injection and 87% for cryptography.
  • Java was the riskiest language in Veracode's 2025 tests, with a 72% security failure rate, compared with 45% for C#, 43% for JavaScript, and 38% for Python.
  • Across 2.23 million package suggestions, 19.7% named packages that do not exist; open-source models hallucinated at 21.7%, versus 5.2% for commercial models.
  • In Apiiro's repository data, AI-assisted code produced more than 10,000 new security findings a month by June 2025, ten times the December 2024 level.

AI-generated code security is the share of code written by large language models and coding assistants that contains exploitable flaws, such as injection bugs, broken access control, or references to fake software packages. This report covers benchmark pass rates, weakness types, languages, package hallucinations, and what happens in real repositories.

Our analysts took each figure as published. Benchmark results come from controlled tasks, so they show how often models write vulnerable code when asked, not how often that code reaches production. Repository figures from Apiiro come from its own customer data.

How Often AI-Generated Code Fails Security Tests

Veracode runs the same set of coding tasks against each new generation of models and checks the output for known weakness classes, which makes its pass rate the most consistent measure over time.23

Veracode average security pass rate for AI-generated code
SnapshotAverage security pass rateShare of tasks with a vulnerability
July 2025 (first report)55%45%
July 202656%44%
October 202662%38%

Source: Veracode.234

Line chart of Veracode average security pass rate for AI-generated code: 55% in July 2025, 56% in July 2026, and 62% in October 2026
Average share of Veracode security tests passed by AI-generated code.

Source: Veracode.234 Chart: CyberReviewed.

Key Findings

  • Models now produce code that compiles almost 100% of the time, but security pass rates moved only one point in the year to July 2026.2
  • The October 2026 jump to 62% was the largest gain since Veracode began the series; ten models cleared 60%, up from four in July.4
  • The two best models passed 73% of security tests in October 2026, so even the top performers failed about one task in four.4
  • Reasoning models averaged 56% in July 2026, against 51% for models without a reasoning step.2

Which Security Flaws AI Code Gets Wrong

Pass rates vary far more by weakness type than by model, so the type of code a team generates matters as much as the tool it uses.25

Average AI security pass rate by weakness type, October 2026
Weakness (CWE)Pass rate
Cryptographic algorithms (CWE-327)87%
SQL injection (CWE-89)83%
Cross-site scripting (CWE-80)18%
Log injection (CWE-117)12.6%

Source: Veracode via NeoTeo.25

Bar chart of AI-generated code security pass rates by weakness: 87% cryptography, 83% SQL injection, 18% cross-site scripting, and 12.6% log injection
Share of Veracode tests passed, by weakness type, October 2026.

Source: Veracode via NeoTeo.25 Chart: CyberReviewed.

Key Findings

  • Cross-site scripting rose from 15% to 18% between July and October 2026, the biggest single change in Veracode's dataset, but most XSS tests still fail.45
  • Log injection barely moved, from 12% to 12.6%, which means AI code that writes user input to logs is almost always unsafe without review.5
  • SQL injection and cryptography tests passed at 83% and 87%, the only two weakness types where most AI code was safe.25

AI Code Security by Programming Language

Veracode's 2025 tests across more than 100 models found that the language a model writes in changes the odds of a security flaw more than model size does.3

Security failure rate of AI-generated code by language, 2025
LanguageSecurity failure rate
Java72%
C#45%
JavaScript43%
Python38%

Source: Veracode.3

Bar chart of AI-generated code security failure rates by language: Java 72%, C# 45%, JavaScript 43%, and Python 38%
Share of Veracode coding tasks that failed security tests, by language.

Source: Veracode.3 Chart: CyberReviewed.

Key Findings

  • Java failed nearly three in four security tests, the worst of the four languages Veracode tested.3
  • Python was the safest at a 38% failure rate, though that still meant more than one flawed result in three.3
  • Across all four languages, 45% of AI code samples introduced an OWASP Top 10 vulnerability in 2025.3

Package Hallucinations in AI-Generated Code

AI models also invent software packages. An attacker who registers a hallucinated name can get malicious code installed by anyone who trusts the suggestion, an attack known as slopsquatting.6

Package hallucination rates across 16 code-generating models
MeasureFigure
Code samples generated576,000
Package suggestions analyzed2.23 million
Share that named nonexistent packages19.7%
Unique hallucinated package names205,474
Average rate, commercial models5.2%
Average rate, open-source models21.7%

Source: Spracklen et al., USENIX Security 2025.6

Column chart of package hallucination rates: 5.2% for commercial models and 21.7% for open-source models
Average share of suggested packages that do not exist, by model type.

Source: Spracklen et al.6 Chart: CyberReviewed.

Key Findings

  • 440,445 of the 2.23 million package suggestions pointed to packages that do not exist.6
  • Open-source models hallucinated packages at roughly four times the rate of commercial models.6
  • The study found 205,474 unique fake package names, each one a name an attacker could register.6

What the Figures Mean for Teams Shipping AI Code

Benchmarks and field data point the same way. Apiiro found AI-assisted developers cut syntax errors by 76% and logic bugs by 60%, but privilege escalation paths rose 322% and architectural design flaws rose 153%.7 BaxBench found that 62% of solutions from even the best model were incorrect or insecure, and about half of the correct ones were insecure.8

Developers are using the tools anyway: 84% of Stack Overflow's 2025 respondents use or plan to use AI in development, while 46% distrust the accuracy of the output.10 Earlier academic work found about 40% of Copilot programs vulnerable and showed that people using an assistant wrote less secure code while feeling more confident in it.911 Teams that generate code should scan it, pin and verify every dependency, and review authentication and logging code by hand.

Sources
  1. CyberReviewed analysis of Veracode, USENIX Security, Apiiro, BaxBench, Stack Overflow, and academic figures cited below
  2. Veracode, 2026 GenAI Code Security: Syntax is Solved, Security is Not, 2026
  3. Veracode, 2025 GenAI Code Security Report, July 2025
  4. TechRadar, AI-generated code is still frequently failing security checks, October 2026
  5. NeoTeo, Veracode's AI code benchmark shows uneven security results, October 2026
  6. Spracklen et al., We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs, USENIX Security 2025
  7. The Register, AI code assistants improve production of security problems, September 5, 2025
  8. BaxBench, Can LLMs Generate Correct and Secure Backends?
  9. Pearce et al., Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributions
  10. Stack Overflow, 2025 Developer Survey: AI
  11. Perry et al., Do Users Write More Insecure Code with AI Assistants?
Methodology

Pass rates and failure rates come from Veracode's published GenAI Code Security Reports and its October 2026 update, as reported by Veracode and by TechRadar and NeoTeo; they are benchmark results on fixed tasks, not production measurements. Weakness-level figures for October 2026 come from NeoTeo's summary of the Veracode update. Package hallucination figures come from the peer-reviewed USENIX Security 2025 study by Spracklen and colleagues. Repository trends come from Apiiro data as reported by The Register. CyberReviewed did not rerun any benchmark. Where sources differ in date or method, we report each figure with its source and period.

More statistics

All statistics
Bar chart of zero trust adoption figures: 96% favor zero trust, 81% plan to implement within 12 months, 65% plan to replace VPNs, and 63% have implemented a strategy

Zero Trust Statistics 2026

We combined Gartner and Zscaler survey data, CISA's 2026 report to Congress on federal zero trust, and Grand View Research market sizing to show how far zero trust adoption has come in 2026.