Key takeaways
- Veracode tested more than 100 models on 80 coding tasks: AI-generated code contained an OWASP Top 10 flaw in about 45% of cases, and larger models did not do significantly better.
- 84% of developers use or plan to use AI tools, yet 46% actively distrust their accuracy (Stack Overflow 2025).
- Git pushes grew 78% year on year in Q1 2026 (Microsoft) — review capacity did not grow at the same rate.
- The practical answer is not less AI but more verification: secret scanning, dependency checks, authorisation tests and human review of the paths that handle money and data.
Writing code has become cheap. Microsoft's Global AI Diffusion report for the first quarter of 2026 notes that git pushes — the moment developers publish code changes — rose 78% year on year, driven by tools such as Claude Code, OpenAI Codex and GitHub Copilot. The question for engineering leaders is no longer whether AI writes code in their organisation, but who checks it.
How often AI-generated code is insecure
In July 2025 Veracode published its GenAI Code Security Report, testing more than 100 large language models on 80 curated coding tasks. The central findings:
- In about 45% of cases the generated code introduced a vulnerability from the OWASP Top 10.
- When a secure and an insecure implementation were both possible, models chose the insecure one roughly 45% of the time.
- Results varied by language: Java failed most often (above 70%), while Python, C# and JavaScript ranged from 38% to 45%.
- Defences against cross-site scripting and log injection failed in 86% and 88% of relevant cases.
- Larger, newer models did not perform significantly better on security than smaller ones — Veracode reads this as a systemic issue rather than a scaling problem.
The pattern matches what code reviewers describe: AI output usually works for the happy path and is less reliable about the defensive details that are invisible in a demo.
Developers use it — and doubt it
The Stack Overflow Developer Survey 2025, with about 49,000 respondents, shows the tension inside teams. 84% of developers use or plan to use AI tools, up from 76% a year earlier. At the same time, 46% actively distrust the accuracy of AI output, compared with 33% who trust it; only about 3% trust it highly. The most common frustration, named by roughly two-thirds of respondents, is output that is almost right, but not quite.
Experienced developers are the most cautious group. That is consistent with where errors hide: in authorisation, edge cases and error handling — the parts that require knowing how a system is used.
Faster attackers, same old weaknesses
The State of AI Report 2026 adds the attacker's side. In one reported test, a frontier model built a working exploit for a known browser bug in 12 minutes. Documented intrusions in 2026 relied mostly on unprotected endpoints, weak credentials and injection flaws — the same categories that appear most often in AI-generated code. Faster exploitation combined with more code that has not been reviewed widens the window of exposure.
Where AI-built code usually fails
Reviews of products built largely with AI assistants or app builders tend to find the same groups of issues:
- Secrets in the repository — API keys and database URLs committed in code or history.
- Authorisation gaps — endpoints or tables that any logged-in user, or anyone, can read or change; disabled row-level security is a frequent example.
- Untested money paths — sign-up, payments and data exports without automated tests.
- Dependencies nobody chose — packages added by an assistant, outdated or with known CVEs, and no update routine.
- Architecture without boundaries — business logic, data access and presentation mixed together, little error handling and no logging.
- No owner — code that nobody on the team fully understands, which makes every later change risky.
Verification has to scale with generation
Large technology companies are applying AI to the review side as well. In the World Economic Forum's 2026 white paper on AI for cybersecurity, Google describes agents that search for unknown vulnerabilities and propose patches — with every patch reviewed by human researchers before submission. The principle generalises: AI can widen review coverage, but accountability for what ships stays with people.
For most teams, the practical controls are well known and inexpensive:
- Secret scanning on every commit and across the existing history.
- Dependency and licence checks in CI, with an owner for updates.
- Authorisation tests for every endpoint and data table that holds customer data.
- Automated tests on the paths that make money — sign-up, checkout, billing, exports.
- Human review of security-sensitive changes, regardless of who or what wrote them.
- Prompt-injection and data-leak checks for any feature that passes user input to a model.
What this means for 2027
Code volume will keep growing faster than the number of experienced reviewers. Organisations that treat AI as a way to generate more code without changing how code is verified will accumulate risk quietly — until a customer security questionnaire, an investor's technical due diligence or an incident makes it visible. Those that invest in verification will capture the speed without inheriting the debt.
Sources
- Veracode, 2025 GenAI Code Security Report, July 2025.
- Stack Overflow, Developer Survey 2025 — AI.
- Microsoft AI Economy Institute, Global AI Diffusion: Q1 2026 Trends and Insights, May 2026.
- Air Street Capital, State of AI Report 2026.
- World Economic Forum and KPMG, Empowering Defenders: AI for Cybersecurity, May 2026.