Blog · Guides · 2026-11-25

Vibe-Coded App Authentication Bugs: What to Test First

TL;DRVibe coded app authentication bugs almost always trace to one gap: AI generators build authentication (login, sessions) but skip authorization (who may read or change which record). Because a single-account click-through can never reveal a missing ownership rule, the essential test is logging in as a second user and requesting the first user's data directly — the server should answer 403 or 404, not render the page.

Vibe coded app authentication bugs almost always come from the same gap: the AI built a login screen but never built authorization. Tools like Cursor, Lovable, Bolt and v0 reliably scaffold a sign-up form, a session and a "logged in" state, because that pattern appears everywhere in their training data. What they rarely add is the per-user, per-row, server-side enforcement that decides which data an authenticated user is allowed to see or change. The result is an app that looks secure — you can't reach the dashboard without logging in — but where any logged-in user can read another user's records by changing an ID in the URL or querying the database directly from the browser. To find these bugs you have to test with two real accounts, not just logged-in versus logged-out.

What causes authentication bugs in vibe-coded apps?

Authentication answers "who are you?" Authorization answers "what are you allowed to do?" AI code generators are good at the first and weak at the second, for three structural reasons.

  • The prompt rarely mentions authorization. You ask for "a dashboard where users can see their projects." The generator produces a projects page and a login flow. Nobody specified that user B must not see user A's projects, so no rule enforcing it gets written.
  • Hiding the UI feels like finishing the job. A generated app typically guards routes in the client: if there's no session, redirect to /login; if the role isn't admin, don't render the admin button. That is cosmetic. The API endpoint behind the hidden button is still live, and anyone can call it with curl.
  • Backend-as-a-service defaults are permissive until you tighten them. When an AI wires your app to Supabase or Firebase, the client gets a public anonymous key that ships inside the browser bundle — by design. The only thing standing between that key and your whole table is a row-level security policy or security rule. If the generator created the table but skipped the policy, or wrote a policy that resolves to "allow all authenticated users," every row is readable by every account.

This is why authentication bugs survive the usual "I clicked around and it worked" check. One person, one account, one browser session will never surface a missing ownership rule. For the wider pattern of what AI generators systematically leave out, see our guide on vibe coding security risks.

Which vibe coded app authentication bugs should you test for first?

Work down this list in order. The top rows are the ones that leak data; the bottom rows mostly annoy users.

Bug classHow it shows upHow to test it
Missing ownership check (IDOR)Changing a record ID in the URL or API call returns someone else's dataLog in as user B, request a URL or endpoint containing user A's record ID
Permissive database rulesThe public client key can read or write the full table directlyQuery the table from the browser console as a logged-in non-owner; confirm it returns only your rows
Client-only route guardProtected content flashes before the redirect, or the API still answersCall the endpoint directly with no session and with a non-admin session
Role escalationRole stored in a client-editable place, or admin endpoints trust a request fieldEdit the role value in local storage or the request body, then retry the admin action
Broken session lifecycleLogged-in shell with every API call failing; logout doesn't invalidate; expired token never refreshesLet a session sit until expiry, then use the app; log out and press Back
Auth flow dead endsPassword reset, email verification or OAuth callback loops or 404sWalk each flow end to end on a fresh account, including the email link

The two-account test is non-negotiable

Create two accounts, A and B, and give each one data. Then, logged in as B, try to reach every one of A's resources: detail pages, edit forms, delete buttons, file downloads, API routes. Correct behaviour is a 403 or 404 from the server — not a redirect, not an empty page rendered by the client. If B sees A's data even once, you have a missing server-side ownership check, and it's almost certainly missing on sibling endpoints too.

How do you test client-side versus server-side authorization?

The distinction matters because only one of them is real. A quick way to tell which you have:

  1. Find a protected action in the UI — say, deleting a project.
  2. Watch the network tab while you do it and note the request: method, path, payload.
  3. Replay that request from a second account (or with no session at all) using the browser console or a terminal, substituting the other user's record ID.
  4. Read the status code. A 200 means your protection was entirely in the UI. A 401, 403 or 404 means the server is actually deciding.

Do this once per resource type, not once per app. Generated code tends to be copy-pasted between endpoints, so a missing check on /api/projects/[id] usually has a twin on /api/invoices/[id]. When you review generated code directly, our notes on how to review AI generated code cover what to grep for.

What about session expiry, refresh and logout?

Session lifecycle is the most common non-security authentication bug in vibe-coded apps, because it only appears after time passes — and nobody tests an app by waiting. Typical symptoms: the app still renders a logged-in header while every request 401s; a refresh token exists but nothing calls it, so users are silently signed out mid-task; logout clears local state without invalidating the server session, so the Back button restores the old view.

Three checks cover most of it. First, leave a session idle past its expiry window, come back and use the app — you should land on a clear re-login prompt, not a broken dashboard. Second, log out, then press Back and refresh; protected data must not reappear. Third, open the app in two tabs, log out in one, and act in the other; the second tab should not keep working.

How can AI QA catch authentication bugs before users do?

Authentication bugs are a good fit for automation because they're combinatorial: every role multiplied by every resource multiplied by every action. That's tedious by hand and trivial to script. Klavity's Sims runs AI personas with separate accounts and roles against your app, so the cross-account attempts above happen on every build instead of when you remember. AutoSim turns the flows that matter — sign-up, login, password reset, logout — into end-to-end tests that repair themselves when your selectors change, which matters when an AI assistant is rewriting your components. And when a client or teammate does hit a permissions bug in the wild, Snap captures the session, console and network context with the report, so you can see which request returned the wrong data instead of guessing.

Whatever tooling you use, the sequence is the same: enumerate your roles, enumerate your resources, then prove at the server that each role can only touch what it owns. For the broader framework this fits into, read our complete guide to AI QA.

Ready to find the auth bugs in your app?

If you shipped a vibe-coded app without running the two-account test, assume the gap is there until you've proved otherwise. It takes one focused sitting by hand, and a few seconds per build once it's automated.

Try Klavity free — run AI personas with real accounts and roles against your app, and catch the authorization gaps your login screen hides.

Key takeaways

  • Test with two accounts, never just logged-in vs logged-out
  • Replay protected requests as a non-owner and check the status code
  • Verify row-level security scopes rows to their owner, not to any logged-in user
  • Test session expiry, logout and the Back button before launch

FAQ

Why do AI code generators get authentication wrong?

They usually get authentication right and authorization wrong. Login forms and session handling are extremely common patterns, so generators reproduce them well. Per-user access rules depend on your specific data model and are rarely mentioned in the prompt, so no code gets written to enforce them.

Is hiding the admin button enough to protect an admin feature?

No. Hiding or disabling UI is cosmetic. The endpoint behind the button is still reachable with a direct request, so authorization has to be enforced on the server for every protected action, not just in the component that renders it.

How do I test for IDOR bugs in a vibe-coded app?

Create two accounts with their own data. Logged in as the second user, request the first user's record IDs through URLs and API endpoints. A correct app returns 403 or 404 from the server. If the data comes back, the ownership check is missing — and likely missing on similar endpoints too.

Do I need to worry about Supabase or Firebase rules if the AI set them up?

Yes. The client gets a public anonymous key that ships in the browser bundle, so row-level security policies or security rules are the only barrier to your tables. Verify that each policy actually scopes rows to their owner rather than allowing any authenticated user.

Catch bugs the moment a human sees them

Klavity: right-click bug reports, AI personas that review your product, and self-healing tests.

Get started free