# Supabase Security Audit: RLS, RPC and Key Leaks

> See what a stranger can read or call with your public Supabase key. Audit SQL, a live RLS probe and an injection scanner find open tables, leaky columns, anon-callable SECURITY DEFINER functions and service_role keys in client code, with fix SQL for each.

Supabase Security Audit: RLS, RPC and Key Leaks is a paid AI agent skill on Agensi by Hayder Al-Hwaidi, in Data & Databases. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $7 (one-time purchase)
- Creator: [Hayder Al-Hwaidi](https://www.agensi.io/creators/hayder-al-hwaidi)
- Category: [Data & Databases](https://www.agensi.io/skills/data-databases)
- Version: 1.0.0
- Last updated: 2026-12-01
- Security: scan passed (2026-12-01); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/supabase-security-audit-rls-rpc-and-key-leaks
- Tags: supabase, security, postgres, rls, audit, nextjs, sql-injection

## 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
1. **Analyze Security Advisor results** to clear high-level dashboard warnings and schema configuration errors.
2. **Execute audit SQL** to find specific tables, columns, and functions exposed to anon and authenticated roles.
3. **Scan the codebase** using grep patterns to find filter injection risks and hardcoded secrets.
4. **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.

## Requires

- Supabase project
- Optional: Node.js 18+ (for the live probe)
- Optional: ripgrep (for the code scan)

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Supabase Security Audit: RLS, RPC and Key Leaks skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What specific security vulnerabilities does this skill detect in a Supabase project?

This skill identifies critical vulnerabilities such as tables with disabled Row Level Security, overly permissive policies that leak private data, and SECURITY DEFINER functions that lack proper search paths. It also scans for service role keys leaked in client bundles and potential SQL or filter injection risks in your code.

### What do I need to provide for the skill to perform a full audit?

You should provide the output from the Supabase Security Advisor or be prepared to run provided SQL queries and shell scripts against your database and codebase. The skill also utilizes a probe script that requires your Supabase URL and public anon key to simulate an external attack.

### What kind of report or output does this skill generate?

You receive a detailed findings table sorted by severity that explains exactly what an unauthorized stranger can access or execute. For every identified risk, the skill provides the specific location, the potential impact, and the migration SQL needed to fix the hole.

### Are there any limitations to what this skill can fix automatically?

While this skill identifies leaked service role keys in your build artifacts or environment variables, it cannot automatically rotate those keys for you. It also requires manual execution of its provided SQL and scripts if your agent does not have direct database access.

### When is the best time to ask my agent to use this skill?

You can ask your agent to audit a new project for RLS gaps before moving to production or verify if specific private columns like emails are truly hidden from the public. It is also useful for checking Edge Functions and Next.js routes for leaked credentials after adding new database logic.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
