Vibe coding is not magic: where AI leaves holes in production
AI writes code that works, not code that is secure. I show, without jargon, where vibe-coded apps leak in production and how to patch the holes.

State of knowledge: 17 November 2026.
A few sentences typed into a chat and the app is ready. That is vibe coding. The problem starts when that app reaches real users, and a few days later it turns out someone has downloaded the whole database.
Why does that happen? AI produces code that works, but not code that is secure. It is not a flaw in the models. It is simply a consequence of what you ask them for. A general guide on keeping AI-written code safe is on the portal, in the hub on AI code security. Here I focus on four specific holes.
Why does AI skip security?
When you write “add login”, AI has one goal: make the login work. And it works. But programmers know that every feature should have extra safeguards around it: checking that the user really has access, keeping different customers’ data apart, blocking excessive traffic.
AI doesn’t add that, because nobody asked it to. The result: the app works, but it is open to anyone who knows where to look.
Below I describe the four places where this gap shows up most often.
1. The database as an open safe
NeonDB and similar serverless PostgreSQL services usually work differently from Supabase. You connect to the database on the server side, through a secret connection string that should never reach the browser. That is good. One note: Neon also has a Data API, through which the browser queries the database directly. Then all the protection comes from permissions and RLS rules in the database itself, because the Data API has no permission layer of its own. Still, the problem lies elsewhere.
When AI generates API code or server functions, it creates database queries, but often without checking whose data it should return. The query SELECT * FROM orders WHERE id = $1 will return the order with the given ID to anyone who calls the endpoint and passes any ID. A logged-in user can browse other users’ data this way. All it takes is changing one parameter in the request.
AI writes code that works for the correct flow: the user clicks “my orders” and sees their own. That another user can pass someone else’s ID and see it too, AI doesn’t check, because the only instruction it got was “show the order”.
The fix is one extra condition in every query: WHERE id = $1 AND user_id = $2, where the second parameter comes from the server session, not from the user’s request. PostgreSQL also offers a built-in mechanism, Row-Level Security (RLS), which enforces this isolation at the level of the database itself, no matter what the programmer writes.
One line of code, a huge difference in performance
Even with RLS protection switched on, you can make a mistake in how you write it. An incorrect rule checks the user’s identity for every row separately. The correct version does it once, at the start. In Supabase’s tests on a table with 100,000 rows, just wrapping the function that checks the user in
(select ...)cut the query from about 179 to 9 milliseconds, roughly 20 times faster.
There is also the matter of the connection string, the string of characters with the database password. If it accidentally ends up in a Git repository, gets embedded in client code or shows up in logs, the database is open to anyone who finds it. When AI generates code examples, it sometimes pastes the connection string straight into the code instead of referring to an environment variable.
2. Server functions: an entrance with no door
In modern frameworks (like Next.js) you can write code that runs on the server but looks like an ordinary function in a file. The problem: that function is in fact reachable from the internet like any web page.
What does that mean? Someone doesn’t have to open your app in a browser at all. They can send a request straight to that function from their own script, with made-up data. If there is no check inside for who is asking, the system will carry out the command.
AI writes code that works when a user with the right permissions clicks a button. That the same function can be called without the button and without logging in is something AI doesn’t take into account.
Good protection takes three things:
- Data validation: rejecting everything that doesn’t look like the expected data, before anything is executed
- Identity check: every function checks whether the user asking really has the right to do this
- Ownership check: whether this user owns the resource they want to modify (not just whether they are logged in)
An extra risk: server code sometimes accidentally sends data to the browser that should never leave the server, for example password hashes from the database, when a function returns the whole record instead of the few fields it needs.
3. The session: a key left in plain sight
When you ask AI to “add login”, the most common result is a session token (the key to the account) stored in the browser’s local storage. Simple, and it works. But it is one of the most common sources of stolen accounts.
Every script running on your page can read that storage. Not just your code: every external library, every chat widget, every dependency installed by someone else. A script reads the key, sends it somewhere else, and from that moment the attacker can act as your user.
The fix is to save that key in a cookie with the httpOnly option. A cookie like that is completely invisible to scripts. No code on the page can read it, only the server.
A fake session token: an unexpected hole in libraries
There is a class of attacks where the attacker sends a specially crafted session token that tells the server “don’t check the signature”. Libraries that don’t block this will accept such a token and let the intruder in. Checking whether your session library is immune to this is one line in the configuration: a list of allowed signing algorithms, without “none”.
Next is session lifetime. If a session key is valid for 24 hours and someone intercepts it, they have 24 hours of full access. Shortening the lifetime and refreshing the session regularly shrinks the window in which a stolen key is useful by a lot.
By the way: how you store passwords in the database matters too. Outdated hashing settings (hashing turns a password into a safe string of characters) can mean that after a database leak the passwords can be recovered in a reasonable time. Today OWASP recommends Argon2id (at least 19 MiB of memory), and bcrypt only in older systems, with a cost of at least 10.
4. A server besieged by bots
A Node.js server (Next.js runs on it too) executes JavaScript in one main thread, so in practice it does one thing at a time. Picture a till in a shop: it serves one person at a time, the rest wait. If someone holds up that till for a very long time, everyone stands and waits.
With no limit on the size of uploaded data, an attacker can send a 100 MB file to the server. The server has to process it before rejecting it, and that can take a few seconds during which it serves nobody else. In an example from the Node.js documentation, just parsing 50 MB of JSON text took 1.3 seconds. One attack blocks all users. Some frameworks have a default limit (Server Actions in Next.js accept at most 1 MB), but every other endpoint and every raised limit has to be checked separately. A few lines of configuration are enough to avoid it. AI doesn’t add them by default. You can also put a traffic limit in front of the app: I described how to do it on the free Cloudflare plan, with WAF and rate limiting separately.
Webhooks (automatic notifications from external services, for example Stripe sending information about a payment) are a common weak point too. Without verifying that the notification really came from Stripe, anyone can send a fake event, say “payment accepted”, and get access to the product without paying.
Code review doesn’t work with vibe coding
The traditional way of looking after security assumes someone checks the code before deployment. In vibe coding that stage gets skipped: the app goes to users straight from a conversation with AI. Security has to be part of the code itself, not an extra stage “to do later”.
What to do about it?
None of these safeguards is complicated on its own. The hard part is putting all of them in place, consistently, without missing one. That is what the checklist is for, along with an AI agent that can work through it point by point. Just keep an eye on what that agent does and what it saves for later. For myself I built an AI agent that shows under every result what it remembered and what it cost.
The rule is simple: every part of the system has to defend itself, independently of the others. The database itself controls who sees which data. Every server function checks for itself whether the person asking has the right. No data goes any further before it has been verified.
Common questions
Does this apply to small projects too?
Yes. Automated scripts scanning the internet don’t tell small services from big ones. They look for unprotected endpoints and mistakes in access checks, whatever the size of the project.
Is NeonDB unsafe?
No. It is standard PostgreSQL and a well-designed service. But a database on its own doesn’t know which user should see which data. It is the programmer (or an AI agent with the right checklist) who has to add the right conditions to every query.
Will AI break my code if I ask it for security fixes?
Not if you give it precise instructions. The same model that skipped the safeguards while building the app will implement them perfectly if it gets a checklist with exact steps. Below is exactly that kind of checklist.
Do I have to understand the code to implement this?
You don’t have to write it. That is what the AI agent is for. You have to understand what you want, so you can judge whether the agent did the job properly. This post gives you exactly that understanding.
Implementation file for your agent
The problems described above translate into 50 concrete tasks grouped into five stages:
- Database: switching on protection, tuning access rules, enforcing data isolation
- Server functions: data validation, identity checks, protection against access without permission
- Session and login: safe session storage, resistance to account takeover, strong password hashing
- Server and webhooks: traffic limits, protection against overload, payment verification
- Infrastructure: vulnerability scanner, application firewall, Zero Trust
Every task comes with a ready code example and a way to check that it works.
Download the implementation checklist for your agent (Markdown)
I work with people 1:1 under the delta240mvt brand. On your project, from the first step.
See the offer ↗

