Skip to content

AI-Generated Code Still Fails 38% of Security Tests Despite Gains, Veracode Finds

Veracode's 2026 GenAI Code Security Report finds AI coding security improving for the first time, but persistent injection flaws and weak Java performance demand stronger security testing. (Includes infographic)

Artificial intelligence is finally getting better at writing secure code. The problem is that it still gets security wrong nearly four times out of 10, and some of the vulnerabilities it struggles with most have barely improved.

That's the central finding from Veracode's 2026 GenAI Code Security Report and an October 29 research update showing the first meaningful security gains since the company began tracking AI-generated code in 2025.

The average security pass rate across tested models climbed from 56% to 62%, reducing the share of code-generation tasks producing detectable vulnerabilities from approximately 44% to 38%.

The improvement is significant. It is also uneven.

Most of the progress is concentrated in cross-site scripting (XSS), while log injection, a vulnerability requiring more contextual understanding of how data moves through applications, remains stubbornly resistant to improvement.

For CISOs, application security leaders and development teams embracing AI-assisted programming, the implications are clear: AI coding tools are becoming more capable, but organizations cannot rely on those tools to police their own security.

AI code security improves, but the gap remains

Veracode has tracked more than 100 large language models across multiple research snapshots, evaluating their ability to produce secure code without explicit security instructions.

Its latest testing covered 18 models across Python, C#, JavaScript and Java, examining four vulnerability categories: SQL injection, cryptographic weaknesses, cross-site scripting and log injection.

The results show meaningful progress after more than a year of relatively stagnant security performance.

Ten models now exceed a 60% security pass rate, compared with four in the previous assessment.

Anthropic's Claude Opus 5.5 and OpenAI's GPT-6-Sol share the top position at 73%, surpassing the previous high of 68% achieved by GPT-5.5.

But even those leading models failed more than one-quarter of the security tests.

Meanwhile, syntax correctness remains close to 100% across nearly all tested models.

That disparity exposes one of the most consequential risks in AI-assisted development: code can compile, execute and satisfy a developer's immediate requirements while introducing vulnerabilities that are not apparent from its functionality.

As organizations accelerate development with AI, the volume of potentially insecure code entering software pipelines can grow faster than security teams can evaluate it.

The concern is no longer whether AI can write working software. It is whether organizations can verify that software before vulnerabilities reach production.

The biggest security gains are coming from the easiest problems

A closer examination of Veracode's findings reveals why the improving headline numbers should be interpreted cautiously.

Security performance varies considerably depending on the vulnerability being tested.

Cross-site scripting showed the most notable improvement, although its overall pass rate remains extremely low.

Veracode attributes much of the progress to the ability of newer models to recognize established secure coding patterns, including safer approaches to handling untrusted content in web applications.

Log injection presents a different challenge.

Preventing it requires understanding how potentially malicious input moves through functions, transformations and logging operations. That demands contextual reasoning rather than simply selecting a familiar secure coding pattern.

The category's security pass rate remains near 12%, virtually unchanged from the previous assessment.

This distinction matters because enterprise applications rarely consist of isolated code snippets. Their security depends on how components interact, how data crosses trust boundaries and whether protections remain effective throughout the application.

Improvements in familiar coding patterns do not necessarily translate into an ability to identify complex vulnerabilities arising from those interactions.

Java remains a major AI coding security concern

Programming language also has a significant effect on security outcomes.

Python achieved a 64.22% pass rate in the October testing, followed by C# at 59.55% and JavaScript at 56.99%.

Java finished at just 31%.

That means approximately 69% of the tested Java code-generation tasks failed the security checks, compared with roughly 36% for Python.

The gap is particularly relevant for enterprises that depend on Java for business-critical applications, including financial systems, backend services and large-scale enterprise platforms.

Veracode's findings do not establish that all AI-generated Java applications are insecure at that rate. They do, however, indicate that the tested models struggle disproportionately with Java under the research conditions.

Organizations should account for that disparity when selecting coding assistants, establishing development policies and determining where to concentrate application security testing.

Bigger models are not a substitute for security controls

The research also challenges the assumption that more sophisticated AI models automatically produce substantially more secure software.

Large models averaged a 55% security pass rate, compared with 52% for medium models and 51% for small models.

