Cenk Kurtoğlu©26

Supabase security · worked example · 6 minute read

What a read-only RLS drift check actually reports

Abstract security advice is easy to ignore. Below is the real output of thirteen read-only catalogue checks against a deliberately misconfigured local PostgreSQL 17 container. It is a synthetic fixture — no customer project, no hosted database, no production connection — but the report shape is exactly what the free monitor produces.

The setup (and the access it used)

The check ran as a catalogue-only role: CONNECT on the database and USAGE on public, with no SELECT grant on any table. All thirteen checks completed. A direct SELECT * FROM public.orders as that same role returned permission denied for table orders. No service_role, no superuser, no BYPASSRLS, no writes, and no application row data was read.

That distinction matters: a nightly drift check should be able to see security-relevant catalogue state without being able to see customer data. The role template is included in the free package.

The fixture

Ten findings, and what each one means

Severity / checkObjectWhy it is flagged
HIGH · Apublic.ordersRLS is disabled — any role with table privileges reads all rows.
HIGH · Cpublic.events :: p_read_allPermissive SELECT/ALL policy with USING (true).
HIGH · Gpublic.lookupSECURITY DEFINER without a pinned search_path — object hijack risk.
HIGH · Hpublic.lookup (owner postgres)Definer function owned by a role that bypasses RLS.
HIGH · Kdefault privileges / anonFuture tables will grant SELECT to anon — invisible in role_table_grants until the table exists.
HIGH · Lpublic.accounts_viewView runs with owner rights (security_invoker not set); the owner bypasses RLS.
MEDIUM · Bpublic.accountsRLS is on but not FORCEd, so the table owner bypasses policies.
MEDIUM · Bpublic.eventsRLS is on but not FORCEd, so the table owner bypasses policies.
MEDIUM · Jpublic.lookup / PUBLICAn API role can EXECUTE the function directly.
MEDIUM · Mpublic.accounts :: p_org_guardThe policy calls a helper with a row column inside a scalar subquery — a correlated SubPlan, re-evaluated for every row.

Three of these rows are the ones a per-table policy review typically misses. K lives in pg_default_acl, not in the grants of any existing table. Lis a property of the view, not of the underlying table's policies. M looks like a safely wrapped call, but the argument is a row column, so Postgres plans it as a correlated SubPlan. That is why the check reads the catalogue rather than re-reading policy text.

How to read the report

Each row is a catalogue signal plus a suggested fix, not proof of a leak. A view flagged by L might be intentional; a definer function flagged by G might have a fully qualified body. The value is that the state change is visible the day it happens, while the migration diff is still fresh.

The inverse matters just as much: zero findings does not mean safe. It means no catalogue signal was found. It cannot tell you whether a policy matches what your team intended, whether a key is being used from a browser, or whether a hosted platform rewrites a grant behind your back.

The nightly workflow is also fail-closed: if the credential breaks or the query errors, the run stops. A broken connection must never be recorded as “all findings resolved”. The baseline is a snapshot of finding fingerprints, and new fingerprints alert until a human reviews and refreshes it.

Run it on a scratch database

The complete workflow, the standalone SQL, the TR/EN start guides, the catalogue-only role template, and this exact sample output are in the free package: Supabase RLS Drift Monitor — free. Start on a scratch database, connect the least-privileged role, and use the manual trigger to capture a baseline before you enable the nightly schedule.

If you want a person to read the policies in context, that is a separate, bounded engagement — a 24-hour read-only spot check starts only after payment is secured. The free package stays free with no support commitment.

Continue with how to detect RLS drift with a nightly catalogue diff or the two gaps a per-table policy review will not show you, or which scope answers which question — spot check vs full audit.

Free entry

If you would rather run these checks yourself

Honest limit: a catalog check is not proof of a leak, and an empty log is not proof the key was never used. Zero findings does not mean safe. If you want a human: $29 self-run kit · $95 spot check (five tables, one working day) · $195 full audit — work starts only after payment is secured.

Template bundle

Review all 20 frontend starters in one bundle

20 editable frontend starters with live demos are $79 — one payment, no subscription.

View the Bundle — $79↗