App Security - 4 min read
Supabase RLS Security Checklist for Lovable, Bolt, and Cursor Apps
How to close exposed public Postgres tables, broken write policies, and service-role key leaks before launching an AI-coded app.
Why AI-built Supabase apps leak customer rows
In 2026 security scans, 98% of 1,072 AI-coded web apps carried at least one vulnerability (Symbiotic Security), and 16,326 public Supabase databases exposed readable tables (UpGuard).
Whenever an AI assistant creates a table with raw SQL in the public schema without enabling Row-Level Security, PostgREST exposes every row to anyone holding the public anon key embedded in your frontend bundle.
Lock down every table with cached auth.uid() policies
Enable and force RLS on every user table, and wrap auth.uid() inside a scalar SELECT so PostgreSQL evaluates it once per query instead of once per row.
Never ship FOR INSERT, UPDATE, or DELETE policies with USING (true) - always bind both USING and WITH CHECK to the authenticated owner or verified tenant membership.
ALTER TABLE public.orders ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.orders FORCE ROW LEVEL SECURITY;
CREATE POLICY "Users access own orders"
ON public.orders
FOR ALL
TO authenticated
USING ((SELECT auth.uid()) = user_id)
WITH CHECK ((SELECT auth.uid()) = user_id);Keep service_role strictly off client prefixes
Any variable prefixed with NEXT_PUBLIC_, VITE_, or REACT_APP_ is compiled straight into client JavaScript. Keep SUPABASE_SERVICE_ROLE_KEY inside server-only Route Handlers or Edge Functions, and rotate it immediately if it ever touched a public prefix.