rls-policy-auditor

Audit Postgres row-level security policies for tenant isolation failures.

2|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/nguyenpv1980-wq/Project-Aegis --skill rls-policy-auditor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rls-policy-auditor
Source: https://github.com/nguyenpv1980-wq/Project-Aegis/tree/main/.claude/skills/rls-policy-auditor
Command: npx skills add https://github.com/nguyenpv1980-wq/Project-Aegis --skill rls-policy-auditor

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill audits row-level security policies to verify that tenant-scoped database data is actually protected, not just configured. It finds missing tenant filters, write-side gaps, recursion, unsafe helpers, overly broad grants, and other conditions that can leak or corrupt tenant data.

Core Features & Use Cases

  • Per-command policy audit: Reviews SELECT, INSERT, UPDATE, and DELETE policies separately so read and write holes are caught independently.
  • Failure-mode detection: Flags missing WITH CHECK clauses, deny-by-default gaps, policy recursion, SECURITY DEFINER risks, service-role leakage, and frontend-derived tenant scope.
  • Negative-test planning: Produces runnable denial tests that prove wrong-tenant, wrong-role, and missing-auth access is blocked, with positive controls for comparison.
  • Use case: A team has enabled RLS on Supabase tables and needs a rigorous audit before shipping multi-tenant features or fixing a suspected isolation bug.

Quick Start

Ask the skill to audit your tenant-table RLS policies and generate a per-command findings report plus negative-test SQL that proves cross-tenant access is denied.

Frequently Asked Questions about rls-policy-auditor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit row-level security policies in Postgres to prevent cross-tenant data access?

To audit row-level security policies, you review SELECT, INSERT, UPDATE, and DELETE commands separately to detect missing tenant filters, write-side gaps, and recursion that can leak cross-tenant data. This process verifies tenant isolation at the database layer rather than just checking configuration.

Why does row-level security still allow cross-tenant access in my multi-tenant database?

Row-level security can allow cross-tenant access due to missing WITH CHECK clauses, deny-by-default gaps, policy recursion, or frontend-derived tenant scope. Auditing these failure modes per command identifies the specific write-side holes or unsafe helpers causing the leakage.

How do I write negative tests to prove tenant isolation for Supabase RLS policies?

You write negative tests by generating runnable denial SQL that attempts wrong-tenant, anon, and service-role access against your tenant tables. These tests prove cross-tenant access is denied, using positive controls for comparison to verify isolation holds.

Does my Postgres RLS policy need a WITH CHECK clause for INSERT and UPDATE operations?

Yes, your Postgres RLS policy needs a WITH CHECK clause for INSERT and UPDATE operations to prevent write-side gaps. A per-command policy audit flags missing WITH CHECK clauses separately from read policies to ensure tenant data cannot be corrupted.

What's the best way to check for service-role leakage in Postgres row-level security policies?

The best way to check for service-role leakage is to perform a per-command policy audit that reviews SELECT, INSERT, UPDATE, and DELETE behavior, specifically flagging SECURITY DEFINER risks and overly broad grants that bypass tenant isolation restrictions.

Can I use a policy audit to verify tenant isolation before shipping multi-tenant features?

Yes, you can use a policy audit to verify tenant isolation before shipping multi-tenant features by generating a per-command findings report and negative-test SQL. This proves wrong-tenant, wrong-role, and missing-auth access is blocked across all table operations.