---
name: supabase-security-audit
description: Audit a Supabase project's security and performance by checking RLS coverage and policies, exposed schemas, risky functions, extensions, storage buckets and Supabase advisors, then prioritising the fixes. Use when the user asks if their Supabase project is secure, wants a security review before launch, or asks about RLS gaps.
---

# Supabase security and performance audit

Read-only. Every `execute_sql` call here is a SELECT. Fixes are proposed, and are applied only after the user approves each one.

## Checks

1. Run `get_advisors` for both security and performance, and take its findings as the backbone of the report, with their remediation links.
2. RLS: from `list_tables`, list tables in exposed schemas without RLS. With a read-only `execute_sql` on `pg_policies`, flag policies that are always true, such as `using (true)` for anon or authenticated on sensitive tables, and tables that have RLS on but no policies.
3. Functions: find `security definer` functions in exposed schemas, which bypass RLS, with a read-only query on `pg_proc`.
4. Extensions: `list_extensions`, and flag extensions installed in the public schema.
5. Storage: `list_storage_buckets` and `get_storage_config`. Flag public buckets that hold user files and missing size or type limits.
6. Keys: check that the app only uses the publishable or anon key, from `get_publishable_keys`, in client code when the repo is open.

## Report

A prioritised list: critical (data readable or writable by anyone), high, medium and low. Each item gives the finding, evidence and the exact fix SQL. Offer to apply the fixes through the schema-change flow, one approved migration at a time.
