SHEET 03blog/rescuing-a-vibe-coded-mvp/ REVISED 

Rescuing a vibe-coded MVP from Lovable, Bolt or v0: the first two weeks

How to take over a Lovable, Bolt or v0 MVP: what to lock down on day one, SQL checks for Supabase RLS, an audit for secrets, auth and payments, and keep vs rewrite.

Published
Length
12 min read
Tags
  • security
  • code-review
  • databases
  • secrets

To rescue a vibe-coded MVP, spend the first two weeks on control and risk before features. In week one, move the code, database, secrets and domains into company accounts, then audit who can read each table, where secrets live, how auth checks work and how payments get confirmed. In week two, fix what’s exposed, add tests and a real deploy pipeline, and decide what to keep or rewrite.

Most of what follows comes from codebases I’ve taken over or hardened for other teams. None of them were Lovable apps, but the bugs fell into the same classes.

Why do vibe-coded MVPs need rescuing at all?

They work well enough to get users, and nobody has checked the parts users can’t see. Lovable, Bolt and v0 are good at getting a product in front of people. A typical setup has the browser talking straight to a hosted Postgres database (usually Supabase), so the database’s access rules are the only line of defense. Those rules are exactly the part founders can’t review.

The public record is consistent:

  • In March 2025, Matt Palmer (who works at Replit, a competitor) and a colleague scanned 1,645 projects from Lovable’s Launched showcase and found 303 endpoints across 170 of them (about 10.3%) with inadequate row-level security. They only looked at homepages. On one app they inserted a record with "payment_status": "paid" as an unauthenticated user, bypassing Stripe. It became CVE-2025-48757 in May 2025.
  • In February 2026, The Register reported on a Lovable-hosted exam app with 16 vulnerabilities, 6 of them critical, and 18,697 user records exposed. One auth guard was inverted: it blocked signed-in users and let anonymous ones through.
  • In a study published on 2 November 2026, Crissy Field looked at 159,041 Lovable projects, 34,545 of which used Supabase. Of the 24,664 sites that sent database records on first load, 7,403 (about 30%) exposed email addresses to read-only requests without a login. The authors say the 30% “should therefore not be read as a confirmed data leak rate”, but one app exposed more than 1,000 records with passport numbers. On Hacker News, Lovable’s head of security wrote that “the root cause in these apps was insufficent Row-Level Security”.

Lovable now scans before publish, and its docs still say “You are still responsible for your app’s security.”

What does the two-week plan look like?

Two days to get control, three to audit, five to fix and lock in. Features wait until the last row is done. The one exception to the order: if the audit finds a table of customer data open to anyone, close it that day.

When Goal Done when
Days 1-2 Control Code, database, hosting and domain sit in company accounts, shared credentials are rotated, a backup has been restored once
Days 3-5 Audit Every table, policy, secret, auth check and payment path has been looked at and written down
Days 6-8 Close exposure No table readable or writable beyond what the product needs, no secret in the bundle or in git
Days 9-10 Make it hold Tests on money and auth, CI on every pull request, a deploy that doesn’t need the builder, a keep-or-rewrite decision per layer

What should you lock down on day one?

Start with ownership. When I took over a SaaS from a previous agency, its auth server and secrets store still belonged to the old team, and both went dark around the handover. With a vibe-coded app, the builder platform plays that role: the code, the database, the hosting and often the domain sit in one founder’s personal account.

  1. Get the code into a GitHub organization the company owns. Lovable always creates a new repo, edits one branch at a time, and keeps syncing after you transfer the repo only if the Lovable workspace also has a GitHub connection for the new owner. Bolt commits every change that doesn’t break the project and pulls from GitHub every 30 seconds. With v0, the connected repo becomes the source of truth, and v0 works on its own branches and respects branch protection.
  2. Agree who edits what. Two-way sync means a founder’s prompt in the builder can land on the branch an engineer is fixing. Either stop builder edits, or give the builder its own branch and merge through pull requests.
  3. Move the database, auth provider, hosting and domain to company accounts, with named people as members. Write down every account and who holds admin.
  4. Rotate anything shared: API keys pasted into chats, keys in old commits, admin logins the freelancer created. If someone who left can still log in, the handover isn’t finished.
  5. If the builder stays in use, turn on its guardrails. In Lovable, workspace admins can enable “Block publishing with critical issues” under Workspace settings, Security.
  6. Take a backup and restore it once, so you know it works.

