Supabase RLS & RPC Security Auditor MCP avatar

Supabase RLS & RPC Security Auditor MCP

Pricing

from $50.00 / 1,000 supabase rls & rpc security audits

Go to Apify Store
Supabase RLS & RPC Security Auditor MCP

Supabase RLS & RPC Security Auditor MCP

Deterministic MCP server auditing Supabase SQL migrations & client code for missing RLS, permissive policies, SECURITY DEFINER search_path bugs, orphaned RPCs, and leaked secrets (/mcp).

Pricing

from $50.00 / 1,000 supabase rls & rpc security audits

Rating

0.0

(0)

Developer

Pablo Ian Laurino

Pablo Ian Laurino

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

10 hours ago

Last modified

Features

Limited permissions

Share

An Apify Standby MCP server for Supabase projects. It serves one deterministic tool over Streamable HTTP at /mcp that statically audits SQL migrations and client code for RLS gaps, SECURITY DEFINER function issues, orphaned RPC calls, and exposed secrets. It reads only the data supplied in each call and makes no network changes.

Tool

ToolInputOutputEvent price
supabase_rls_auditproject_path: path to project directory inside containerSummary counts, detailed findings with fixes, and formatted report$0.05

Rules Checked

Rule IDSeverityTitle
RLS-001CRITICALPublic table has RLS disabled
RLS-002HIGHPolicy grants unrestricted access
RPC-001HIGHSECURITY DEFINER function lacks search path or authorization guard
RPC-002HIGHFrontend calls a missing RPC function
SEC-001CRITICALPotential secret exposed in client material

The audit uses only standard-library Python (no runtime deps beyond the MCP/Apify SDKs). It parses SQL files for CREATE TABLE, ALTER TABLE ... ENABLE ROW LEVEL SECURITY, CREATE POLICY, CREATE FUNCTION, and DROP FUNCTION statements. It scans client source files (TypeScript/JavaScript/React under src/) for .rpc() calls and secret patterns (SUPABASE_SERVICE_ROLE_KEY, VITE_*_SECRET, VITE_*_SERVICE_ROLE, JWTs).

Run locally

Requires Python 3.11+.

pip install -e .
python -m pytest tests/
python -m src.main

The server listens on ACTOR_WEB_SERVER_PORT or port 3000 and provides GET /health. For a local billing simulation, set ACTOR_TEST_PAY_PER_EVENT=true before starting. Local calls without this variable are unbilled. On Apify, each successfully returned tool result calls Actor.charge once; a charge failure or exhausted spending limit prevents the result from being returned. Invalid arguments are not charged.

Example MCP client configuration after deployment

{
"mcpServers": {
"supabase-rls-auditor": {
"url": "https://YOUR-STANDBY-URL.apify.actor/mcp",
"headers": { "Authorization": "Bearer YOUR_APIFY_API_TOKEN" }
}
}
}

Example arguments

{
"project_path": "/app/project",
"format": "json",
"fail_on": "critical"
}

The project directory should be mounted or copied into the container at the specified path. The audit scans:

  • All .sql files (migrations) for RLS, policies, and RPC functions
  • .env.example at the project root
  • Client files under src/ with extensions .ts, .tsx, .js, .jsx

Deploy and monetize

  1. Push with apify push from this directory. .actor/actor.json enables Standby and exposes /mcp.
  2. In Apify Console, set the Actor pricing model to Pay per event and verify the event name and USD price in .actor/pay_per_event.json. Apify documents an 80% creator share of PPE event revenue; applicable platform costs and terms affect the final payout. The code does not set a payout percentage.
  3. Set a sensible per-run spending limit and test the tool through the Standby URL with an Apify token. Apify authenticates the public Standby URL; the container HTTP server relies on that proxy and should not be exposed directly to the public internet.

The Docker image installs locked production dependencies and runs as an unprivileged user. The service is stateless, so multiple Standby instances can serve calls independently.

Local testing with a sample project

# Create a test project structure
mkdir -p /tmp/test-project/supabase/migrations /tmp/test-project/src
# Add a migration with issues
cat > /tmp/test-project/supabase/migrations/001_init.sql <<'EOF'
CREATE TABLE public.profiles (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
user_id uuid REFERENCES auth.users(id),
name text
);
-- Missing: ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Public read" ON public.profiles FOR SELECT USING (true);
CREATE FUNCTION public.get_user_profile(user_id uuid)
RETURNS json LANGUAGE sql SECURITY DEFINER AS $$
SELECT json_build_object('id', id, 'name', name) FROM public.profiles WHERE user_id = get_user_profile.user_id;
$$;
-- Missing: SET search_path = public, pg_temp AND auth.uid() guard
EOF
# Add client code with issues
cat > /tmp/test-project/src/api.ts <<'EOF'
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
process.env.SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY! // SEC-001: Service role key in client
)
supabase.rpc('get_user_profile', { user_id: '...' }) // RPC-002 if function missing
supabase.rpc('missing_function', {}) // RPC-002: orphaned call
EOF
# Run the auditor locally (unbilled)
ACTOR_TEST_PAY_PER_EVENT=true python -m src.main &
sleep 2
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"supabase_rls_audit","arguments":{"project_path":"/tmp/test-project","format":"json"}}}'

Limitations

  • Static analysis only — no live database connection, no query execution, no runtime policy evaluation.
  • SQL parsing handles common patterns but is not a full PostgreSQL parser; complex statements (CTEs, dollar-quoted bodies, nested functions) may be missed.
  • Client scanning is limited to src/ directories and common file extensions; monorepo structures may need path adjustment.
  • RPC-002 only reports calls to functions not seen in scanned SQL; functions created outside scanned migrations (e.g., via Supabase Dashboard) will be false positives.
  • Secret detection is pattern-based; false positives/negatives possible. Always rotate any credential that was committed.

License

MIT — see the LICENSE file if present.