Supabase rls audit
@shipcheck/supabase-rls-audit
Audit row level security in your Supabase migrations before you launch. Finds tables with RLS off, policies that let anyone write, policies that trust user_metadata, views that skip RLS, and risky SECURITY DEFINER functions, then drafts a fix migration for you to review. Reads .sql files only and never touches your database.
- Activity
- New: be the first to try it
- Installs
- 0 installs
- Likes
- 0 likes
- Clones
- 0 clones
- 1# Supabase RLS audit
- 3Checks the row level security in your Supabase migrations and tells you, in plain words, who can read or change each table. Then it drafts a fix migration for you to review, so you can launch without leaving your data open to anyone holding your public anon key.
- 5**For:** anyone shipping a Supabase app, especially your first one. No security background needed.
- 7## Example
- 9Input: `supabase/migrations/` with a table that never got `enable row level security` and a policy like `for all to authenticated using (auth.role() = 'authenticated')`.
- 11Output (`out/rls-audit.md`):
- 13```markdown
- 145 tables, 4 with RLS on.
- 15High: 3 | Medium: 4 | Low: 0 | Info: 1
- 17## High
- 18- public.invoices (rls-disabled): Row level security is off. Anyone with your
- 19 public anon key can read and change every row through the API.
- 20 - Fix: alter table public.invoices enable row level security;
- 21- public.notes / Signed in users can do anything (policy-any-user-write):
- 22 any user can read and change other users' rows.
- 23```
- 25Plus `out/rls-fixes.sql`, a draft migration with one commented fix per finding. Try it on the bundled example: `node scripts/rls-audit.mjs examples/migrations`.
- 27## What it checks
- 29Tables with RLS off, `USING (true)` and `WITH CHECK (true)` policies, policies that only check "signed in", policies that trust `user_metadata`, views without `security_invoker`, materialized views, and SECURITY DEFINER functions without a fixed `search_path`.
- 31## What it can access
- 33- Reads `supabase/migrations/**` (and `supabase/schema.sql` if you paste one).
- 34- Writes the report to `out/`, and a new fix migration to `supabase/migrations/` only after you say yes.
- 35- Runs only its own script. No network, no database connection, no env vars.
- 37## Setup
- 39None. Needs Node 22 or later.
