I Built a Zero-Dependency 15-Point Audit CLI for Vibe-Coded Supabase Apps (What Lovable's Green RLS Toggle Misses) A developer built a zero-dependency Node.js 18+ audit script, supabase-rls-audit.mjs, that scans SQL migrations, Edge Functions, and frontend bundles against 15 rules (VCR-01 through VCR-15) to catch Row Level Security gaps in AI-generated Supabase apps. The tool targets five failure modes that pass Supabase's green RLS-enabled badge, including permissive USING (true) policies, UPDATE/INSERT policies missing WITH CHECK, views that bypass RLS without security_invoker, and signup triggers that trust user-controlled raw_user_meta_data for roles and plans. The writeup pairs each finding with SQL patches, such as wrapping auth.uid() in a subselect for per-statement caching and revoking column-level updates on plan and role fields. If you built your SaaS MVP in Lovable, Bolt, or Cursor over a weekend, you probably checked the Supabase dashboard, saw the green RLS Enabled badge on your tables, and assumed multi-tenant isolation was done. It usually is not. Over the past month, I audited AI-generated Supabase repositories and migrations and kept running into the exact same five failure modes. None of them trip the basic "is RLS enabled?" warning in the dashboard. All five let an authenticated or anonymous user read another customer's rows, escalate to an admin plan, or forge Stripe webhooks. To stop checking these by hand, I wrote a zero-dependency Node.js 18+ static and passive audit script supabase-rls-audit.mjs that scans SQL migrations, Edge Functions, and frontend bundles against 15 rules VCR-01 through VCR-15 . Here are the 5 silent leaks that slip past the green RLS toggle most often, along with the exact SQL and TypeScript patches to close them. VCR-04 When an AI coding assistant hits a 403 error during prototyping, its favorite shortcut is to turn RLS on and immediately create a policy with USING true or WITH CHECK true for public , anon , or authenticated . The dashboard shows RLS as enabled. In practice, every row in the table is readable or writable across tenants via the public PostgREST endpoint. What our CLI flags: -- Vulnerable: passes "RLS Enabled" checks, leaks every tenant row CREATE POLICY "allow authenticated all" ON public.projects FOR SELECT TO authenticated USING true ; The fix: DROP POLICY "allow authenticated all" ON public.projects; CREATE POLICY "tenant isolated select" ON public.projects FOR SELECT TO authenticated USING SELECT auth.uid = user id ; Wrapping auth.uid in SELECT auth.uid also lets Postgres cache the initPlan per statement instead of re-evaluating per row. INSERT / UPDATE Policies Missing an Explicit WITH CHECK VCR-05 An UPDATE policy with only a USING clause checks whether you own the row before the update, not after . An INSERT policy without WITH CHECK lets any signed-in user submit another tenant's user id or org id in the payload and inject records directly into someone else's workspace. DROP POLICY "owner update" ON public.projects; CREATE POLICY "owner update" ON public.projects FOR UPDATE TO authenticated USING SELECT auth.uid = user id WITH CHECK SELECT auth.uid = user id ; VCR-08 In PostgreSQL, views run with the permissions of the view creator postgres by default. If your AI assistant generated a reporting view public.dashboard metrics or public.active subscriptions to simplify a frontend query, PostgREST exposes that view to the client and silently bypasses every RLS policy on the underlying tables. The fix PostgreSQL 15+ / Supabase : ALTER VIEW public.dashboard metrics SET security invoker = true ; -- Or set it on creation: CREATE OR REPLACE VIEW public.dashboard metrics WITH security invoker = true AS SELECT id, user id, total cents FROM public.invoices; raw user meta data VCR-07 This is the most common billing bypass in Lovable and Cursor templates. A signup trigger or RLS policy reads NEW.raw user meta data - 'role' or raw user meta data - 'plan' . The catch: raw user meta data is user-controlled. Anyone can pass { data: { role: 'admin', plan: 'pro' } } during supabase.auth.signUp or modify it later with supabase.auth.updateUser . The fix: Never read roles, plans, or org IDs from raw user meta data . Hardcode least-privilege defaults on insert, or read server-managed raw app meta data only: INSERT INTO public.profiles id, email, full name, role, plan VALUES NEW.id, NEW.email, NEW.raw user meta data - 'full name', COALESCE NEW.raw app meta data - 'role', 'member' , 'free' ; Pair this with column-level revocation REVOKE UPDATE plan, role, is admin, credits ON public.profiles FROM authenticated; , checked by VCR-11 so users cannot patch their own billing columns from browser DevTools. constructEventAsync VCR-09 & VCR-10 Two bugs show up constantly in AI-generated Supabase Edge Functions handling Stripe: await req.json directly and trusting body.type === 'checkout.session.completed' with zero HMAC signature verification. Anyone can curl your endpoint and grant themselves a paid plan. stripe.webhooks.constructEvent inside Deno, which throws a crypto runtime error in Supabase Edge Functions, prompting the developer to comment out signature verification "temporarily" to get checkout working. The fix for Supabase Edge Functions Deno : js const rawBody = await req.text ; const sig = req.headers.get 'stripe-signature' ; if sig return new Response 'Missing signature', { status: 400 } ; const event = await stripe.webhooks.constructEventAsync rawBody, sig, Deno.env.get 'STRIPE WEBHOOK SECRET' , undefined, Stripe.createSubtleCryptoProvider ; Then deduplicate event.id in a public.stripe webhook events table with stripe event id text PRIMARY KEY before granting credits VCR-10 so Stripe retries never double-credit an account. Beyond those five checks, supabase-rls-audit.mjs checks for: service role JWTs leaked in client bundles VCR-01 and hardcoded API tokens VCR-02 ENABLE ROW LEVEL SECURITY VCR-03 SECURITY DEFINER functions missing SET search path = '' VCR-06 storage.objects policies VCR-12 .env files or NEXT PUBLIC / VITE prefixed secret keys VCR-13 dangerouslySetInnerHTML and interpolated SQL VCR-14 Access-Control-Allow-Origin: on authenticated routes VCR-15 If you are about to launch a Lovable, Bolt, Cursor, or Next.js + Supabase app and want a clean 24-hour pre-launch security review full 15-point scan, redacted report, ready-to-apply SQL migrations, and Stripe webhook patch PR , email me at support@localledgerstudio.xyz mailto:support@localledgerstudio.xyz with your repo stack. Fixed-price audits run $149 to $399 depending on table count and Edge Function complexity, with zero retainer lock-in. More 60-second dev fixes and free browser-local tools from LocalLedger Studio: DESIGN.md spec generator: