Short answer: In its 2025 GenAI Code Security Report, Veracode reported that 45% of AI-generated code samples introduced security flaws—only 55% were secure—and that this rate has not improved as models got larger. Java performed worst (29% secure) and Python best (62%). The takeaway is not to stop using AI. It is that AI-generated code must pass the same security scanning and review as any other code, because generation speed does not equal security.
AI coding tools are now nearly universal—GitHub’s 2024 developer survey cited by Veracode reports that 97% of developers have used them. That makes one question urgent: is the code they produce secure enough to trust by default? Veracode’s research gives an uncomfortable but useful answer.
What Veracode measured
Veracode’s 2025 analysis spanned over 100 large language models across 80 coding tasks, four programming languages, and four common vulnerability types. The headline result: only 55% of AI-generated code was secure, meaning 45% introduced a known security flaw.
Two findings deserve emphasis. First, the insecurity is not concentrated in old, weak models—Veracode reports the security pass rate has stayed roughly flat even as models became far better at producing syntactically correct code. Bigger and newer did not mean safer. Second, the risk varies sharply by language and vulnerability class.
| Language | Reported security pass rate |
|---|---|
| Python | 62% |
| JavaScript | 57% |
| C# | 55% |
| Java | 29% |
By vulnerability type, Veracode reported that models often handled SQL injection reasonably (about 80% secure) but struggled badly with cross-site scripting and log injection, generating insecure code the large majority of the time.
Why AI struggles with security specifically
The report attributes the gap to three structural causes, and they are worth understanding because they will not be fixed by a bigger model alone:
- Training data contamination. Models learn from public code that contains both secure and insecure patterns, so both look “normal.”
- Missing security context. A model generating a function rarely knows the application’s trust boundaries, so it produces code that works but omits controls.
- Limited dataflow reasoning. Deciding whether a variable holds untrusted input requires analysis current models do not reliably perform.
Functionally correct and secure are different targets, and today’s models optimize for the first.
What does not follow from 45%
A striking statistic invites overreaction. To keep the number honest:
- It does not mean 45% of code in production written with AI is exploitable; it is a controlled test across specific tasks and vulnerability types.
- It does not mean any single tool is 45% insecure; results vary by model, prompt, and language.
- It does not mean human-written code is flawless; it means AI does not remove the need for security review.
- It is vendor research from an application-security company. The methodology is reasonable and the direction matches other studies, but the exact figure is specific to Veracode’s test design.
The defensible reading is directional and strong: a large fraction of AI-generated code contains security flaws, and that fraction is not shrinking on its own.
What engineering teams should do
None of this argues against AI assistance. It argues for treating AI output as untrusted-until-verified—exactly how mature teams already treat any code entering the repository.
- Scan everything. Run SAST (and DAST where relevant) on AI-generated code before merge, not after an incident.
- Keep a human review gate. Require review for security-relevant changes; do not let generation volume erode oversight.
- Watch the weak spots. Give extra scrutiny to output handling (XSS), logging, and any language your team ships that scored poorly.
- Manage dependencies. AI can suggest packages that are outdated or do not exist; verify and pin them.
- Record it. Keep audit trails of AI-assisted changes and their reviews.
This is the same discipline behind the site’s pilot methodology and the hard security gates in the AI coding pilot scorecard. It also complements the agent-focused controls in our OWASP-aligned checklist: that piece is about what an agent can do; this one is about the code it writes.
Where a managed platform helps
Ad-hoc AI use on individual laptops makes “scan and review everything” hard to enforce. A platform that routes AI work through managed environments and a review workflow makes security gates a default rather than a hope. MonkeyCode’s public materials describe automated code review and a task-and-review workflow around AI changes; treat that as infrastructure for enforcing these controls, and verify current capabilities in the product documentation.
Bottom line
Veracode’s 45% is a healthy reality check: AI writes a lot of code, and a large share of it is not secure by default—regardless of how capable the model feels. The response is not prohibition or blind trust. It is to put AI-generated code through the same scanning and review as everything else, watch the known weak spots, and enforce those gates through workflow rather than willpower.
Source boundary: The 45% figure, language pass rates, and the observation that security has not improved with model size are from Veracode’s 2025 GenAI Code Security Report and accompanying blog, checked 20 July 2026. Veracode is an application-security vendor; the statistics reflect its test methodology and are directional evidence, not a universal measurement of every tool or codebase.