AI code models fail security checks 38% of the time, test finds
Frontier AI models are writing safer software than they did last year, but over a third of their output still contains exploitable flaws. A new benchmark study by Veracode found that 38% of AI-generated code continues to fail basic security checks, driven by deep blind spots in complex logic.
Frontier gains mask a shallow fix
Veracode evaluated 18 models across Python, C#, JavaScript, and Java against four common software vulnerability types. While overall code safety improved—rising from a 56% baseline to a 62% average pass rate—the underlying reason for the jump reveals a familiar limitation.
Almost all of the upward movement came from catching cross-site scripting (XSS) errors, an area where models improved by 18 percentage points. XSS flaws rely on predictable text patterns that large language models are structurally suited to identify and neutralize.
When security checks require tracing data across separate functions—such as preventing log injection or handling complex cryptographic implementations—the models hit a wall. In those categories, the software industry's top generative engines showed almost no progress over their predecessors.
The high cost of partial security
Anthropic's Claude Opus 5.5 and OpenAI's GPT-6-Sol topped the benchmark with a 73% security pass rate, inching past the 68% score set by GPT-5.5 earlier this year. Ten of the tested models now clear the 60% mark, compared to just four during the previous evaluation cycle.
Yet top-tier performance comes with steep inference costs. Running elite reasoning engines for code generation requires significant enterprise budgets, but even the category leaders still ship insecure code more than one out of every four times they are queried.
The findings mirror broader industry friction around autonomous developer tooling. Teams are already cautioning against reckless overuse, much like how Amazon warned engineers against AI tokenmaxxing to curb runaway compute costs, while a recent Gartner survey found just 3% of companies hit AI savings goals after aggressive rollouts.
Do not treat a passing compilation as secure software. The fact that models improved primarily on surface-level XSS checks confirms that LLMs are merely memorizing sanitization syntax, not reasoning about threat surfaces. If your engineering workflow lets AI-generated pull requests bypass human review or dedicated static application security testing, you are actively accumulating technical debt.
What it means for dev teams
For engineering organizations across North America and Europe, the takeaway is straightforward: generative code tools cannot bypass existing continuous integration pipelines. Veracode's data indicates that running a cheaper, mid-tier model paired with automated static analysis yields fewer production bugs than blindly trusting output from an expensive frontier tier.
Generative assistants have mastered the art of writing code that compiles and runs on the first try. Until these models develop genuine awareness of data flow across entire systems, human audit and automated security testing remain non-negotiable.
Frequently asked questions
Which AI models write the most secure code?
Claude Opus 5.5 and GPT-6-Sol currently lead the sector, each achieving a 73% pass rate on Veracode's security evaluations across four major programming languages.
Why do AI models struggle with code security?
Models excel at syntax patterns like sanitizing inputs against cross-site scripting, but they struggle with architectural reasoning across multiple functions, such as tracing sensitive data flows or preventing injection attacks.
Sources
- AI-generated code is still frequently failing security checks — with Claude and GPT-6 topping the leader board | TechRadar. techradar.com, 2026. https://www.techradar.com/pro/security/ai-generated-code-is-still-frequently-failing-security-checks-with-claude-and-gpt-6-topping-the-leader-board