Vibe-Coded App Security: How to Test What AI Wrote for You
Vibe CodingHetz Team

Vibe-Coded App Security: How to Test What AI Wrote for You

Is your vibe-coded app secure? The security mistakes AI coding tools make most often, how to test for them, and how to fix them with the same tools that wrote the code.

Vibe coding changed who can build software. You describe what you want, an AI coding tool writes it, and a working product appears in days. The part that has not changed is that attackers do not care how the code was written. They care whether the API checks who is asking.

This guide is for founders and developers shipping apps built with Cursor, Claude Code, Copilot, Windsurf or similar tools. It covers why AI-written code has predictable security gaps, the mistakes we see most often, how to test for them, and how to fix them quickly. If your app came from a full app builder such as Lovable, Bolt or Base44, also read our guide to AI app builder security.

Why Vibe-Coded Apps Have Predictable Gaps

AI coding tools are very good at doing what they were asked. Security is mostly about what nobody asked for:

  • You asked for "a page where users see their invoices". You did not ask for "and make sure the API refuses to return other users' invoices". The page works. The API may not check.
  • You asked to "connect to the database". The fastest working connection may use a key with full access, placed where the browser can read it.
  • You asked for "a login". You did not ask for rate limits, lockouts or reset tokens that expire.

None of this is the model being careless. It is the model being literal, and moving fast. The result is code that passes every demo and fails the first time someone opens the browser's developer tools.

There is a second effect: when you did not write the code, you do not have the mental map a developer builds while writing it. You cannot easily review what you do not know is there.

The Most Common Security Mistakes in AI-Written Code

MistakeWhat it looks likeWhat an attacker does
Authorization only in the UIButtons hidden for non-admins, API wide openCalls the admin endpoint directly
Missing object checksAPI loads any record by IDChanges the ID to read other users' data
Secrets in the frontendService keys or API tokens in the JS bundleCopies the key and uses it with full rights
Open database rulesRow level security off, or rules that allow everyoneReads or writes the whole table from the browser
No rate limitsUnlimited login, sign-up and reset attemptsGuesses passwords, floods sign-ups, burns your AI credits
Unvalidated inputUser input in queries, HTML or URL fetchesInjection, stored XSS, server-side request forgery
Verbose errorsStack traces and SQL errors returned to the clientLearns your stack and data model
Leftover debug routesTest endpoints and seed scripts left liveFinds an unauthenticated back door

The first two rows, together called broken access control, top the OWASP Top 10 for all web applications, not only AI-written ones. In vibe-coded apps they are even more common, because access rules are exactly the kind of requirement that is obvious to a person and invisible in a prompt. We explain the pattern in depth in IDOR and broken access control.

A Special Note on AI Features Inside Your App

If your app itself calls a language model, for example a chatbot over your users' data, there are additional risks: prompt injection that makes the model ignore its instructions, the model revealing data from other users, and attackers using your endpoint to run up your AI bill. The OWASP Top 10 for LLM Applications is a good checklist. At minimum, the model should only ever see data the current user is allowed to see, and the endpoint should have rate limits per user.

Five Checks You Can Do Today

These take less than an hour and catch the worst problems:

  1. Search your frontend for secrets. Open your deployed site, view the JavaScript files, and search for "key", "secret", "token" and the names of your providers. A public "anon" or "publishable" key is expected. A service, secret or admin key is not.
  2. Check your database rules. If you use Supabase or Firebase, confirm every table has access rules and that none of them simply allow everyone. Our Supabase security guide shows what to look for.
  3. Swap an ID. Sign in as one user, find a request that loads a record by ID, and replay it with another user's ID. If it returns data, you have a critical bug.
  4. Call an admin endpoint as a normal user. Hidden buttons do not count. Try the request directly.
  5. Try ten wrong passwords in a row. If nothing slows you down, add rate limiting.

These checks find the obvious problems. They do not replace a test that maps the whole app, signs in as every role and tries the less obvious paths.

How to Security Test a Vibe-Coded App Properly

A proper test treats your app the way an attacker would: from the outside, signed in as real users, against every endpoint it can find. For a vibe-coded app it should include:

  • Mapping everything that is live, including routes and endpoints the AI generated but the UI no longer uses.
  • Testing every endpoint as every role, and across users, to find access control gaps.
  • Checking the database layer directly, since many of these apps let the browser talk to the database.
  • Proving each finding with the exact request and response, so you know it is real before you spend time on it.

This is what Hetz does. You put in your domain, AI agents test the running product end to end, and you get detailed insights with the fix for every finding. We compare this kind of testing with traditional manual testing in automated vs manual penetration testing.

Fixing It With the Same Tools That Wrote It

Here is the good news: the tool that wrote the bug is very good at fixing it, if you tell it exactly what is wrong. Compare two prompts:

Vague: "Review my app for security issues and fix them."

Precise: "The endpoint GET /api/invoices/:id returns any invoice to any signed-in user. A request as user 4471 for invoice 8812, owned by user 1203, returned 200 with the invoice. Change the handler so it loads the invoice only where the owner is the current user, and returns 404 otherwise. Add a test that fails before the change and passes after."

The vague prompt produces general hardening that may or may not touch the real bug. The precise prompt fixes the real bug and proves it. Every Hetz finding comes with a prompt like the second one, ready to paste into Claude Code, Cursor or your app builder, along with the patch and the test. Then you retest, and the finding closes only when the attack no longer works.

Building Security Into the Way You Vibe Code

You do not need to slow down. You need a few habits:

  • Say the rule in the prompt. "Only the owner can read or change an invoice; enforce this on the server" costs one sentence.
  • Keep secrets on the server. Ask for server routes or edge functions for anything that needs a privileged key.
  • Turn on database rules first. Start with "deny everything" and open only what each user needs.
  • Add rate limits by default on login, sign-up, password reset, and any endpoint that costs you money.
  • Test after every big generation. A new feature can open a new path, and a quick automated test catches it the same day.

When to Test

Because generating a feature takes minutes, the gap between a safe version and an unsafe one can be a single prompt. Treat testing as part of shipping, not as a yearly event, and match its rhythm to how often you generate large changes.

MomentWhy
Before public launchFirst real users mean first real attackers
Before taking payments or personal dataThe cost of a leak jumps
After generating roles, teams or an APIAccess control is where AI-written code breaks most
Before a customer's security reviewThey will ask for a recent test
Regularly while you keep shippingEvery generation can change the attack surface

For cost expectations, see our guide to penetration testing cost.

Next Steps

Do the five checks above today. Then run a full test before your next launch, and keep testing as you ship. You can see how a full run works on our home page, compare plans on pricing, or start a scan and get detailed insights, with the fix, for the app you built.

FAQ

Frequently asked questions

Keep reading