
Key facts.
- Veracode 2025: 100+ models, 80 tasks, 45% of AI-generated code introduced an OWASP Top 10 vuln. Java: 72% fail rate. XSS: 86% fail rate.source
- Security failure rate: flat. Models got dramatically better at syntax. Not at security. Same holes, cleaner surface.source
- Models trained on public code, which has bugs. They reproduce insecure patterns with full confidence.source
Why does fluent code hide insecure code?
Syntactic quality and security are different things. The model is good at one. It produces code that compiles, runs, and reads well. That's exactly what makes a reviewer relax. Then it embeds an injection-prone query, missing validation, or a weak default, because those patterns are all over the training data. Nearly half of generated code carries a known vulnerability. That share hasn't fallen as models got better at looking correct. The agent that feels like a productivity win is also a steady source of security debt. In code that looks too clean to question. The work shifted from writing code to catching what the code got wrong. Skip the catching, and you just shipped the vulnerability faster.
A better model isn't the fix. Veracode found newer, larger models don't generate more secure code. The insecurity is in the patterns, not the fluency. More capability gives you the same failure rate in nicer-looking code.

What gate actually protects the repo?
Automated security scanning on every generation, before the code merges, plus correctness checks the agent did not run on itself. Treat AI-generated code as untrusted input to your codebase, the same way you treat any external contribution and run it through static analysis, dependency checks and tests as a hard gate rather than a suggestion. Where the scanner flags a known vulnerability class, block the merge. The point is that the agent's confidence is not evidence of security, and Veracode's number says it is wrong about security nearly half the time, so the gate has to be the thing that decides, not the agent.
| Handling of generated code | What reaches the repo |
|---|---|
| Trust the fluent output | Vulnerabilities at a measured rate |
| Gate every generation | Insecure code caught before merge |
Gating generation against those patterns is part of what VibeModel does as the Pattern Intelligence Layer. We model the patterns of insecure and incorrect generated code and check for them before merge, so a coding agent accelerates your team without quietly accumulating the security debt the model is prone to.
Frequently asked questions
Does a sharper model close the code-security gap?
Veracode found 45% of AI code carries an OWASP hole, unmoved as models grew; a newer model hides it, so the gate stops rework. (arXiv:2108.09293)
Will a better model reduce the vulnerabilities?
Veracode found newer, larger models do not produce meaningfully more secure code. The fix is the security gate, not the model.
Isn't scanning every generation slow?
It is far cheaper than shipping a vulnerability. Automated scanning as a merge gate adds little time and catches the 45% problem.
Why is the code insecure if it looks clean?
The model learned insecure patterns from public code and reproduces them fluently. Clean syntax is not evidence of security.

