AI code ships faster. So do the bugs
AI-written code runs fine and still fails security tests almost half the time. Here's what the data says, why it happens, and six checks before you ship.
I use AI to write code. So does pretty much every developer I know.
So this isn't a "stop using AI" article. That would be like telling people to stop using the internet.
It's about something that gets left out of the excitement. AI made writing code a lot faster. It did not make that code safe. And a lot of people are quietly treating those as the same thing.
What the data says
Veracode tests AI models on coding tasks and then checks the output for security holes. Their Spring 2026 update has two numbers that tell the whole story.
Code that's written correctly, as in it actually runs: up from about 50% in 2023 to above 95% now.
Code that's secure: still stuck around 55%. In about 45% of cases, the model introduced a known security flaw. That number has stayed in the same range across model generations.
That last one surprised me the most. Cross-site scripting is one of the oldest tricks on the web. The models passed that test only 15% of the time.
So the code looks right. It runs. It passes the demo. And almost half the time there's a hole in it.
It's showing up in the real world too
Researchers at Georgia Tech have been tracking publicly reported security vulnerabilities that trace back to AI-written code. As of March 2026 they had 74 confirmed cases, 35 of them in March alone. And they think the real number is 5 to 10 times higher, because most of it is hard to trace back to an AI tool.
Then there's speed. Apiiro compared developers who use AI assistants with those who don't, and found the AI group was committing code at 3 to 4 times the rate. Over the six months they tracked, to mid 2025, monthly security findings went from about 1,000 to more than 10,000.
Four times the speed. Ten times the problems.
Why does this happen?
Three reasons, and none of them are mysterious.
It learned from us. AI learned to code by reading a huge amount of public code. A lot of public code is insecure. So it picked up our bad habits along with the good ones.
It's built to make things work. You ask for a login page, you get a login page. You didn't ask for one that survives an attack, so that's not what it optimised for. "Works" and "safe" are two different goals, and only one of them is visible when you hit run.
It doesn't know your system. It can't see who your users are, what data is sensitive, or what the rest of your code assumes. A security decision that's fine in one app is a disaster in another. The AI is guessing.
The weird new one: packages that don't exist
This one is new, and it's kind of wild.
Sometimes AI tells your code to use a software package that doesn't exist. It just makes up a name that sounds right. One study looked at 576,000 AI-generated code samples and found that about 20% referenced packages that didn't exist.
Sounds harmless. The code just fails, right?
Here's the catch. The AI tends to make up the same fake names again and again. So attackers work out which names it likes, and register real packages under those names with something nasty inside. Next time the AI suggests it, the install works. And now their code is running inside your product.
Six checks before you ship
None of this needs a security team. It needs a habit.
- Read what you ship. If you can't explain what a piece of code does, it doesn't go out. That one rule catches more than any tool.
- Check every new package. Does it actually exist? Is it the one you meant? Has it been around for more than a few weeks? Thirty seconds each.
- Never trust what users type. Anything coming from outside gets checked before your code uses it or shows it on a page. This is exactly where the models fail most.
- Keep secrets out of the code. Passwords and keys never get pasted into a file. AI will happily put them there if you let it.
- Run a scanner. There are free tools that check code for known holes automatically. Set one up once and it runs on every change.
- Ask for a second opinion. Before you ship, start a fresh AI session and ask it to attack the code. "Find the security problems in this." It's a lot better at finding holes than at avoiding them the first time.
That last one sounds silly, but it works. Writing and reviewing are different jobs, even for AI.
Who's responsible?
This is the bit I care about most.
When AI-written code leaks customer data, nobody is going to accept "the AI wrote it". Not the customer, not the regulator, not your boss. Whoever shipped it owns it.
That's why I keep saying vibe coding is exposing developers, not replacing them. The typing got automated. The responsibility didn't.
AI made writing code fast.
Making it safe is still on you.