What goes on the week-one audit checklist?

Check the places where a working app can still be badly wrong. This is the list I’d run on a Lovable, Bolt or v0 codebase:

Area What to check Red flag
Data access RLS and grants on every table the browser can reach, and what each policy allows RLS off, a policy that is just true, a policy that reads user_metadata
Storage Bucket policies and which buckets are public Public buckets that allow listing, uploads with no owner check
Secrets Repo history, the built JavaScript bundle, env files sb_secret_, service_role, sk_live_ or any third-party key in the bundle or in git
Auth Where the “is this user allowed” check happens Checks only in React components, or guards with inverted logic
Tenancy Two users in two organizations trying to see each other’s data Any row from the other account, including from cached screens
Payments How an order or subscription becomes “paid” The success redirect marks it paid, the client can write the payment status, or the webhook doesn’t verify signatures
Data model Tables, foreign keys, JSON blobs Duplicate user tables, no foreign keys, money as floats
Build and deploy A build and deploy from a clean checkout, without the builder Only the builder’s “publish” button works
Tests What runs before a change reaches users Nothing

Secrets

Scan the full history, not just the current tree. Gitleaks and TruffleHog both do this. Then build the frontend and grep the output, because Vite puts every VITE_ variable into the client bundle by design:

gitleaks git -v .
trufflehog git file://. --results=verified
npm run build && grep -rEo "sb_secret_[A-Za-z0-9_]+|service_role|sk_live_[A-Za-z0-9]+" dist/ | sort -u

Supabase’s publishable (or legacy anon) key is meant to be public. The secret key (or legacy service_role key) bypasses row-level security, and Supabase’s API key docs say never to put one in a browser, a shipped app or source control. New secret keys are refused when sent from a browser, but anyone who copies one can still use it from other tools.

Auth logic

Once you find one broken check, search for its siblings. In a legacy admin panel I fixed, one access check sent a redirect but never stopped the request, and a search for the same shape found ten more places. Generated code repeats its own patterns at least as reliably as people do, so run the same search there.

Tenancy

Row-level security being on doesn’t mean it works for every query. On a multi-tenant SaaS I took over, Postgres RLS was in place, yet a roles endpoint still returned every tenant’s roles, and the frontend cached them under a key that ignored the organization. Test with two real accounts in two organizations on every screen, and repeat the database version of that test below.

Payments

Payments should be confirmed by the provider’s webhook, never by the browser landing on a success page or writing a status column. Stripe’s docs say to verify the Stripe-Signature header against the raw request body and to handle duplicate events. At Zaher.AI the webhook and the redirect page could race to settle the same order, so settlement is a single atomic pending-to-paid update that only one of them can win.

How do you check Supabase row-level security on an inherited app?

Run the queries below in the SQL editor, run the Security Advisor, then read every policy by hand. Queries from the dashboard run as postgres, which bypasses row-level security, so a plain select there tells you nothing about what users can see. Query the catalog instead, and switch roles when you test.

-- 1. RLS status and what signed-out visitors may attempt on each table
select tablename,
       rowsecurity as rls_enabled,
       has_table_privilege('anon', format('%I.%I', schemaname, tablename), 'SELECT') as anon_select,
       has_table_privilege('anon', format('%I.%I', schemaname, tablename), 'INSERT,UPDATE,DELETE') as anon_write
from pg_tables
where schemaname = 'public'
order by rowsecurity, tablename;

