Practical guide

How to secure a vibe-coded app (without becoming a security engineer)

You do not need a security background to close the holes AI leaves. You need the right order: find where the data lives, lock it, take the keys off the client, rotate anything that leaked, and re-check after every change. Here is that sequence.

1 Find where the data actually lives

Most vibe-coded apps use a hosted backend (often Supabase). Open the project and list its tables. Every table that holds user data is in scope; anything the browser can reach with a public key is the attack surface.

If you cannot name every table your front end queries, stop here and list them first. You cannot secure what you have not mapped.

2 Turn on Row Level Security on every user table

RLS is the rule that decides which rows a request may read or write. With it off, the public key exposes the whole table.

alter table public.your_table enable row level security;

Then add a policy that scopes rows to the signed-in user, and force the rules so the owner cannot bypass them:

create policy "own rows" on public.your_table
  for all to authenticated
  using (auth.uid() = user_id)
  with check (auth.uid() = user_id);

alter table public.your_table force row level security;

3 Check that "RLS on" is not a false comfort

RLS on with using (true) protects nothing. A write policy with no WITH CHECK lets a user write rows they should not own. These are the two most common "it looks locked" failures.

Read every policy and ask: which rows does this allow, for which role, on which command? If the answer is "everyone, everything," it is not a policy.

4 Take every secret off the client

The service_role key bypasses RLS entirely. It belongs on the server, never in a browser bundle, a mobile app, or a public repo. The same goes for private keys and any hardcoded API password.

Move them to environment variables or a secret manager, and read them at runtime.

5 Rotate anything that was ever exposed

Deleting a leaked key from the current code does not remove it from git history. If a secret was committed or shipped, treat it as compromised: rotate it, then redeploy. Rotation is the only step that actually closes the exposure.

6 Check dependencies, and declare what you import

AI tools sometimes import a package without adding it to the manifest. That builds locally and breaks — or pulls something unexpected — elsewhere. Declare it, lock it, and upgrade any package with a known advisory.

7 Re-check after every meaningful AI change

This is the step people skip. These tools regenerate code; a policy that existed yesterday can vanish in the next prompt. A one-time fix is not a guarantee.

Run the scan again after a change that touches auth, the database, or deployment. If you want it automatic, the monitoring plan re-scans on a schedule and tells you when something gets worse.

The honest short version: lock the database, move the keys, rotate what leaked, and check again. Everything else is detail on top of those four moves.

Do it in about a minute.

Free read-only scan of your migrations and source: plain-English findings, the exact fix SQL, and a suggested migration. The upload is discarded after the scan.

Run the free scan

Prefer the full list first? Read 10 security holes AI leaves in your app. If your database is Supabase and you are not sure whether RLS is on, start with Supabase RLS missing. Raising money? See pre-investor verification.