- Home
- Skills
- Data & Databases
- Supabase Security Audit: RLS, RPC and Key Leaks
Works with the AI Agents you already use
Supabase Security Audit: RLS, RPC and Key Leaks
Securing a Supabase project requires more than just ticking boxes in the dashboard.
$7
Supabase Security Audit: RLS, RPC and Key Leaks
Example session with this skill installed
Audit my Supabase project before launch. It's a Next.js marketplace with listings, profiles and orders.
- Read your context and instructions
- Compiled the supabase security audit
- Generated the document
Supabase security audit: marketplace
Ran the audit SQL, the code scan and the live probe with the anon key.
Findings
| Severity | Location | What a stranger can do | Fix |
|---|---|---|---|
| Critical | lib/admin.ts:4 | SUPABASE_SERVICE_ROLE_KEY is read through NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY, so it ships in the browser bundle (found in .next/static/chunks/) | Move the admin call to a server route; rotate the key in Dashboard > API keys |
| High | public.orders | RLS is off. Probe read 3 of 1,214 orders with names and addresses | Enable RLS + owner policies (migration below) |
| High | public.listings.seller_phone | Readable by anon on every public listing (RLS is per row, not per column) | Column grants: revoke table select, grant only public columns |
| High | public.admin_stats() | SECURITY DEFINER, no search_path, executable by anon. Probe called it and got revenue totals | set search_path = '', revoke execute from public, anon |
| Medium | app/search/page.tsx:18 | .or() filter built from the raw search string lets a crafted q rewrite the filter | Replace with a search_listings(q) RPC with a typed parameter |
| Low | bucket avatars | Public, contains only avatars | Intended: no change |
Migration
alter table public.orders enable row level security;
create policy "buyer reads own orders" on public.orders
for select to authenticated using ((select auth.uid()) = buyer_id);
revoke select on public.listings from anon, authenticated;
grant select (id, title, price, city, photos, created_at) on public.listings to anon, authenticated;
alter function public.admin_stats() set search_path = '';
revoke execute on function public.admin_stats() from public, anon;
Re-test
node scripts/rls-probe.mjs orders listings --rpc admin_stats
Expected: orders 0 rows, listings without seller_phone, admin_stats blocked.
Rotate the service_role key before deploying the fix: it has already been public.
page.tsx
PDF · document
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
About this skill
Securing a Supabase project requires more than just ticking boxes in the dashboard. If your RLS policies are weak or your client-side filters are improperly handled, anyone with your public anon key can scrape your entire database or escalate privileges.
This skill audits your Supabase implementation across the database, server-side functions, and client-side code to identify data leaks before they are exploited.
What it does
- RLS validation identifies tables where Row Level Security is disabled or using overly permissive policies.
- Function auditing scans RPCs for SECURITY DEFINER vulnerabilities and missing search_path definitions.
- Injection detection greps through client code for unsafe use of .or(), .filter(), and raw SQL templates.
- Key leak detection searches build artifacts and environment variables for exposed service_role keys.
- Live probing simulates an unauthenticated attacker attempting to read private tables and call RPCs.
How it works
- Analyze Security Advisor results to clear high-level dashboard warnings and schema configuration errors.
- Execute audit SQL to find specific tables, columns, and functions exposed to anon and authenticated roles.
- Scan the codebase using grep patterns to find filter injection risks and hardcoded secrets.
- Run the RLS probe script with the public key to verify that private data returns empty sets or errors.
Why this beats prompting it yourself
Generic security prompts often miss the nuances of PostgREST syntax and the specific ways SECURITY DEFINER functions bypass schema permissions. This skill uses a multi-stage approach that combines static SQL analysis with actual network probes, ensuring you catch what an LLM might hallucinate as "safe" logic.
Use cases
- Audit a new project for RLS gaps before moving from development to production.
- Verify that private columns like email or phone are truly hidden from the public key.
- Check Edge Functions and Next.js routes for leaked service_role credentials.
- Test RPC security after adding complex database logic or views.
Known limitations
This skill requires the user to provide output from the Supabase Security Advisor or have access to run provided SQL and shell scripts. It cannot automatically rotate leaked keys.
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 3 days ago
- Software
- Supabase project
- Optional
Node.js 18+ (for the live probe)ripgrep (for the code scan)
Permissions
What's inside
Frequently Asked Questions
New in Data & Databases
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.