Blog
AI-Generated Code Security: What the 2026 Data Shows
Security & legacy

AI-Generated Code Security: What the 2026 Data Shows

Key takeaways
  • Veracode's 2026 GenAI Code Security Report: AI-generated code passes security tests only 56% of the time, and model size makes no difference.
  • More than 70% of developers use AI tools every day, yet 48% trust the output only when they can easily verify it (Stack Overflow Developer Survey 2026).
  • 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

Veracode's 2026 GenAI Code Security Report, published in July, tracks more than 100 large language models across four rounds of testing. The central findings:
  • The average security pass rate is 56%: given no security-specific guidance, models produce insecure code nearly 44% of the time. Veracode calls the result virtually unchanged since its previous report.
  • Syntax is correct almost every time, so the insecure code compiles and runs.
  • Results vary by language: Python passes 63% of the time, Java only 30%.
  • Model size has no effect on security: large models average 53%, medium and small models 51%. Coding-specialised models (51%) do no better than general-purpose ones (52%).
  • The best of the 11 models on the current leaderboard passes 68% of the time, the weakest 50%.
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 2026, with more than 30,000 responses from 169 countries, shows the tension inside teams. More than 70% of respondents use AI tools every day, and 73% use coding assistants and agents daily. At the same time, 48% say they trust AI output only when they can easily verify it, and 93% rate cited sources as important for checking AI-generated answers.
Trust that depends on verification 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:
  1. Secret scanning on every commit and across the existing history.
  2. Dependency and licence checks in CI, with an owner for updates.
  3. Authorisation tests for every endpoint and data table that holds customer data.
  4. Automated tests on the paths that make money — sign-up, checkout, billing, exports.
  5. Human review of security-sensitive changes, regardless of who or what wrote them.
  6. 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.
Bonsay's AI-generated code audit is built for this situation: senior engineers review code written with Cursor, Copilot, Claude, Lovable or Bolt — secrets, authentication, payments and tests — and deliver a report and fix plan in 5–10 days, from €3k.

Sources