General-purpose models averaged 54%, while coding-specialized models averaged 51%.

Although some newer, larger models perform better, the differences do not justify treating any model as inherently secure.

There is also an economic consideration.

Premium models can require greater computing expenditures, but even the highest-performing systems still generate vulnerable code in a substantial share of tested scenarios.

For organizations deploying AI coding assistants at scale, model selection should therefore account for security performance alongside development speed, operating costs and functionality.

The better approach is to combine productive coding models with independent security verification rather than assuming the most expensive model will deliver secure output.

Five actions security leaders should take now

Veracode's findings point to five practical priorities for organizations expanding AI-assisted development.

1. Treat all AI-generated code as untrusted

Require AI-generated code to meet the same security standards as human-written code before it reaches production.

Successful compilation, functional testing or an AI assistant's own assurance that its output is secure should never substitute for independent validation.

2. Put security testing directly into AI coding workflows

Integrate static application security testing, dependency analysis, secrets scanning and appropriate dynamic testing into development pipelines.

Security checks should operate during code creation and pull-request review, with release controls preventing unacceptable vulnerabilities from reaching production.

For agentic coding systems, establish controls that prevent agents from bypassing required reviews or changing security configurations without authorization.

3. Prioritize the vulnerabilities AI handles worst

Concentrate additional testing and human review on weaknesses where Veracode found particularly poor performance, especially log injection and cross-site scripting.

Use targeted security tests to examine untrusted input handling, output encoding, logging behavior and data flows across application components.

Apply additional scrutiny to Java projects, where the benchmark results indicate substantially weaker security performance.

4. Evaluate AI coding models on security, not just productivity

Test approved models against representative internal development tasks and the languages, frameworks and vulnerability classes most relevant to the organization.

Measure vulnerability introduction rates, remediation effort and security performance alongside coding speed.

Reevaluate models as new versions arrive rather than assuming an upgrade automatically improves security.

5. Track whether AI is increasing security debt

Measure how many vulnerabilities AI-assisted development introduces, how quickly they are detected and how long remediation takes.

Prioritize flaws based on exploitability, application exposure and business impact rather than raw vulnerability counts.

Include third-party dependencies in that assessment. AI-generated first-party code is only one component of the software supply chain.

The larger problem: Security debt is already growing

The AI coding findings become more concerning when considered alongside Veracode's broader application security research.

According to its 2026 State of Software Security Report, 82% of organizations carry security debt, defined as known vulnerabilities that have remained unresolved for more than a year.

That figure increased from 74% in 2025.

Critical security debt affects 60% of organizations, while the median time required to fix a vulnerability stands at 243 days.

Third-party software presents another major obstacle. Veracode found that 66% of the most dangerous long-lived vulnerabilities originate in third-party code, with an average remediation time of 358 days.

Those findings illustrate a broader challenge for organizations adopting AI coding tools.

If software production accelerates without comparable improvements in vulnerability detection and remediation, organizations risk expanding an already substantial backlog of security problems.

AI may help developers produce more code. It does not automatically give security teams the resources or capabilities to evaluate and maintain that code.

The takeaway: AI coding is improving, but verification must keep pace

Veracode's latest findings offer legitimate grounds for optimism.

For the first time since the research began, measurable improvements in AI-generated code security are appearing across multiple models.

But the remaining weaknesses are substantial, and the improvement is concentrated in vulnerabilities that are comparatively easier for models to recognize and avoid.

The harder problems, particularly those requiring contextual understanding of application behavior, remain largely unresolved.

For security leaders, the answer is not to abandon AI-assisted development. It is to stop treating functional AI-generated code as evidence of secure software.

The organizations best positioned to benefit from AI coding will be those that make independent security verification, risk-based remediation and secure development controls as automatic as the code generation itself.

AI can write the code faster. Security teams still have to make sure it is safe.

Related:

30 Years of Raising Awareness with Chris Wysopal
Chris Wysopal joins CYBR.SEC.CAST to discuss software security, vendor accountability, liability, and the future of secure tech.
Chris Wysopal Says Awareness Won't Fix Cybersecurity
Cybersecurity pioneer Chris Wysopal argues that awareness campaigns have failed and that software liability and accountability are needed to improve security.

Latest