Notes · Vibe-Coded Security

We Built Our App With AI and It Has Security Holes — Should We Rebuild It?

· Secure rebuilds · ~8 min read

If you vibe-coded your app, it works, and you have just realised anyone could read your customers' data, you almost never need to throw the whole thing away — but you do need to fix it before the next person finds the hole. The most common vibe coding security risks are a handful of predictable, well-understood mistakes: a database with its access controls switched off, secret keys shipped to the browser, and login checks that run where the user can edit them. A secure vibe-coded app is reachable from where you are now; the work is to seal the data layer first, then rebuild the weak parts in place.

First, take a breath. Shipping something that works is the hard part, and most founders never get there. The fact that you built a real product with AI and customers are using it is a genuine achievement. The security holes are not a sign you did it wrong — they are the predictable, almost universal gap in how AI tools generate code today. Knowing they exist puts you ahead of the people who haven't looked.

Second, the honest answer to "should we rebuild?" is usually no, not the whole thing. The features, the screens, the flow your customers like — that stays. What needs rebuilding is the thin, dangerous layer underneath: how data is stored, who is allowed to read it, and where your secrets live. That is a contained job, not a teardown.

Why vibe-coded apps share the same security holes

This is not bad luck specific to your build. It is structural. Veracode's 2025 GenAI Code Security Report tested code from more than 100 large language models and found that 45% of generated code samples failed security tests, introducing the kind of flaws on the OWASP Top 10 list. Tellingly, newer and larger models did not score better — the report concluded this is baked into how AI generates code, not a gap the next model release will close.

The reason is simple once you see it. An AI coding assistant optimises for code that runs and matches what you asked for. You asked it to "let users save their profile" — and it did, beautifully. You did not ask it to "make sure user A can never read user B's profile," because you didn't know that was a separate thing you had to ask for. As the security firm Tenzai put it after auditing five popular tools, the agents "lack this 'common sense' and depend mainly on explicit instructions." The functional request gets met. The unspoken security requirement does not.

So vibe coded app vulnerabilities cluster around the same few mistakes regardless of who built the app or which tool they used. That is good news for you: if the problems are predictable, the fixes are too.

The three holes that let strangers read your customers' data

When founders tell us "anyone could read our data," it is almost always one of three things — often all three at once.

1. Database access controls were never switched on

This is the big one, and the most dangerous. If you use Supabase, Firebase, or a similar backend, your database has a feature called Row Level Security (RLS) — the rule that says "a logged-in user can only see their own rows." AI tools frequently scaffold projects with Supabase RLS disabled by default, because that is the fastest way to make the app work in early development. Nobody turns it back on.

The effect is brutal. With RLS off, the public key your app uses to talk to the database becomes an admin-level master key for every table. This is exactly the pattern behind CVE-2025-48757, disclosed in June 2025 by researcher Matan Getz, which affected more than 170 applications built on the Lovable platform — AI was generating database configurations with RLS disabled, leaving customer data and API keys readable to anyone who looked. Wiz Research, scanning real production apps, found the same "overly permissive or disabled Row-Level Security" leaking personal data, IP addresses and confidential records across vibe-coded apps.

2. Secret keys were shipped to the browser

Your app needs keys to talk to other services — your AI provider, your payment processor, your email tool. There are two kinds: public keys, safe to expose, and secret keys, which must never leave your server. AI-generated frontends routinely embed secret keys straight into the JavaScript that downloads to every visitor's browser. Anyone can open the developer console, find your API keys in the client bundle, and start spending your money or reading data on your behalf. Wiz specifically called out hardcoded sk-proj- OpenAI tokens sitting in client-side code. In Escape.tech's October 2025 scan of 5,600 vibe-coded apps, exposed secrets like these turned up in over 400 of them.

3. Login checks run where the user can edit them

The third common vibe coding security hole is authentication that happens in the browser instead of on the server. The app checks "is this person allowed in?" using JavaScript the user fully controls — so a curious visitor can simply delete the check. Wiz found apps "handling password validation entirely in the browser, with credentials embedded directly in JavaScript files," plus admin dashboards and staging environments deployed publicly with no authentication at all. A lock only works if the user can't reach the mechanism. Client-side checks hand them the key.

Across the whole landscape, Wiz Research reported that one in five organisations building on vibe-coding platforms had systemic security risks of this kind. The common thread, as their team noted, is that these issues are "easily preventable" — which is the encouraging part.

How to find out how exposed you actually are

Before deciding anything, get the real picture. You can do a meaningful first pass yourself in an afternoon, no specialist tools required.

  • Open your live site, then open the browser developer tools. In the Network and Sources tabs, search the loaded files for "key", "secret", "token", "password". If a secret key (not a public one) shows up, that is hole number two confirmed.
  • Check your database dashboard for RLS. In Supabase, open the Table Editor and look at each table's RLS status. Any table holding customer data with RLS "Disabled" or "No policies" is hole number one.
  • Try to reach data you shouldn't. Log in as one test user, note the URL or ID for their record, then try to load another user's record by changing the ID. If it loads, your access controls aren't enforcing ownership.
  • Test the front door. Open your admin pages and internal tools in a private browser window where you are not logged in. If they load, they are public.

