AI Engineering

Vibe-Coding Security: The 12 Risks Hiding in AI-Generated Apps (and a Checklist to Catch Them Before Launch)

AI coding tools ship working features fast, and the same predictable security holes along with them. Here is what to review before real users and real data arrive.

TL;DR AI-generated apps tend to fail security in predictable ways: secrets in client code, missing server-side authorization, disabled database row-level security, permissive CORS, unvalidated input, hallucinated or outdated packages and no rate limiting. A one-day review against a checklist, plus an automated configuration scan, catches most of them before launch.

AI coding assistant generating an app with security warnings highlighted

Vibe coding means describing what you want to an AI tool and accepting the code it produces, often without reading it line by line. It has made shipping a working prototype a matter of hours. The catch is that "working" and "safe" are different tests, and AI tools optimise for the first. The good news is that the security mistakes are repetitive, so a checklist catches most of them.

The 12 most common security holes in AI-generated apps

#RiskWhat it looks likeFix
1Secrets in the clientAPI keys for OpenAI, Stripe or a database admin key bundled into front-end JavaScriptMove calls server-side, rotate the exposed key
2Missing server-side authorizationThe UI hides other users' records, but /api/orders/123 returns anyone's order (IDOR)Check ownership on every endpoint
3Database row-level security offSupabase/Firebase tables readable with the public anon keyEnable RLS and write policies per table
4Permissive CORSAccess-Control-Allow-Origin reflects any origin with credentialsExplicit origin allow-list
5InjectionSQL built with string concatenation, eval on user inputParameterised queries, no eval
6Unsafe HTML renderinginnerHTML / dangerouslySetInnerHTML with user contentFramework escaping, a sanitiser, a CSP
7Hallucinated or outdated packagesA suggested dependency that does not exist (or is a typo-squat), or a 2019 versionVerify every new package, enable dependency alerts
8No rate limitingLogin, sign-up, AI and email endpoints callable thousands of times a minutePer-IP and per-account limits
9Verbose errorsStack traces and SQL errors returned to the browserGlobal error handler, generic messages
10Weak session handlingJWTs in localStorage, no expiry, cookies without Secure/HttpOnlyShort-lived tokens, secure cookies
11Unrestricted file uploadAny file type and size, stored in a public bucket under its original nameType and size checks, random names, private storage
12Missing security headersNo HSTS, CSP, frame or nosniff headers on the deployed siteAdd at the host or CDN

Why AI tools make these mistakes

  • They solve the prompt you wrote. "Show the user their orders" gets a filtered UI query, not an authorization rule, unless you ask for one.
  • They learned from public code, including tutorials that skip security for brevity.
  • They lack the full picture. A model editing one file cannot see that another endpoint exposes the same data.
  • They suggest packages from memory, which may be outdated or not exist at all. Attackers now register commonly hallucinated package names ("slopsquatting").

The pre-launch checklist

  1. Search the built front-end bundle for sk-, key, secret, service_role and password. Anything found is already public, so rotate it.
  2. For every API route, write down who may call it and which records they may touch, then test it with a second user account.
  3. Turn on row-level security and run your app as an anonymous user against the database API.
  4. Run npm audit / pip-audit / dotnet list package --vulnerable and open each new dependency's registry page to confirm it is the real one.
  5. Add rate limits to authentication, AI, email and payment endpoints.
  6. Remove debug output and check that errors return generic messages.
  7. Scan the deployed site with the free ZetsApp Website Security Audit for HTTPS, headers, cookies, CORS and vulnerable libraries, and fix everything marked failed.
  8. Ask the AI to review its own code with a security-focused prompt and have a human read the auth and data-access code. Use both, not either.

Prompts that produce safer code

Add standing instructions to your AI tool's project rules:

- Every API endpoint must verify the caller is authenticated AND owns the requested record.
- Never put secrets in client-side code; read them from server environment variables.
- Use parameterised queries only; never build SQL with string concatenation.
- Never use eval, new Function or innerHTML with user input.
- Only use well-known, maintained packages; state the exact version.
- Add rate limiting to auth and any endpoint that sends email, SMS or calls a paid API.

When to bring in engineers

A vibe-coded prototype is a great way to validate an idea. Before it handles payments, health data, children's data or business-critical records, it needs a proper security review and usually some re-architecture. ZetsApp turns prototypes into production systems through MVP development and custom software development, with security review included. See also our guide to the OWASP Top 10:2025.

Frequently asked questions

Is vibe coding secure?

It can be, but not by default. AI coding tools reliably produce working features and frequently miss server-side authorization, secret handling, rate limiting and secure configuration. A structured review before launch closes most of the gaps.

What is the biggest security risk in AI-generated code?

Missing server-side authorization (insecure direct object references) and secrets exposed in client code are the most common serious issues, because the app appears to work correctly in normal use.

What is slopsquatting?

An attack where criminals publish malicious packages under names that AI models commonly hallucinate, so developers who install a suggested dependency without checking it pull in malware.

How do I security-test an app built with Lovable, Bolt or Cursor?

Search the client bundle for secrets, test every API with a second user account, enable database row-level security, audit dependencies, add rate limits, and scan the deployed site's headers, TLS and cookies with a tool like the ZetsApp Website Security Audit.

Tags
Vibe CodingAI CodingAppSecSecurity ReviewStartups
Share this article