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
| Snapshot | Average security pass rate | Share of tasks with a vulnerability |
|---|---|---|
| July 2025 (first report) | 55% | 45% |
| July 2026 | 56% | 44% |
| October 2026 | 62% | 38% |
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
| 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
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
| Language | Security failure rate |
|---|---|
| Java | 72% |
| C# | 45% |
| JavaScript | 43% |
| Python | 38% |
Source: Veracode.3
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
| Measure | Figure |
|---|---|
| Code samples generated | 576,000 |
| Package suggestions analyzed | 2.23 million |
| Share that named nonexistent packages | 19.7% |
| Unique hallucinated package names | 205,474 |
| Average rate, commercial models | 5.2% |
| Average rate, open-source models | 21.7% |
Source: Spracklen et al., USENIX Security 2025.6
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
- CyberReviewed analysis of Veracode, USENIX Security, Apiiro, BaxBench, Stack Overflow, and academic figures cited below
- Veracode, 2026 GenAI Code Security: Syntax is Solved, Security is Not, 2026
- Veracode, 2025 GenAI Code Security Report, July 2025
- TechRadar, AI-generated code is still frequently failing security checks, October 2026
- NeoTeo, Veracode's AI code benchmark shows uneven security results, October 2026
- Spracklen et al., We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs, USENIX Security 2025
- The Register, AI code assistants improve production of security problems, September 5, 2025
- BaxBench, Can LLMs Generate Correct and Secure Backends?
- Pearce et al., Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributions
- Stack Overflow, 2025 Developer Survey: AI
- 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.