Supabase
Security FAQ

What are Supabase security best practices?

Get instant answers about your app's security.

Short Answer

Supabase security best practices are dictated by Supabase's actual risk profile, not a generic checklist. The top three: alter table name enable row level security; on every table; never use service_role in frontend; use (select auth.

Detailed Answer

The best practices specific to Supabase (not generic OWASP)

Every "security best practices" list tells you to use HTTPS and rotate keys. Those are table stakes. The list below is what actually matters for Supabase apps, based on the risks that appear in real Supabase deployments.

1. ALTER TABLE name ENABLE ROW LEVEL SECURITY; on every table

*Why:* Any table without RLS enabled is fully exposed via the public API. *Do this:* ALTER TABLE name ENABLE ROW LEVEL SECURITY; on every table.

2. Never use service_role in frontend

*Why:* The service_role key bypasses all RLS and grants admin access. *Do this:* Never use service_role in frontend. Keep it server-side only. Rotate if exposed.

3. Use (select auth

*Why:* Policies that allow more access than intended (e.g., any authenticated user). *Do this:* Use (select auth.uid()) = user_id pattern. Test policies with different contexts.

4. Add auth

*Why:* Database functions callable without authentication. *Do this:* Add auth.uid() IS NOT NULL checks at the start of all functions.

5. Configure storage policies to require authentication and ownership

*Why:* Storage buckets without policies allow public read/write. *Do this:* Configure storage policies to require authentication and ownership.

Supabase-specific: audit every table for RLS before every deploy

The failure mode in Supabase + Supabase apps is always the same: a table gets added during a feature push, RLS never gets turned on, the full table becomes queryable via the anon key. Bake a pre-deploy check: `select tablename from pg_tables where schemaname = 'public' and not rowsecurity` — the result must be empty.

Verification

Even perfect best practices don't prove themselves — the only way to confirm the list above is implemented is to scan a deployed Supabase app. VAS probes each of rls policies, service key exposure, rpc functions, auth configuration by actually attempting the attack, not just reading headers or docs.

Security Research & Statistics

10.3%

of Lovable applications (170 out of 1,645) had exposed user data in the CVE-2025-48757 incident

Source: CVE-2025-48757 security advisory

91%

of data breaches involve databases with misconfigured access controls

Source: Verizon Data Breach Investigations Report

4.45 million USD

average cost of a data breach in 2023

Source: IBM Cost of a Data Breach Report 2023

Expert Perspectives

Vibe coding your way to a production codebase is clearly risky. Most of the work we do as software engineers involves evolving existing systems, where the quality and understandability of the underlying code is crucial.

Simon WillisonSecurity Researcher, Django Co-creator

The problem with AI-generated code isn't that it doesn't work - it's that it works just well enough to ship, but contains subtle security flaws that are hard to spot.

Security Research CommunityCollective wisdom from security researchers

Check Your Supabase App's Security

VAS scans for all the security issues mentioned above. Get a comprehensive security report in minutes.

Get Starter Scan

More Questions About This Topic

What's the single most important Supabase security step?

ALTER TABLE name ENABLE ROW LEVEL SECURITY; on every table. This closes tables without rls, which is the #1 critical-impact finding in Supabase apps. Everything else is secondary — if this one gap exists, the rest doesn't matter.

Should I follow Supabase's docs or a third-party best-practices list?

Both, for different things. Supabase's docs tell you *how* to configure their specific features — that's authoritative. Third-party best practices (including this one) tell you *which* failure modes show up in real Supabase deployments — that's where Supabase's docs under-deliver, because Supabase doesn't advertise what its own users misconfigure. Use docs for syntax, external guidance for priority.

How often should I re-audit Supabase app security?

Before every production release, without exception. Supabase's AI-assisted workflow means database schemas, API endpoints, and auth logic can change in a single chat session — any of which can introduce an issue from the list above. Weekly automated scans for live Supabase apps are a reasonable baseline; post-feature scans are non-negotiable.