- Home
- Skills
- Data & Databases
- Supabase RLS & Policy Audit
Works with the AI Agents you already use
Supabase RLS & Policy Audit
Supabase's free Security Advisor is a good first check, and you should keep running it.
$19
Supabase RLS & Policy Audit
Example session with this skill installed
Audit the RLS on my Supabase project before we launch. Public schema only. Also check ./web for any service key that could end up in the browser. Don't change anything.
- Read your context and instructions
- Compiled the supabase rls
(Excerpt. Fictional demo data.)
Before I start: this audit only reads Postgres system catalogs, inside a read-only transaction. I won't open your .env files or print any key, and I won't change anything. If you want a fix applied, we'll do it one item at a time, with the undo shown first.
Ran the audit through psql (connection string from SUPABASE_DB_URL, which you set) and scanned ./web for key names.
| Severity | Count |
|---|---|
| CRITICAL | 3 |
| HIGH | 4 |
| MEDIUM | 5 |
| LOW | 3 |
Top findings
- CRITICAL E01: web/.env.local line 3 defines NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY. Anything with that prefix is built into the browser bundle, and the service role skips RLS. Rotate the key in the dashboard, then rename the variable and use it only on the server.
- CRITICAL R01: public.notes has RLS off, and anon can SELECT, INSERT, UPDATE and DELETE. Proposed fix: enable RLS and add an owner policy on user_id (SQL and undo in the report).
- CRITICAL S02: a storage policy lets anon upload to any bucket.
- HIGH R03: "logged in users can update orders" only checks auth.uid() is not null. Any signed-in user, including an anonymous sign-in, can change every order. Proposed fix: compare auth.uid() to the owner column.
- HIGH R07: view public.profile_summary runs as its owner, so it ignores RLS on profiles. Fix: alter view ... set (security_invoker = true).
Clean: profiles, jobs, tenant_data (FORCE RLS on), profile_summary_v2.
Not covered: the bodies of your SECURITY DEFINER functions, Edge Functions, and whether each policy matches your business rules.
Want to start with item 1? I'll show the steps, what breaks, and how to check it worked before anything changes.
Connects securely to your tools. The creator never sees your data.
About this skill
Supabase's free Security Advisor is a good first check, and you should keep running it. This skill goes further. It has your agent audit the live database without changing anything, explain each problem in plain words, and hand you the SQL to fix it and the SQL to undo the fix.
What it adds on top of the Advisor
- Fix and undo SQL for every finding, plus what may break and how to check the fix worked. You approve each fix one at a time; nothing is applied without your OK.
- "Any signed-in user" policies.
auth.uid() is not null,auth.role() = 'authenticated'andauth.jwt() is not nulllook like security but let every signed-in user (anonymous sign-ins included) see or change every row. These are flagged likeusing (true), includingcoalesce(auth.uid()::text, '') <> ''style checks. Reads are rated HIGH when the table holds contact details (email, phone, street address, IP address) or other sensitive-looking columns, because the usual leak is aprofilestable where anyone signed in can read every email. With anonymous sign-ins on, "signed in" can mean anyone. - Partitioned tables. A partitioned table with RLS off exposes all of its partitions, and a partition with RLS off skips its parent's policies when queried directly. Both are caught and explained.
- FORCE ROW LEVEL SECURITY, for setups where the app connects as the table owner (or a role that inherits it) and would skip every policy.
- Storage write policies: anon uploads, and users who can overwrite or delete other users' files.
- A code scan for service role or secret key names behind a browser prefix (
NEXT_PUBLIC_,VITE_,EXPO_PUBLIC_and others), server keys in'use client'files, committedsb_secret_keys, and.envfiles git doesn't ignore. File and line only, never the value. Mentions in docs are skipped unless you ask for them. - CI:
--fail-on HIGHexits non-zero so a pull request can't add a new problem, with an accept file for findings you've decided are fine.
Also covered
Tables with RLS off or no policies, policies that trust user_metadata, anon write policies, views without security_invoker, SECURITY DEFINER functions anon can call, grants broader than your policies need (TRUNCATE, default privileges that hand future tables to anon), and login roles that bypass RLS.
How it keeps you safe
- Read-only. The audit is a set of SELECTs on system catalogs, run in a read-only transaction with psql. No table rows are read.
- No secrets in the chat. The agent never opens
.envfiles or asks for a password or key; you set the connection in your own terminal. Long string literals in policies are masked and error text is scrubbed. - Fixes are proposals. The agent offers a branch, your local stack, or a migration file before touching anything.
Four ways to run it
psql, the Supabase CLI (supabase db query), the Supabase MCP server (execute_sql), or pasting one query into the dashboard SQL editor. It also runs on plain Postgres, skipping the Supabase role checks.
What you get
A Markdown report ranked CRITICAL to INFO, with fix SQL, undo SQL, a docs link and an accept key per finding, a "checked and clean" list, and a section on what the audit can't see. JSON output too.
Tested
Tested on Postgres 16 and 17 against a mock Supabase database with 42 deliberate mistakes and 17 correctly built objects. Every mistake was caught at the intended severity, every clean object passed, and the database was unchanged afterwards. The test database and scripts are included so you can re-run them.
By Mausoft Skills. Supabase is a trademark of its owner; this skill is not affiliated with or endorsed by Supabase.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
- Not yet run against a hosted Supabase project,
supabase db query --linked, or a live MCP connection. Tested on local Postgres 16 and 17 with a mock Supabase schema through psql, on 17 through CLI--db-url, and with the MCP and SQL editor result shapes tested through the parser. - Not tested on Postgres 15 or on Windows.
- It flags policy shapes that are usually wrong. It can't tell whether a policy matches your business rules.
- It doesn't read the bodies of SECURITY DEFINER functions or policy helper functions, Edge Functions, or server code using the secret key.
- Realtime authorization and GraphQL settings are not covered. Column-level privileges are reported but not analyzed in depth.
- The code scan matches names and key shapes, so a secret under an unusual name won't be found.
- Sensitive and contact columns are found by name (email, phone, address, IP, password, token and similar). A column with personal data under an unusual name won't raise a read policy to HIGH.
- The exposed-schemas list comes from you (or
pgrst.db_schemaswhen set). The audit can't read the dashboard setting.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 19 days ago
- Accounts
Supabase
Postgresql
- Software
Python 3.8+
psqlorSupabase CLI
Permissions
Allowed Hosts
Supabase database: read access to system catalogs through psql, the Supabase CLI, the Supabase MCP server, or the SQL editor (no table rows are read; writes only for fixes you approve one at a time) Optional: read-only access to your app's code folder (env variable names and key shapes; values never printed)