Vibe coding works. You describe the feature, AI writes the code, the app runs, customers use it. We are not here to tell you to stop. Speed is a real advantage and you should keep it.

But here is the thing. AI generates code that works, not code that is safe. And because all models learn from the same public code, they make the same mistakes. Not similar mistakes. The same ones, in almost every generated app.

We already wrote about what the research says on AI-generated vulnerabilities, with the studies and numbers. This post is the practical version. Ten concrete mistakes, why AI makes them, and for each one three things: a quick check you can run on your own app today, the security pattern that prevents the whole class of bug, and a free or open source tool that does the work. No security background needed, and nothing here costs money.

Grab your codebase and go through the list.


1. API keys and secrets sitting in the code

This is the number one finding, every time. You ask AI to connect to Stripe or OpenAI, it gives you working code with the key right there in the file. It works, you move on, the key gets committed. Now it is in your git history forever, and if the repo ever becomes public, or one contractor laptop gets compromised, the key is gone.

Quick check:

grep -rE "sk-|sk_live|AKIA|api_key.*=.*['\"]" --include="*.{js,ts,py,env}" .
git log -p | grep -cE "sk_live|AKIA"

If the second command returns more than 0, the key is in your history even if you deleted it from the code. Rotate it. Deleting the file is not enough.

Fix: keys live in environment variables, .env stays in .gitignore, and anything that ever touched git gets rotated. Then turn on secret scanning and push protection, it is free.

Pattern: centralised secrets management. Secrets live in one managed place, the app fetches them at runtime, nothing sensitive sits in code or config files. One place to rotate, one place to audit.

Free tools: HashiCorp Vault or Infisical if you want a proper secrets manager, both open source. For a small app, your platform’s built-in encrypted env vars (Vercel, Fly, Railway, GitHub Actions secrets) are enough to start. Add gitleaks in CI to catch leaks before they land.


2. Login is checked, ownership is not

AI is good at generating login. It is terrible at authorization. The typical generated endpoint checks that you are logged in, then happily serves any record you ask for:

// what AI generates
app.get('/api/invoices/:id', requireAuth, async (req, res) => {
  const invoice = await db.invoices.findById(req.params.id);
  res.json(invoice);
});

Any logged-in user can read any invoice of any customer just by changing the number in the URL. This bug is called IDOR and it is the most common critical finding in SaaS apps, vibe-coded or not. AI makes it worse because it generates this pattern by default.

Quick check: log in as user A, open something that belongs to you, then change the ID in the URL to another number. If you see someone else’s data, you have it.

Fix: every query that touches user data must filter by the owner too:

const invoice = await db.invoices.findOne({
  _id: req.params.id,
  userId: req.user.id   // this line is the whole fix
});

Pattern: centralised authorization. Ownership checks live in one policy layer that every endpoint goes through, not copy-pasted into each handler where AI will forget one. One place to review, one place to test.

Free tools: Casbin or Oso as a policy library inside your app, Open Policy Agent if you want policy as a separate service. All open source. If you are on Supabase or Postgres, row level security gives you the same guarantee at the database layer.


3. The admin role comes from the request

Ask AI to add roles and there is a good chance the role arrives from the client side: a field in the request body, a value in localStorage, or a flag in the JWT that the server never verifies properly. Anyone who opens browser dev tools can promote themselves.

Quick check: look at your update-profile or register endpoint. If role, isAdmin or plan can be sent in the request body and gets saved as is, that is the bug. This pattern is called mass assignment.

Fix: the server decides roles, never the client. Take only the specific fields you expect from the request, ignore everything else.

Pattern: input validation at the boundary. Every request body gets checked against an explicit schema before your logic sees it. Fields you did not declare simply do not exist. This one pattern also kills mistake 5 below.

Free tools: zod for TypeScript, pydantic for Python. Both free, both one import away, and FastAPI gives you pydantic validation out of the box.


4. CORS open to the whole internet

The app gets a CORS error during development, AI “fixes” it the popular way:

app.use(cors({ origin: '*', credentials: true }));

This tells browsers that any website is allowed to call your API. Combined with cookies or credentials, a random malicious page can act as your logged-in user.

Quick check:

grep -rn "origin: '\*'" --include="*.{js,ts}" .

Fix: list your real frontend domains, nothing else. CORS config is three lines, there is no reason to wildcard it.

Pattern: API gateway. One front door where CORS, auth checks and request rules are enforced for every endpoint, instead of hoping each route remembered its own config.

Free tools: if you are already behind Cloudflare, the free plan includes a basic WAF with managed rules, which also filters known attack patterns before they reach your app. Self-hosted, Traefik or Kong are open source gateways that do the same job.


5. Prices and limits trusted from the frontend

AI wires up the checkout exactly how you describe it, and if the frontend sends the price, the backend charges the price it received. Change 19.99 to 0.01 in dev tools and buy your product for one cent. Same story with quantity limits, discount codes and plan tiers.

Quick check: open dev tools, intercept the checkout or upgrade request, change the amount, send it. If it goes through, every one of your customers can do it too.

Fix: the server looks up prices from its own database or from Stripe. The frontend only sends the product ID. Anything money-related that arrives from the client is decoration, not data.

Pattern: server-side source of truth. Prices, plans, limits and discounts live on the server and only there. The same boundary validation from mistake 3 enforces it: if the schema does not accept an amount field, nobody can send one.

Free tools: none needed. Stripe price IDs instead of amounts, plus your zod or pydantic schema. This one is pure design.


6. No rate limiting anywhere

