Black Friday is here! Level up your AI & AppSec skills. Save 40% with LEVELUP40.

AI Code Security: Why Scanners Miss What AI Gets Wrong

PUBLISHED:
December 2, 2026
|
BY:
Abhay Bhargav
Ideal for
Security Leaders

AI code security is the practice of finding and preventing the vulnerabilities that AI coding assistants introduce into software, from insecure snippets to flawed authorization design and hallucinated dependencies. The models are getting better at the first problem. Your team still owns the other two.

Good news first. In October 2026, Veracode reported the first real jump in AI code security since it started tracking it: the average security pass rate climbed from 56% to 62%, and vulnerable outputs dropped from 44% to 38% (Veracode).

Now the bad news. That still means more than a third of AI-generated tasks ship with a flaw. And Veracode's benchmark measures snippets. It can't measure the thing that actually hurts you.

Design.

When Apiiro studied code from Fortune 50 repositories, it found AI-assisted developers cut syntax errors by 76%. Privilege escalation paths went up 322%. Architectural design flaws rose 153% (Apiiro). Apiiro's own summary: AI is fixing the typos but creating the timebombs.

That's the whole problem in one sentence. You're measuring the typos.

What's in this post

  1. AI writes cleaner code and worse systems
  2. Your scanners were built for a smaller blast radius
  3. Hallucinated packages turn the supply chain into a guessing game
  4. Developers already distrust AI output, and they still merge it
  5. A practical AI code security program has four parts

1. AI writes cleaner code and worse systems

An AI assistant sees a prompt and a context window. It doesn't see your trust boundaries, your tenancy model, or the reason your payments service never talks to the user service directly.

So it does what you asked. It writes a working endpoint. It wires up a role check. It passes tests.

It also gives the service account admin rights because that made the integration work on the first try.

None of those flaws look wrong in a diff. The code compiles, the logic holds, the test suite goes green. The flaw lives in a decision nobody made on purpose: who can call this, with what identity, and what happens when that identity gets stolen.

My team and I have run over 700 threat models. The flaws that cause real damage almost never sit in a single function. They sit in the relationships between components. AI multiplies the number of those relationships per sprint, and nobody is reviewing them.

2. Your scanners were built for a smaller blast radius

SAST finds SQL injection in a function. It doesn't find a missing authorization check on an endpoint that looks perfectly normal. DAST finds reflected XSS. It doesn't find that a new microservice trusts an internal header any caller can forge.

Volume makes this worse. Apiiro found AI-assisted developers produced 3–4x more commits, packed into fewer, larger pull requests, and by June 2025 AI-generated code was adding over 10,000 new security findings a month across its study, a 10x spike in six months (Apiiro).

Think about what that does to code review. A reviewer looking at a 40-file PR is checking whether it works. They aren't redrawing the data flow diagram.

Scanners still matter. Run them. But treat them as the floor. They catch implementation bugs. Your AI-era risk sits a layer above implementation.

3. Hallucinated packages turn the supply chain into a guessing game

Here's a risk that didn't exist before AI assistants: dependencies that never existed.

A USENIX Security 2025 study generated 576,000 Python and JavaScript samples across 16 LLMs and found roughly 20% recommended at least one non-existent package (The Register). Commercial models hallucinated about 5.2% of package suggestions. Open models hit 21.7%.

Attackers noticed. They register those phantom names on npm and PyPI, load them with a post-install payload, and wait for an assistant to suggest the same name again. Seth Larson named it slopsquatting.

The hallucinations aren't random, either. In July 2026, researcher Aleksandr Churilov found the same 127 fake package names produced by five different LLMs (InfoWorld). Repeatable hallucinations mean predictable targets.

(Typosquatting needed a human to fat-finger a name. Slopsquatting only needs an agent that runs pip install without asking.)

4. Developers already distrust AI output, and they still merge it

