supabase-rls-check
Provides read-only review of Supabase project configuration and anonymous exposure, including RLS, policies, grants, functions, views, Storage buckets, and optional probe findings. The MCP server exposes local tools to analyze SQL catalog exports and explain rules.
supabase-rls-check
Consent-gated, read-only configuration and anonymous-exposure checks for Supabase projects (PostgreSQL 15+, Python 3.11+). No database password or service_role key required.
Why this exists
Supabase applications intentionally ship a public anon JWT or sb_publishable_ key inside browser JavaScript bundles so client code can talk directly to PostgREST (/rest/v1/) and Storage. Because every visitor can read that key from DevTools, access control depends directly on PostgreSQL Row Level Security (RLS), policy expressions, table/function grants, view options, and Storage bucket visibility—along with never bundling a service_role token in frontend code.
During rapid prototyping, AI-assisted schema generation, or manual migrations, it is easy to leave a table in public without RLS, keep a temporary USING (true) policy, or forget that PostgreSQL grants EXECUTE to PUBLIC on new SECURITY DEFINER functions exposed at /rest/v1/rpc/*. supabase-rls-check helps project owners review those patterns safely without modifying data or saving table rows.
Related MCP server: database-sentinel
Installation
Requires Python 3.11 or newer.
Not on PyPI yet. Install from the GitHub release tag:
pipx install "git+https://github.com/Tthanh2k6/supabase-rls-check@v0.2.0"Optional Model Context Protocol (MCP) server support (mcp>=1.2):
pipx install "supabase-rls-check[mcp] @ git+https://github.com/Tthanh2k6/supabase-rls-check@v0.2.0"From source for development:
pip install -e ".[dev]"Three-step usage
1. Export catalog metadata with check.sql
Print the bundled read-only SQL query (or open src/supabase_rls_check/sql/check.sql):
supabase-rls-check sql --print-sql > check.sqlPaste check.sql into the Supabase SQL Editor, adjust the sensitive-table name pattern if needed, run the SELECT, and export the single result set as CSV or JSON (rule,schema_name,object_name,policy_name). Only catalog metadata is queried—never application rows.
Validate and normalize the export:
supabase-rls-check sql --from export.csv --out sql_results.json --i-own-this-project2. Optionally verify anonymous read exposure (probe)
Check what an unauthenticated caller can actually read with your public anon JWT or sb_publishable_ key, and optionally inspect your frontend origin for leaked service_role JWTs:
supabase-rls-check probe \
--url https://YOUR_PROJECT.supabase.co \
--anon-key YOUR_ANON_OR_PUBLISHABLE_KEY \
--site https://your-app.example \
--out probe_results.json \
--i-own-this-projectPass the project HTTPS origin to
--url(not/rest/v1/).Only
anonJWTs andsb_publishable_keys are accepted;service_roleandauthenticatedtokens are rejected before any request is sent.If OpenAPI schema discovery is disabled on PostgREST, pass known table/view names explicitly with
--tables todos profiles.
3. Generate the standalone report and dry-run SQL template
supabase-rls-check report \
--from sql_results.json probe_results.json \
--out-dir review_out \
--project "My Supabase App" \
--i-own-this-projectThis writes three files to review_out/:
report.html— standalone, offline-ready HTML report (A4 landscape print stylesheet for Print -> Save as PDF)report.md— Markdown summary suitable for issues or pull requestsfix.sql— commented review template wrapped inBEGIN; ... ROLLBACK;(never executed by this tool; replaceuser_idwith your real ownership column and test on staging first)
Add --lang vi to generate Vietnamese report text.
Explaining a rule and optional MCP mode
Inspect the rationale, caveats, and remediation example for any rule without touching a target project:
supabase-rls-check explain rls_disabled
supabase-rls-check explain definer_anon_execIf installed with supabase-rls-check[mcp], start the local stdio MCP server:
supabase-rls-check mcpThe MCP server exposes only two local, read-only tools: analyze_sql_export(path) and explain_rule(rule). Network probing is intentionally excluded from MCP so AI clients never handle API keys or send HTTP requests through this tool.
Sample report and offline demo

Try the offline fictional dataset (demo/todo_ai.csv -> demo/report.md and demo/fix.sql):
supabase-rls-check report --from demo/todo_ai.csv --out-dir demo --project "todo-ai (fictional demo)" --i-own-this-project
supabase-rls-check report --from demo/todo_ai.csv --out-dir demo/vi --project "todo-ai (dữ liệu giả)" --lang vi --i-own-this-projectEleven checks: SQL catalog rules
check.sql inspects PostgreSQL 15+ system catalogs and storage.buckets in a single read-only CTE query:
Rule ID | Severity | Meaning |
| High | Table or partitioned table in |
| High | Policy in |
| High | Policy granted to |
| High | Non-trigger |
| High |
|
| High | View in |
| Medium | Supabase Storage bucket in |
| Low | PostgreSQL extension is installed directly in |
| High | Policy in |
| Low | Policy on an RLS-enabled table in |
| Critical | Public view directly depends on |
The three new rules add only commented guidance to fix.sql; they never generate automatic DDL. Policy expression checks are heuristics over PostgreSQL's deparsed SQL. The authentication performance check recognizes directly SELECT-wrapped calls; complex subqueries need manual review. The Auth exposure check follows direct dependencies and returns no findings when auth.users is absent.
Additional checks from probe
When probe is run, two runtime checks complement the SQL catalog export:
anon_readable(High) — PostgREST returned visible rows for an unauthenticatedGET/HEADrequest using theanonor publishable key (records column names and visible row count only).service_role_exposed(Critical) — A JWT whose payload decodes torole = "service_role"was found in frontend HTML or a directly linked same-origin script.
Tip: pass the anon key through the SUPABASE_ANON_KEY environment variable instead of --anon-key to keep it out of shell history.
How it is tested
66 unit tests (
pytest): consent flag enforcement, GET/HEAD-only probing with no redirects, response size limits, row values and keys never written to disk,service_roleJWT detection, HTML/SQL escaping in reports, identifier quoting infix.sql, English and Vietnamese output, all 11 catalog rules in reports/explanations, comment-only fixes for the new rules, and the MCP tool surface (noprobeexposed).Catalog query on a real PostgreSQL 15 (GitHub Actions):
tests/fixtures/seed_pg.sqlplants issues for all 11 rules next to safe controls. CI compares all 19 expected findings exactly, including overlapping view findings, and rejects extra or missing rows. Cases cover both JWT sources, all four authentication helpers, mixed wrapped/unwrapped calls, materialized views, role grants, and safeapp_metadata/sub-select/invoker controls. The query runs with read-only transactions, including separate cases without anauthschema orauth.userstable.Abuse cases checked by hand: running any command without
--i-own-this-projectexits before touching the network; passing aservice_rolekey toprobeis refused; the MCP server cannot reach the network.
Ethical boundaries
Authorization required: Only scan projects you own or have explicit written authorization to test, including any
--sitefrontend domain. Commands that process project exports or targets require--i-own-this-projector--have-written-consent.Strictly read-only:
probesendsGETandHEADrequests only—neverPOST,PUT,PATCH,DELETE, or RPC invocations. HTTP redirects are not followed,trust_envis disabled, responses are capped at 5 MB, and timeouts are fixed at 20 seconds.No customer row storage:
proberequests at mostlimit=1row per relation in memory, extracts column names, discards row values immediately, and strips JWT patterns ([REDACTED]) from metadata and error messages.
Limitations (not a penetration test)
This tool is a configuration and anonymous-read review aid, not a penetration test and not a security certification:
Configuration findings are review signals, not proof of exploitability; public buckets or anonymous
SELECTpolicies are sometimes intentional.An empty finding list, HTTP
200 [], or401/403on a single request does not prove overall safety.Does not test authenticated cross-user / multi-tenant isolation,
INSERT/UPDATE/DELETEpermissions, SQL function bodies, Edge Functions, custom Auth hooks, or complexstorage.objectspolicy combinations.--siteinspects only the entry HTML document and up to 20 directly linked same-origin HTTPS<script src>files. Dynamically imported chunks, source maps, split/obfuscated tokens, and non-JWT secret formats (sb_secret_*) are outside its coverage, and JWT signatures are not verified.fix.sqlis a starting template ending inROLLBACK;. Adding a new permissive policy does not override existing broad permissive policies—always export existing policies/grants and test two-user isolation on staging before committing changes.
Need a human review?
Need a manual review of RLS policies, SECURITY DEFINER function bodies, and two-user staging isolation? Book a fixed-scope review here: https://contra.com/s/sFUXWqOZ-supabase-security-check-for-lovable-bolt-and-v0-apps
License
Code is released under the MIT License (Copyright (c) 2026 Trung Thanh Tran). Bundled Bricolage Grotesque report fonts in assets/ are licensed under the SIL Open Font License 1.1 (assets/BricolageGrotesque-OFL.txt).
Available Tools
2 toolsanalyze_sql_exportA
Validate and summarize a local CSV or JSON metadata export from check.sql.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of disclosing behavior. It states the supported formats and the validation/summarization purpose, which strongly implies a read-only analysis operation, but it does not explicitly confirm non-destructiveness, describe validation behavior, or mention error handling.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The definition is a single front-loaded sentence with no unnecessary wording. It states the action and accepted input formats immediately.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple one-parameter tool with an output schema, the description is largely complete: it identifies the operation, accepted file formats, and source context. The main remaining gap is that it does not explicitly state read-only behavior or clarify path resolution expectations, though these are minor given the tool's low complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate for the bare 'path' parameter. It does so by explaining that the path refers to a local CSV or JSON metadata export from check.sql, giving the agent clear meaning beyond the schema's generic string type.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb pair, 'Validate and summarize,' with a clear resource: a local CSV or JSON metadata export from check.sql. It is distinguishable from a generic file reader, but it does not explicitly contrast itself with the sibling tool explain_rule.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is implied by the mention of local CSV/JSON exports from check.sql, so an agent can infer when the tool applies. However, there is no explicit when-to-use guidance, no exclusions, and no named alternative for related tasks such as explaining rules.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
explain_ruleB
Explain what a supabase-rls-check rule detects, caveats, and how to remediate it.
| Name | Required | Description | Default |
|---|---|---|---|
| rule | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must carry behavioral disclosure. It indicates the explanation covers detection logic, caveats, and remediation, which is useful output context, but it does not state that the operation is read-only, whether it requires a valid rule identifier, or what happens for an unknown rule.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with no redundant wording. Every phrase contributes to the tool's purpose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a one-parameter explain tool with an output schema, the description covers the conceptual return content. However, it leaves the required rule identifier's format and usage context undocumented, which is a meaningful gap given zero schema coverage and no annotations.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The single 'rule' parameter has 0% schema description coverage, and the description only calls it a 'supabase-rls-check rule' without specifying format, source, or valid values. It does not compensate for the missing schema documentation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb, 'Explain', and a specific resource, 'supabase-rls-check rule', and lists the content covered: detects, caveats, and remediation. It does not explicitly differentiate from the sibling analyze_sql_export, so it falls short of a 5.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides no when-to-use or when-not-to-use guidance, and does not mention alternatives such as analyze_sql_export. The sentence describes output content rather than invocation context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v0.1.0- First observed
analyze_sql_export - First observed
explain_rule
TDQS
Scored across 2 tools
The two tools operate on completely different inputs: one validates/summarizes a local metadata export file, the other returns static documentation for a rule. There is no plausible way for an agent to confuse them.
Both names use the same snake_case verb_noun pattern (analyze_sql_export, explain_rule) with clear, specific nouns. No stylistic drift between the two.
Two tools is thin for a domain that includes running the check, enumerating rules, and interpreting results. It is defensible given a narrow scan-and-explain scope, but the surface feels minimal rather than well-scoped.
There is no way to list available rules (so explain_rule requires guessing rule names) and no tool to actually run or re-run check.sql, only to analyze a pre-existing export. Remediation is described in prose via explain_rule but never produced as SQL, leaving notable dead ends.
Maintenance
Related MCP Connectors
Check Supabase SQL for who can read and write each table: RLS gaps, open policies, grants, fix SQL.
Free passive outside security scan of a live web app: leaked keys, exposed files, open Supabase
Security scans for AI-built apps: leaked keys, open Supabase RLS, vulnerable packages, live sites.
Scan a deployed app URL for exposed keys, open Supabase tables and missing security headers.
Related MCP Servers
- AlicenseAqualityDmaintenanceAudits PostgreSQL/Supabase schemas for security issues like missing RLS, permissive policies, and sensitive data exposure during AI conversations.3MIT
- AlicenseBqualityBmaintenanceRead-only security audit for Supabase. Surfaces RLS gaps, permissive policies, exposed functions and grants, and returns scored findings with fix SQL that is never executed.451MIT
- AlicenseAqualityBmaintenanceScan a deployed site for an exposed Supabase service_role key and audit Row Level Security from your AI coding agent.246 npmMIT
- AlicenseAqualityCmaintenanceEnables AI coding assistants to check whether an API key is safe to expose, audit Supabase Row Level Security, generate owner-based RLS policy templates, and run a builder-specific pre-launch security checklist. Runs locally over stdio with no network calls, telemetry, or file access.5MIT