The most common Row Level Security bug I see in AI-generated Supabase apps (Lovable, Bolt, v0, Cursor) passes every basic "is RLS enabled?" check.
The developer enables RLS on public.profiles and adds an ownership policy for updates:
CREATE POLICY "users_update_own_profile" ON public.profiles FOR UPDATE TO authenticated USING ((SELECT auth.uid()) = user_id); Later, they add billing or role columns to public.profiles: role, is_admin, plan, credits, or balance. Because PostgreSQL grants table-level UPDATE to authenticated by default on new Supabase tables, and USING ((SELECT auth.uid()) = user_id) only restricts which row is targeted, any signed-in user can open DevTools and run:
PATCH /rest/v1/profiles?user_id=eq.<their-uid> Content-Type: application/json {"role": "admin", "is_admin": true, "credits": 999999} PostgREST updates the columns directly.
I released supabase-rls-check v0.7.0 (MIT, Python 3.11+, 159 automated tests passing) to catch this pattern alongside non-invoker views and leaked keys inside compiled frontend bundles.
GitHub: https://github.com/Tthanh2k6/supabase-rls-check
PyPI: https://pypi.org/project/supabase-rls-check/
1. column_update_escalation (Catalog + Static SQL DDL)
Rule #21 in check.sql (column_update_escalation, High severity) inspects pg_catalog.pg_policies and pg_catalog.pg_attribute in one read-only query. It flags any PERMISSIVE policy for UPDATE or ALL in public granted to anon, authenticated, or PUBLIC when:
- The table contains columns matching
role,is_admin,plan,tier,credits,balance,subscription_status, ororg_id. - The role holds table-level or column-level
UPDATEprivileges on those columns (has_table_privilegeorhas_column_privilege). - The policy's
WITH CHECKexpression does not reference and guard the column name.
The basis field lists the exact updatable columns (for example, credits, is_admin, role).
To fix it without breaking profile edits, revoke table-level UPDATE and grant column-level UPDATE only on safe user-editable columns (or move billing and role state to a separate server-managed table):
REVOKE UPDATE ON public.profiles FROM PUBLIC, anon, authenticated; GRANT UPDATE (display_name, avatar_url) ON public.profiles TO authenticated; In v0.7.0, the static SQL parser (scan_sql) also detects column_update_escalation directly on raw migration .sql files before you apply them to a database, tracking CREATE TABLE, ALTER TABLE ... ADD COLUMN, REVOKE UPDATE, and column-specific GRANT UPDATE (col1, col2).
2. view_not_invoker Across Catalogs and Raw Migrations
In PostgreSQL, CREATE VIEW public.user_summaries AS ... defaults to security_invoker = false. When queried through PostgREST (/rest/v1/user_summaries), the view executes with the permissions of the view owner (postgres), bypassing RLS on the underlying tables.
check.sql already checked live catalogs for views in public missing security_invoker=true in pg_class.reloptions. In v0.7.0, scan_sql brings the same view_not_invoker detection to offline .sql migration files and folders. It flags CREATE [OR REPLACE] VIEW statements in public unless the view is created with WITH (security_invoker = true) (or on / 1) or followed by:
ALTER VIEW public.user_summaries SET (security_invoker = true); Materialized views are skipped by this check and covered separately under matview_api_exposed and auth_users_exposed.
3. Offline Frontend Bundle Scanner (scan-bundle)
Earlier versions included scan-env for project source directories (which skips dist/, build/, and web-build/). When auditing a deployed or pre-release build artifact where source files are already bundled into dist/assets/index-a1b2c3.js or static .html files, you want to scan the compiled output directly.
v0.7.0 adds scan-bundle to both the CLI and the read-only stdio MCP server:
supabase-rls-check scan-bundle ./dist --out bundlescan.json scan-bundle walks build output, source files (.js, .mjs, .cjs, .jsx, .ts, .tsx, .html, .htm, .vue, .svelte), .env*, app.json, and eas.json up to 5 MB per file with zero network calls. It detects:
-
service_role_in_client_codeandpublic_env_service_role(Critical): JWTs whose payload decodes to"role": "service_role"(ignoring safeanonJWTs) andsb_secret_*keys. -
db_url_in_client_code(Critical):postgres://orpostgresql://connection strings containing a literal password (ignoring placeholders such as${DB_PASSWORD}). -
public_env_secret_key(High): client-prefixed variables (NEXT_PUBLIC_,VITE_,EXPO_PUBLIC_,REACT_APP_,PUBLIC_,NUXT_PUBLIC_) carrying secret prefixes (sk_live_,rk_live_,sk-proj-,sk-ant-) or secret variable names.
Every match is masked before printing (first6…last4) so secrets never leak into terminal logs or CI artifacts.
Try v0.7.0
pipx install supabase-rls-check # or run via uvx: uvx supabase-rls-check --version To inspect the full explanation and remediation SQL for the new column escalation rule:
supabase-rls-check explain column_update_escalation 