Generated apps almost never include rate limiting. Nobody asks for it, so AI does not add it. Result: your login endpoint accepts unlimited password guesses, your password-reset sends unlimited emails, and your expensive AI endpoint happily burns your OpenAI budget for whoever finds it.

Quick check: run a small loop against your login with wrong passwords:

for i in $(seq 1 50); do curl -s -o /dev/null -w "%{http_code} " \
  -X POST https://yourapp.com/api/login \
  -d '{"email":"[email protected]","password":"wrong'$i'"}' \
  -H "Content-Type: application/json"; done

Fifty 401s with no slowdown and no block means no protection.

Fix: one middleware, five minutes. express-rate-limit for Node, slowapi for FastAPI, or rate limiting at Cloudflare level before traffic even hits the app. Auth endpoints and anything expensive go first.

Pattern: rate limiting at the edge. Limits belong as far in front of your app as possible, so hostile traffic burns someone else’s CPU, not yours. App-level middleware is the fallback, not the first line.

Free tools: Cloudflare’s free plan includes one rate limiting rule, put it on your login endpoint. express-rate-limit and slowapi are free at the app layer. Self-hosted gateways like Traefik and Kong have rate limiting built in.


7. JWT done wrong

AI loves JWT and gets the details wrong in predictable ways: the signing secret is "secret" or "your-secret-key" straight from the tutorial, tokens never expire, and logout just deletes the token from the browser while it stays valid on the server side forever.

Quick check:

grep -rnE "secret|your-secret" --include="*.{js,ts,py}" . | grep -i jwt

Also decode your own token at any JWT debugger and look at the exp claim. No exp means the token works forever, including the one a hacker stole.

Fix: strong random secret from environment, short expiry with refresh tokens, and follow RFC 8725, the official JWT best practices. It is short and readable.

Pattern: secure session management, and more bluntly: do not build auth yourself. Login, tokens, refresh, logout and password reset are solved problems with sharp edges. Use a maintained implementation and spend your time on your product.

Free tools: Keycloak and Ory are full open source identity providers. Auth.js covers most Next.js apps for free. If you are on Supabase or Firebase you already have managed auth included, use it instead of the AI’s hand-rolled JWT code.


8. Debug mode and verbose errors in production

Generated projects ship with development settings: Flask debug=True, Django DEBUG = True, full stack traces in API responses, database errors passed straight to the user. A stack trace tells an attacker your framework, versions, file paths and queries. With Flask debug mode it is worse, the debugger console can mean direct code execution.

Quick check: trigger an error on purpose in production. Request a page that does not exist, send broken JSON to an API endpoint. If you see a stack trace or an SQL error, this one is yours.

Fix: debug off in production, generic error messages out, detailed errors into your logs where they belong.

Pattern: environment separation. Production config and development config are different files or different env var sets, and the dangerous flags simply do not exist in the production one. Secure defaults, debug is opt-in for dev, never opt-out for prod.

Free tools: Sentry has a free tier that captures the full stack trace privately while your users see a clean error page. helmet for Node sets safe HTTP headers in one line. Both take minutes.


9. The database is reachable from the internet

Supabase with row level security never turned on. Firebase with rules in test mode “just for now”. MongoDB listening on a public IP with no password because that is how the AI-generated docker-compose set it up. The app works exactly the same, so nobody notices that the whole database also answers to anyone who connects directly.

Quick check: for Supabase, open the dashboard and check RLS is enabled on every table with user data, then try querying your API with the public anon key only. For Firebase, read your rules file, allow read, write: if true is the bad sign. For self-hosted databases, try connecting from an outside machine.

Fix: row level security on, real rules written, databases on private networks only. The frontend should never be the only thing between users and your data.

Pattern: defence in depth. The database enforces its own access rules even if the app layer fails. Row level security means a bug in your API does not become a breach of your whole table.

Free tools: RLS is built into Postgres and Supabase, it just needs turning on. For databases that must be reachable remotely, Tailscale (free for small teams) or plain WireGuard puts them on a private network in an afternoon, no public IP at all.


10. Dependencies nobody ever looked at

A vibe-coded app pulls in whatever packages the AI suggested, and AI happily suggests outdated versions and sometimes packages that do not exist at all. Attackers register those hallucinated names and wait. This is slopsquatting and it is already happening in the wild, we covered it in detail in the research post.

Quick check:

npm audit          # or: pip-audit
npm ls --depth=0   # do you recognise these packages?

Fix: check that suggested packages actually exist and are maintained before installing, commit your lockfile, and turn on Dependabot, it is free and automatic. The upcoming npm v12 changes will help too, but they will not pick your packages for you.

Pattern: supply chain hygiene as a pipeline step. Dependency checking is not a thing you do once, it is a gate that runs on every build, so a bad package gets caught before deploy, not after the breach.

Free tools: OSV-Scanner from Google checks your lockfile against the open vulnerability database, open source and one command in CI. Semgrep adds free static analysis for your own code in the same pipeline. Dependabot or Renovate keep versions moving.


The pattern behind all ten

Notice what these have in common. Almost none of them are exotic. They are the boring basics: who can access what, what do you trust from the client, what is exposed that should not be. AI does not skip these because they are hard. It skips them because nobody asked, and because working code is what gets the thumbs up.

The good news is the same: none of the fixes are hard either. Most are a few lines. You can go through this whole list in an afternoon.

And to be fair to the robots, human developers made all ten of these mistakes for decades before AI showed up. AI just made it possible to make them much faster.

Built something with AI and not sure what is hiding in it?

We review vibe-coded apps before they ship. Real findings, plain English, fixes your AI assistant can apply. The first 30 minutes are free, and if your codebase is small, the conversation might be all you need.

Get your app checked

References