This tells you the severity. A leaked secret key and a wide-open database mean act today. A single missing ownership check on a low-stakes feature means plan the fix calmly. Either way, you now know — and knowing is the difference between a quiet patch and a public incident.

The safe way to rebuild a vibe-coded app

You do not rebuild a vibe-coded app by starting over. You rebuild it in the right order, securing the data layer first because that is where the bleeding is, then hardening the rest while the app keeps running. The sequence we use looks like this.

  • Rotate every secret immediately. If keys have been in the browser, assume they are compromised. Generate new ones, store them server-side, and revoke the old ones. This is the one step that can't wait.
  • Turn on Row Level Security and write real ownership policies. Every table gets a rule that ties each row to the user who owns it. Until this is done, the database is open regardless of anything else.
  • Move authentication and authorisation to the server. Every "is this person allowed?" decision moves out of the browser to code the user can't touch. This is the part most worth rebuilding properly rather than patching.
  • Add input validation and rate limits. Validate what comes in, and cap how often anyone can hit your endpoints, so a single bad actor can't drain or poison your system.
  • Re-scan, then keep the good parts. Run the checks again, confirm the holes are closed, and leave your working features exactly as they are.

Done in this order, the customer-facing app barely changes. The dangerous layer underneath gets replaced with something built to hold. That is the difference between a panicked rewrite and a calm, surgical rebuild — and it is why most founders who arrive worried about throwing everything away end up keeping 80% of what they made.

When it is genuinely worth bringing in help

Plenty of this you can do yourself, and if your app is small and the stakes are low, you probably should — switching on RLS and rotating keys is within reach for anyone comfortable enough to have built the app in the first place. We would tell you that plainly rather than sell you a rebuild you don't need.

It is worth bringing in a studio when the cost of getting it wrong is high: you are holding real customer data, taking payments, handling anything covered by data-protection rules, or growing fast enough that a breach would be more than embarrassing. The risk of a half-finished fix is a false sense of safety — RLS on three tables out of five looks done and isn't. When you decide to hire a studio to rebuild an AI app, what you are really buying is the certainty that someone who has closed these exact holes before has checked every table, every endpoint, and every key — and can tell you, with evidence, that it is sealed.

Either path is legitimate. The one thing that isn't is leaving it open now that you've seen it. The strangers who scan for AI generated code vulnerabilities are automated, patient, and already looking.

Straight answers

Questions we hear about rebuilding vibe-coded apps

Do we have to throw away our vibe-coded app and start over?

Almost never. The features and screens your customers use can stay. What needs rebuilding is the thin layer underneath — how data is stored, who can read it, and where your secret keys live. Most founders keep the large majority of what they built and replace only the dangerous parts.

What is the single most dangerous vibe coding security hole?

A database with Row Level Security (RLS) disabled. AI tools often scaffold projects with it switched off so the app works faster in development. With RLS off, the public key your app uses becomes an admin-level master key to every table, letting anyone read or write all your customer data. This was the root cause behind CVE-2025-48757, which affected 170+ Lovable-built apps in 2025.

How can I check if my own app is exposed?

Open your live site with the browser developer tools and search the loaded files for words like 'secret', 'key' and 'token' — a secret key appearing there is a serious leak. Then check your database dashboard to see whether RLS is enabled on tables holding customer data. Finally, try opening another user's record by changing the ID in the URL; if it loads, your access controls aren't enforcing ownership.

Why does AI write code with security holes if it works fine?

AI assistants optimise for code that runs and matches your request. You ask it to 'let users save a profile' and it does — but you didn't ask it to stop user A reading user B's profile, because you didn't know that was a separate requirement. Veracode's 2025 study found 45% of AI-generated code introduced OWASP Top 10 flaws, and that larger models didn't do better, so it's a structural gap, not bad luck.

What is the right order to fix a vibe-coded app's security?

Secrets first, data layer second, then the rest. Rotate every key that may have been exposed and move them server-side, then enable Row Level Security with real ownership rules on every table, then move all authentication checks off the browser onto the server. After that, add input validation and rate limits, re-scan to confirm the holes are closed, and leave your working features untouched.

Can we fix this ourselves or should we hire a studio?

If your app is small and the stakes are low, switching on RLS and rotating keys is within reach for anyone who built the app in the first place. Bring in help when the cost of getting it wrong is high — real customer data, payments, regulated information, or fast growth. The danger of a half-done fix is a false sense of safety, since RLS on most tables looks complete but isn't.

Your app works. Now let's make sure only your customers can see their own data.

If you've found a hole — a leaked key, a database that's wide open, a login check anyone can skip — the worst move is to leave it sitting there now that you've seen it. We close these exact gaps for founders who shipped fast with AI and want to keep what they built. Tell us what you found and we'll tell you honestly whether it's an afternoon's patch or a proper rebuild — and if it's the former, we'll point you at it for free.