AI-Generated Code Has a Security Problem, and Your Build Inherits It

0

min read

Digital illustration of a data security concept showing a glowing green cloud with server racks connected by streams of data to a blue segmented pipeline that is sparking as it connects to a translucent digital fortress marked with warning symbols and padlocks, representing cybersecurity and data protection.

AI-generated code security is a supplier question before it is a technology question. The tools produce code with measurable security defects, and if the agency building your software ships that code without a person and a scanner between the model and your product, the defects are yours. Your name is on the login page, your customers’ data is behind it, and the supplier has been paid.

We build with these tools ourselves. The argument is about process, and about what to demand from anyone who writes software for you in 2026.

Is AI-generated code less secure than code written by hand?

Yes, on the current evidence, by a wide enough margin to plan around. Veracode’s 2026 GenAI Code Security Report (July 2026) tested 11 new models across 80 tasks and found an average security pass rate of 56 per cent, barely changed from 55 per cent a year earlier. Roughly 44 per cent of tasks introduced a vulnerability, the best model still failed almost one in three, and on cross-site scripting the pass rate was 15 per cent. A year of bigger models did not move the number.

The Stanford study used a 2022-era model, so the tool has moved on, but the human finding has not: people with an assistant wrote worse code and felt better about it. A review process exists to break that combination.

Why does your build inherit the risk?

Because after handover the code is yours, and almost nobody checks how it was made. The government’s Cyber Security Breaches Survey 2025/2026 (April 2026) found 43 per cent of UK businesses had a breach or attack in the last year, rising to 65 per cent of medium and 69 per cent of large firms. Only 15 per cent had reviewed the risk from their immediate suppliers. Your software agency is one of those suppliers.

Because after handover the code is yours, and almost nobody checks how it was made. The government’s Cyber Security Breaches Survey 2025/2026 (April 2026) found 43 per cent of UK businesses had a breach or attack in the last year, rising to 65 per cent of medium and 69 per cent of large firms. Only 15 per cent had reviewed the risk from their immediate suppliers. Your software agency is one of those suppliers.

Two of the inherited risks are new. The first is the fictional package problem above, which OWASP now ranks third in its Top 10 for 2025 as Software Supply Chain Failures, a new category. The second is licensing: a Peking University benchmark, LiCoEval (ICSE 2025), found 0.88 to 2.01 per cent of generated code was strikingly similar to existing open-source code, and that models rarely reported the licence. One per cent sounds small until it is a GPL-licensed block inside the product you sell, which can oblige you to publish your source.

Why doesn’t more AI review fix it?

Because the volume outruns the review, and the mistakes have moved from the visible kind to the invisible kind. Apiiro’s study of Fortune 50 repositories (September 2025, vendor research) found AI-assisted developers produced three to four times more commits and ten times more security findings, while trivial syntax errors fell 76 per cent and privilege-escalation paths rose 322 per cent. The code compiles, the tests pass, the demo works, and the hole is in the permissions model where only an experienced reviewer would look.

So the answer is a senior engineer plus tooling, in that order: scanning catches the known patterns, and a person who has shipped software catches the design flaw no scanner has a rule for. That review is what you are paying an agency for, and this post is the security half of that argument.

What should you demand from a supplier that builds with AI?

Evidence of the safeguards, in writing, before you sign. The NCSC’s own guidance on AI-assisted development (June 2026) puts it plainly: “The risk is not using AI. The risk is not applying the right safeguards when the stakes are high.” Login, payments, personal data and anything that talks to another system are high stakes by default. Ask for:

  • A named senior engineer who reviews every line a model writes before it reaches any environment you own, and the record that shows it happened.
  • Automated security testing and dependency scanning on every change, with results you can see.
  • A check that every package the code pulls in exists, is the one intended, and carries a licence you can use commercially.
  • Secrets scanning, because Apiiro found assisted developers exposed cloud keys almost twice as often.
  • A warranty that covers defects in generated code the same as hand-written code, with no carve-out.

On our own builds, a senior engineer reviews everything a model writes before it reaches a client environment, and automated tests and dependency checks run before anything reaches staging. [NEEDS SAM: confirm this sentence matches exactly what we run today, and name the tooling if you want it public.]

Should you avoid suppliers that use AI at all?

No. You should avoid suppliers who cannot describe their review process. The NCSC’s chief executive said in March 2026 that AI-produced code “currently poses intolerable risks for many organisations” and, in the same speech, that it offers “glimpses of a new paradigm”. Both are true, and an agency that pretends otherwise is either behind or not being straight with you.

The EU’s Cyber Resilience Act began its reporting obligations on 11 September 2026, with the main obligations applying from 11 December 2027, to any software or hardware with digital elements sold into the EU. If that includes you, the process above becomes something you have to evidence. Bespoke software built this year will still be running then.

Is AI-generated code less secure than code a developer writes by hand?
On current evidence, yes. Veracode’s July 2026 report found models introduced a vulnerability in roughly 44 per cent of tasks, and a 2023 Stanford study found developers using an assistant wrote SQL-injectable code five times as often as those without one.
If my supplier used AI to write my software and it is breached, who is liable?
Your contract decides. Ask for a warranty that treats generated code exactly like hand-written code, with no exclusion, and take legal advice on the wording.
Could AI-written code bring open-source licence obligations into my product?
Yes. The LiCoEval benchmark (ICSE 2025) found up to 2 per cent of generated code was strikingly similar to existing open-source code, with licences rarely reported. A licence scan before release is the control.
Does AI-generated code have to be reviewed by a person before it goes live?
It should be, every line. The NCSC’s June 2026 guidance says the risk is in skipping safeguards where the stakes are high, and Apiiro’s 2025 data shows the flaws have shifted to design and permissions errors that scanners miss.
What should we ask a supplier about regulated experience?

Check out more articles

We build products that perform. Let's build yours.