cd /news/ai-tools/the-supabase-security-checklist-i-ru… · home › topics › ai-tools › article
[ARTICLE · art-182392] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=· neutral

The Supabase security checklist I run on every AI-built app (Lovable, Bolt, v0, Cursor)

A developer published a read-only SQL checklist for auditing Supabase security in AI-generated apps from builders such as Lovable, Bolt, v0 and Cursor, arguing that these tools ship working logins and policies without deciding who can read which row. The checklist uses catalog queries and greps, never writes or requires service_role, to surface tables with RLS disabled, policies using USING (true), FOR ALL policies missing WITH CHECK, anon write grants, dangerous default privileges, SECURITY DEFINER functions without a pinned search_path, and views lacking security_invoker.

recommendation

Audit AI-generated Supabase schemas with these read-only catalog queries before shipping, and treat any RLS-off table, USING (true) policy or unpinned SECURITY DEFINER function as a leak to fix.

more in playbook: Securing agents and AI tools
by read5 min views4 publishedDec 5, 2026

An AI app builder will connect Supabase, create tables, generate policies and ship a working login in one session. What it will not do is sit down with your access model and decide who is allowed to read which row. That part is still yours — and the gap between "it works" and "it is closed" is measurable with read-only SQL.

This is the order I run. Every step is a catalog read or a grep. None of them writes, deletes or needs service_role, and all of them are safe to run on a production project.

The key in your NEXT_PUBLIC_ / VITE_ env is supposed to ship to the browser. The security boundary is not the key; it is what the key can touch. Fetch a table you believe is private with only the anon key and see whether rows come back. A populated response is the finding.

public

select n.nspname as schema, c.relname as table
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
  and c.relkind = 'r'
  and not c.relrowsecurity
order by 1, 2;

Every row is a table with RLS off. With the anon key and default grants, an RLS-off table in public is readable by anyone who has your project URL.

true

select schemaname, tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
  and (qual = 'true' or with_check = 'true');

USING (true) on a SELECT policy means every row is visible to every role the policy names — usually authenticated, which means every logged-in user. AI-generated schemas contain one of these surprisingly often so the demo works before anyone decides the access model.

FOR ALL without WITH CHECK

select tablename, policyname, cmd
from pg_policies
where schemaname = 'public'
  and cmd = 'ALL'
  and with_check is null;

USING decides which existing rows a statement may touch. WITH CHECK decides which new row it may produce. Without it, a user can update a row they own into a state they should not reach — a different tenant, a different owner, an escalated status.

anon hold write grants?

select table_name, privilege_type, grantee
from information_schema.role_table_grants
where table_schema = 'public'
  and grantee in ('anon', 'authenticated')
  and privilege_type in ('INSERT', 'UPDATE', 'DELETE')
order by 1, 3;

RLS still stops the write, but a grant is a second lock that should not be open by accident — and it is exactly the failure mode behind the Supabase October 30 grant change, where tables that relied on old default grants started returning 42501.

select pg_get_userbyid(defaclrole) as creator,
       defaclobjtype as object_type,
       defaclacl as acl
from pg_default_acl;

ALTER DEFAULT PRIVILEGES ... GRANT SELECT ON TABLES TO anon creates no row in role_table_grants and no policy. It waits here and attaches silently when the next migration creates a table. If your builder's migrations run as one role and your app queries as another, this is where tomorrow's leak is configured today.

SECURITY DEFINER: pin search_path

select p.proname,
       p.prosecdef as security_definer,
       p.proconfig as settings,
       has_function_privilege('anon', p.oid, 'EXECUTE') as anon_can_execute
from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public'
  and p.prosecdef
order by p.proname;

A definer function runs with its owner's rights. If proconfig is null, search_path is not pinned and the function can be redirected to another schema. If anon_can_execute is true and the function touches privileged data, that is a leak path no policy review will show you.

select c.relname as view_name, c.reloptions
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
  and c.relkind = 'v'
  and not (coalesce(c.reloptions, '{}') @> array['security_invoker=true']);

A normal view evaluates with the view owner's rights. If the owner also owns the base table and the table has no FORCE ROW LEVEL SECURITY, the view can return rows your caller's policies would hide. security_invoker = true makes the view run as the caller.

select id, name, public from storage.buckets order by name;

A public bucket serves every object to anyone with the URL. For private data: private bucket, signed URLs, and storage.objects policies reviewed the same way as table policies — one per operation, scoped by owner.

grep -rn "service_role\|sb_secret_\|SUPABASE_SERVICE" \
  --include="*.ts" --include="*.tsx" --include="*.js" \
  --include="*.env*" . | grep -v node_modules

service_role and sb_secret_ bypass RLS by design. They belong in server-only code. Any hit imported by a client component, or prefixed NEXT_PUBLIC_ / VITE_, is a full-database key sitting in the browser.

auth.uid() is null unless you pass the token A route that queries Supabase with the anon key and no user JWT runs as anon. auth.uid() is null, your policy filters everything, and the route returns empty or 42501. Worse: a route that trusts a user_id from the request body instead of the verified JWT is an IDOR no matter how good the policies are.

Postgres Changes is filtered by table RLS. Broadcast and Presence are authorized by policies on realtime.messages, and only for channels joined with private: true while "Allow public access" is off in Realtime settings. A public channel can be joined by anyone holding the anon key. Two policies are needed per topic — select to receive, insert to send — and a join-time policy cache means revoking a membership row does not disconnect anyone until their JWT refreshes.

Everything above is a snapshot. The failure mode is not "I never checked"; it is "I checked in March and the schema changed in July". A nightly read-only diff over the same catalog queries reports only new fingerprints, and fails closed when the credential breaks instead of writing an empty baseline.

These are catalog checks, not proof of a leak. They do not read application rows, do not run as service_role and do not modify anything. I verified the queries against a local PostgreSQL 17 fixture — not against hosted Supabase projects, whose defaults and exact revision are outside what a public catalog query can tell you. Zero findings does not mean safe; the catalog cannot tell you what your access model should have been.

If you want the executable version, the write-up with the full check set and a free nightly n8n workflow is on my site: https://cenkkurtoglu.com/blog/supabase-security-checklist-lovable-bolt-v0-cursor

If you'd rather have a person read the output and separate real exposure from noise, that is a fixed-scope review — and it starts only after payment is secured.

── more in #ai-tools 4 stories · sorted by recency
── more on @supabase 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/the-supabase-securit…] indexed:0 read:5min 2026-12-05 · —