The 2025 Stack Overflow Developer Survey found 84% of developers use or plan to use AI tools. Only 33% trust the accuracy of the output, and just 3% trust it highly (Stack Overflow).

So your developers don't trust it. They ship it anyway.

That isn't hypocrisy. It's deadline math. Leadership mandated AI adoption, the velocity targets moved, and review time stayed flat. Distrust without a process to act on it is just anxiety.

The fix isn't telling developers to "be careful with AI." They already are. Give them a way to check the things AI gets wrong.

5. A practical AI code security program has four parts

Threat model before you prompt. Ten minutes on trust boundaries, identities, and data flows before a developer asks an assistant to build a feature. Put those constraints into the prompt and the rules file, or go further with spec-driven development so the spec carries the security requirements. An assistant that knows "this service must never hold write access to the ledger" writes different code than one that doesn't.

Review AI PRs for design, not syntax. Add three questions to every AI-heavy pull request: What new identity or permission does this introduce? What new trust boundary does it cross? What new dependency does it pull in? Anything you can't answer means the PR goes back.

Lock down the dependency path. Pin versions, use a private registry or package firewall, and block agents from installing packages that aren't already on an allowlist. Hooks and OS-level sandboxing in your coding harness let you enforce that rule at runtime instead of hoping the agent behaves. Verify every new dependency against the registry before it hits requirements.txt or package.json.

Train developers on how AI fails, and how to fence it in. Watching a video about AI-generated vulnerabilities doesn't build the instinct to spot an over-permissive role in a 40-file diff. Your developers need to recognize the patterns AI repeats, and they need to know how to configure the harness itself: permissions, guardrails, secrets handling. That's the gap the AI Code Security learning path is built to close.

None of this slows you down much. All of it beats the incident.

Faster code needs earlier security

AI is getting better at writing secure code. Veracode's latest numbers prove it. But better snippets don't fix flawed systems, and your systems are where attackers live.

Ask yourself three questions. Who on your team reviews the design decisions an AI assistant makes? Can your developers spot a privilege escalation path that compiles cleanly? Would your pipeline stop an agent from installing a package that didn't exist last week?

If any answer makes you wince, start there. AppSecEngineer's AI Code Security learning path walks developers, security champions and architects through six courses on securing tools like Claude Code and Codex: sandboxing coding harnesses, using hooks as guardrails, VibeReview, keeping secrets from leaking, and spec-driven development.

Ship fast. Just stop shipping timebombs.

‍

Abhay Bhargav

Blog Author
Abhay builds AI-native infrastructure for security teams operating at modern scale. His work blends offensive security, applied machine learning, and cloud-native systems focused on solving the real-world gaps that legacy tools ignore. With over a decade of experience across red teaming, threat modeling, detection engineering, and ML deployment, Abhay has helped high-growth startups and engineering teams build security that actually works in production, not just on paper.
4.6

Koushik M.

"Exceptional Hands-On Security Learning Platform"

Varunsainadh K.

"Practical Security Training with Real-World Labs"

Gaël Z.

"A new generation platform showing both attacks and remediations"

Nanak S.

"Best resource to learn for appsec and product security"

Ready to Elevate Your AI Security Training?

Empower your teams with the skills they need to secure AI agents, LLM applications, and the software they power — before attackers find the gaps first.
Get Started Now
4.6

Koushik M.

"Exceptional Hands-On Security Learning Platform"

Varunsainadh K.

"Practical Security Training with Real-World Labs"

Gaël Z.

"A new generation platform showing both attacks and remediations"

Nanak S.

"Best resource to learn for appsec and product security"

Ready to Elevate Your Security Training?

Empower your teams with the skills they need to secure your applications and stay ahead of the curve.
Get Our Newsletter
Get Started
X

Not ready for a demo?

Join us for a live product tour - available every Thursday at 8am PT/11 am ET

Schedule a demo

No, I will lose this chance & potential revenue

x
x