-- 2. Every policy and what it allows
select tablename, policyname, permissive, roles, cmd, qual, with_check
from pg_policies
where schemaname = 'public'
order by tablename, cmd;

-- 3. Red-flag policies: always true, or trusting user-editable metadata
select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
  and (qual = 'true' or with_check = 'true'
       or qual like '%user_metadata%' or with_check like '%user_metadata%');

Any row in query 1 with rls_enabled = false and anon_select = true is a table anyone with your project URL can read. Supabase’s RLS guide states the rule plainly: “A table in an exposed schema without RLS is readable and writable by any role with a grant on it.” They also warn that adding policies doesn’t take grants back, so a table protected only by policies can still give anon an insert path. And a policy based on user_metadata is checking a field that signed-in users can edit themselves.

Then test as real users. Supabase’s RLS testing guide sets the role and the user ID inside a transaction:

begin;
set local role authenticated;
set local request.jwt.claim.sub = '<user-a-uuid>';  -- a real user from auth.users
select count(*) from public.invoices;               -- only user A's company?
rollback;

begin;
set local role anon;
select count(*) from public.profiles;               -- should be 0 or fail
rollback;

Run the first block once per user, for two users in different organizations, against every table that holds customer data. If your policies read other claims through auth.jwt(), set request.jwt.claims to a JSON object as well. If you’d rather click than type, the dashboard’s role dropdown does the same thing and can impersonate a specific user.

The Security Advisor catches most of the mechanical problems: tables with RLS off (rls_disabled_in_public), policies that allow everything (permissive_rls_policy), policies that read user metadata (rls_references_user_metadata), views that bypass RLS (security_definer_view) and public buckets that allow listing. From the CLI, run supabase db advisors --type security --level info --remote, and add --fail-on error in CI.

One timing detail matters for apps built before this year. Supabase stopped exposing new public tables to the Data API automatically for new projects from 30 May 2026 and for existing projects from 30 October 2026. Existing tables “keep their current grants”. So in an MVP generated in 2025 or early 2026, the original tables probably still grant access to anon, and row-level security is the only thing in the way.

When you read the policies, compare each one with what the product is supposed to allow. “Users can read their own rows” is fine for a profile. It’s wrong for an invoice table where a company’s admins need every invoice in their company, and it’s dangerous when “own” is decided by a column the client can write.

What happens in week two?

Fix in order of blast radius, then make it hard to regress:

  1. Close exposed data and leaked secrets. Turn on RLS, revoke grants the app doesn’t need, tighten policies, rotate keys. Check logs to see whether anything was read before you closed it, because that decides whether you have to tell users. The fix for a table that should be private follows Supabase’s own pattern:

    alter table public.reports enable row level security;
    revoke all on table public.reports from anon, authenticated;
    grant select, insert on table public.reports to authenticated;  -- only what the app uses
    -- then add policies that say which rows
  2. Move privileged logic to the server. Anything that touches money, roles or other users’ data goes into an edge function or an API you control, using the secret key there and only there. Supabase is deprecating the legacy anon and service_role keys in early 2027, so switch to publishable and secret keys while you’re in there.

  3. Write tests for the paths that cost money or leak data: sign-up, login, the paywall, the webhook and the two-organization check. Put the RLS rules in pgTAP tests and run supabase test db in CI. A dozen good integration tests beat 200 snapshot tests.

  4. Build a deploy pipeline that doesn’t need the builder. When Zaher.AI moved off Replit to AWS early in 2026, the deploy became GitHub Actions building a package, shipping it to S3 and handing it to CodeDeploy, with runtime config from Secrets Manager and database migrations run as part of the deploy. A vibe-coded app rarely needs that much. A CI build, a staging environment and migrations in version control get you most of the way.

  5. Add the repo rules a team needs: branch protection, CI on every pull request, Dependabot, and CODEOWNERS on the sensitive paths (auth, payments, migrations).

