FixRLSFixRLS
RLS Errorservice_role KeyPublishable KeyAnon KeyMCP Setup

Supabase service_role key: safe usage and exposure checklist

Use this page when a service_role or secret key may have reached browser code, mobile code, a public repo, or committed MCP config. The tool gives an emergency checklist without asking for the actual key.

Fix privileged key exposure

Contain service_role or secret key risk before adapting RLS.

Issue

Pick a shortcut, then tune the settings below.

Fix settings

These controls restore the original page behavior.

Placeholders

Use schema names only. Do not paste secrets.

No secrets needed. Placeholder-only.

Privileged key emergency checklist

Contain service_role or secret key exposure first. RLS SQL is secondary because privileged requests can bypass RLS.

Copy in one click

service_role/secret requests can bypass RLS and RLS SQL does not constrain them.

service_role / secret key placement:

Never expose these keys in browser JavaScript, mobile apps, public repositories, committed MCP config, or NEXT_PUBLIC_* environment variables.
Treat exposure as urgent because privileged keys can bypass RLS or perform elevated operations.
RLS SQL does not constrain requests made with service_role or secret keys.

Emergency checklist:
1. Remove the key from client/public code.
2. Rotate or delete the exposed key in Supabase.
3. Move privileged operations to a server route or Supabase Edge Function.
4. Replace frontend usage with a publishable or anon key plus RLS.
5. Review logs for unusual reads, writes, exports, or schema changes.
6. Add CI checks for forbidden env names such as NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY.
7. Only then adapt normal-client RLS policies for publishable/anon keys plus authenticated sessions.

Copy outputs

Copy the companion outputs for agent repair, testing, and key placement.

{}

Copy AI repair prompt

Paste this into Cursor, Claude Code, or Lovable for an agent fix tailored to your schema.

Copy proof-of-fix test

Get a checklist and SQL test script to confirm the fix works as intended.

{}

Secondary RLS SQL template

Use only after replacing frontend privileged key usage with publishable/anon + authenticated sessions.

Launch Safety Pack

Early-access pack with 15 bundles: AI repair prompts, test scripts, policy templates, MCP guards, and more.

© 2026 FixRLSPrivacyTerms