None of this is specific to AI-written code. On a live multi-tenant platform I worked on after a pentest, the fixes ran to about 40 security changes: tenant scoping, auth gaps, unauthenticated writes, SQL injection through column names, cookie flags, CSP, HSTS, brute-force lockout and leaked secrets. Some were quick wins no scanner had rated critical. Vibe-coded apps hit the same classes of bug, only after weeks of development instead of years.

Should you keep it or rewrite it?

Keep it and replace it in pieces, unless the data model is wrong. The usual case against rewrites is that old code holds years of bug fixes. A three-month-old MVP holds very few of those, so a rewrite costs less than it would for older software. What the MVP does hold is behavior real users have validated, plus their data. So the safest route is usually Martin Fowler’s strangler fig: move one piece at a time behind your own API until the generated code is gone or good enough.

Signal Keep and harden Rewrite that part
Data model Fits the product, has foreign keys Wrong core entities, everything in JSON blobs
Stack Mainstream (React, Vite or Next.js, Postgres) Tied to the builder’s runtime, can’t build outside it
Security fixes Mostly grants, policies and moving logic server-side Would touch nearly every file
Users and data Real users, real data to migrate Few users, throwaway data
Team Engineers can read and change it Nobody can follow the flow end to end

I’d usually keep the frontend, because generated React UIs are often fine. The parts most often rebuilt are the access rules, anything server-side and the data model.

What I’d do this week

  • Move the repo, database, hosting and domain into company-owned accounts, and list who has admin on each.
  • Pick one place where edits happen so the builder and engineers stop overwriting each other.
  • Run gitleaks or TruffleHog on the full history and grep the built bundle for secret keys. Rotate anything you find.
  • Run the catalog queries above and supabase db advisors --type security, then read every policy against what the product should allow.
  • Impersonate two users in two organizations, in SQL and in the browser, on every table and screen.
  • Confirm payments only become “paid” through a verified webhook, and only once.
  • Write down keep or rewrite for each layer: data model, server logic, frontend.

To add automated checks to the audit, see coding agents as security auditors. If you’re about to hire engineers to take over an AI-built MVP and want someone to run this audit with them, that’s the codebase takeover part of my fractional CTO work.

Further reading

Questions

Is a Lovable or Bolt app safe to launch with real customer data?

Not until someone has checked who can read and write each table. These apps usually have the browser talk straight to the database, so the database's access rules are the only thing protecting user data. In a November 2026 study of Lovable apps, email addresses were readable without logging in on 30% of the sites that loaded database records, though the authors say that isn't a confirmed leak rate. Check row-level security and secrets before real users sign up.

How do I check if my Supabase tables are exposed?

In the SQL editor, query pg_tables for rowsecurity and use has_table_privilege to see what the anon role can select or write on each table. Then read every policy in pg_policies, and run Supabase's Security Advisor, which flags tables with RLS off and policies that allow everything. Finally, impersonate two real users inside a transaction and confirm neither can see the other's rows.

Should I rewrite a vibe-coded MVP or keep it?

Usually keep it and replace it in pieces. A rewrite makes sense when the data model is wrong for the product, when nobody can build or deploy the code outside the builder, or when the security fixes would touch nearly every file. If the stack is mainstream and the data model fits, fix the critical issues, add tests around money and auth, and move privileged logic to the server one feature at a time.

Is the Supabase anon or publishable key safe to put in the frontend?

Yes, it's designed to be public, but only if row-level security and grants are correct for every table it can reach. The secret key (sb_secret_ or the legacy service_role key) bypasses row-level security and must never ship to the browser. If it ever did, fix the leak and then rotate the key.

Can I move a Lovable, Bolt or v0 project off the platform?

Yes. All three can sync the code to a GitHub repository, and Lovable and Bolt can also export it as a download. From there it is a normal React or Next.js app you can build, test and deploy anywhere, though you still need to move the database, secrets and domains to accounts the company controls.

About the author

Software engineer and serial founder in Alexandria, Egypt, and CTO at Zaher.AI, a GEO and SEO agency serving MENA.

Console

Type help and press Enter.