Auditing Supabase
Supabase is a backend-as-a-service built on Postgres. It provides a REST API generated automatically from the schema (PostgREST), authentication, file storage, realtime and functions. The browser talks directly to the database through that API using a public key. That’s why all of the application’s authorization lives in one place: Postgres Row Level Security (RLS) policies. Auditing Supabase is mostly auditing RLS and everything that can bypass it.
Responsibility model
Section titled “Responsibility model”Supabase handles the platform: infrastructure, patching, encryption and backups. The customer handles the RLS policies, where the keys go, the Auth and network configuration, and the security of the account and organization.
flowchart LR
N["Browser<br/>publishable key<br/>+ user JWT"] --> API["Supabase API<br/>/rest/v1, /storage/v1,<br/>/auth/v1"]
API -->|"no session: anon role<br/>signed in: authenticated"| PG[("Postgres<br/>RLS policies")]
B["Backend / Edge Function<br/>secret key"] --> API
API -->|"service_role<br/>BYPASSRLS"| PG
D["Direct connection<br/>user and password"] -->|"SSL, network restrictions"| PG
Keys and roles
Section titled “Keys and roles”| Key | Format | Postgres role | Where it can go |
|---|---|---|---|
| Publishable | sb_publishable_... |
anon without a session, authenticated with one |
Browser, apps, public repositories |
| Secret | sb_secret_... |
service_role (BYPASSRLS attribute) |
Backend only: servers, Edge Functions, workers |
anon (legacy) |
Long-lived JWT | anon / authenticated |
Same as publishable |
service_role (legacy) |
Long-lived JWT | service_role |
Same as secret |
| Database password | Connection string | postgres |
Backend and administration only |
What to check:
- Legacy keys are JWTs that expire after ten years. Supabase is retiring them and plans to require the new ones by late 2026. Creating the new keys doesn’t revoke the legacy ones: they have to be disabled separately.
- Secret keys return 401 when used from a browser (Supabase detects it through the
User-Agent). Even so, a secret in the client is a critical finding, because it keeps working outside the browser. - The recommendation is a different secret per backend component, to limit the damage of a leak.
- In Edge Functions,
verify_jwtisn’t enough with the new keys: key authorization has to be done in code.
Lab: RLS and what bypasses it
Section titled “Lab: RLS and what bypasses it”To see each mistake’s effect without touching a real project, the lab reproduces Supabase’s model in Postgres 16. It creates the anon, authenticated and service_role roles (the last one with BYPASSRLS), the auth.uid() and auth.jwt() functions, which read the JWT claims the way PostgREST does, and the default grants on public. The tests use set role and request.jwt.claims, which is what PostgREST does on every request.
| Object | Mistake | Result as anon or a regular user |
|---|---|---|
perfiles |
RLS disabled | anon reads everyone’s names and phone numbers |
notas |
for select using (true) policy |
anon reads everyone’s private notes |
pedidos |
Correct policy: (select auth.uid()) = user_id |
anon sees 0 rows; Ana only sees her own order |
pedidos_resumen |
View over pedidos without security_invoker |
anon sees both orders: the view bypasses RLS |
facturas |
Policy that checks user_metadata ->> 'role' |
Ana sees 0 invoices, sets her own user_metadata to admin and sees all of them |
buscar_email() |
SECURITY DEFINER function executable by anon |
anon gets the emails from auth.users |
Postgres views run by default with their owner’s privileges, and in Supabase the owner is usually postgres. Supabase’s documentation warns about it: views bypass RLS by default. user_metadata is meant to be edited by the user (supabase.auth.updateUser({ data: { role: 'admin' } })), so it can never decide permissions. That’s what app_metadata is for: only the server writes it.
Audit queries
Section titled “Audit queries”With read access to the schema (dashboard SQL editor or a direct connection), these catalog queries find the four patterns:
-- Tables in public without RLSselect c.relname from pg_class c join pg_namespace n on n.oid = c.relnamespacewhere n.nspname = 'public' and c.relkind = 'r' and not c.relrowsecurity;
-- Policies that always pass or read user_metadataselect tablename, policyname, cmd, roles, qual from pg_policieswhere schemaname = 'public' and (qual = 'true' or with_check = 'true' or qual like '%user_metadata%');
-- Views readable by anon/authenticated without security_invokerselect c.relname from pg_class c join pg_namespace n on n.oid = c.relnamespacewhere n.nspname = 'public' and c.relkind in ('v','m') and (has_table_privilege('anon', c.oid, 'select') or has_table_privilege('authenticated', c.oid, 'select')) and not coalesce(c.reloptions::text[] && array['security_invoker=true','security_invoker=on','security_invoker=1'], false);
-- SECURITY DEFINER functions anon can execute (reachable through /rest/v1/rpc)select p.proname, pg_get_function_identity_arguments(p.oid) from pg_proc pjoin pg_namespace n on n.oid = p.pronamespacewhere n.nspname = 'public' and p.prosecdef and has_function_privilege('anon', p.oid, 'execute');Output in the lab before the fix:
perfiles -- no RLS facturas | admins ven facturas | SELECT | {authenticated} | ((auth.jwt() -> 'user_metadata') ->> 'role') = 'admin' notas | leer notas | SELECT | {anon,authenticated} | true pedidos_resumen -- view without security_invoker buscar_email | p text -- SECURITY DEFINER executable by anonalter table public.perfiles enable row level security;create policy "cada uno su perfil" on public.perfiles for select to authenticated using ((select auth.uid()) = id);
drop policy "leer notas" on public.notas;create policy "solo mis notas" on public.notas for select to authenticated using ((select auth.uid()) = user_id);
alter view public.pedidos_resumen set (security_invoker = on); -- Postgres 15+
drop policy "admins ven facturas" on public.facturas;create policy "admins ven facturas" on public.facturas for select to authenticated using ((auth.jwt()->'app_metadata'->>'role') = 'admin');
revoke execute on function public.buscar_email(text) from public, anon, authenticated;After applying it, all four queries return 0 rows, anon sees nothing, Ana only sees her own order, changing user_metadata no longer grants access to the invoices and the function call returns permission denied. service_role still sees both orders, because it has BYPASSRLS.
Two behaviors that confuse an outside audit:
- Without a grant, the request returns a permission error. With a grant but no matching policy, it returns an empty list. An empty list doesn’t prove there’s no data.
- A
for selectpolicy doesn’t coverinsert,updateordelete. Check every operation and itswith check.
Outside check
Section titled “Outside check”With the project URL and the publishable key taken from the front end, on a project you own or are authorized to test:
# No session: what does each exposed table return?curl -s "https://<ref>.supabase.co/rest/v1/perfiles?select=*&limit=1" \ -H "apikey: $SB_PUBLISHABLE"
# As a test user: can they see someone else's rows?curl -s "https://<ref>.supabase.co/rest/v1/pedidos?select=id,user_id" \ -H "apikey: $SB_PUBLISHABLE" -H "Authorization: Bearer $JWT_USER_A"The /rest/v1/ root (the OpenAPI description listing every table) only answers with a secret key. From the outside, table names come from the application’s own JavaScript.
Storage, Realtime and Auth
Section titled “Storage, Realtime and Auth”- Buckets. They’re private by default, and then every operation goes through RLS on
storage.objects. A public bucket serves any file to whoever has the URL, with no access control. Uploading, deleting and moving still need a policy. IDs, invoices or private attachments never go in a public bucket. A broadselectpolicy onstorage.objectsalso lets clients list the whole bucket. - Realtime. Replicated tables with sensitive data need RLS. To send sensitive changes only to authorized users, Supabase recommends Broadcast with authorization. RLS does not filter Postgres Changes
DELETEevents. - Auth.
- Email confirmation turned on.
- No test phone numbers.
- OTP expiry of 3600 s or less. It also applies to confirmation, recovery and invite links.
- Custom SMTP, and MFA for users if the data calls for it.
- Unused sign-in providers disabled.
Network, account and logs
Section titled “Network, account and logs”- SSL Enforcement turned on. For compatibility, Supabase accepts Postgres connections without SSL by default.
- Network Restrictions for direct database connections. They don’t affect the HTTPS APIs, which rely on keys and policies.
- Account:
- MFA (or GitHub 2FA if you sign in with GitHub).
- MFA enforced in the organization (Pro, Team and Enterprise plans).
- More than one owner.
- Logs.
log_connectionsis off in new projects: turn it on if you want to trace who connects. - Recovery. Point in Time Recovery, if the impact of losing data justifies it.
| Tool | Use |
|---|---|
| Security Advisor (dashboard) | Linter findings per project. Supabase also emails about tables created without RLS |
supabase db advisors (CLI) |
The same findings from the terminal or in CI |
Management API (security advisors, SSL and network settings) |
Read-only audit across projects |
| Splinter | The open-source SQL linter behind the Advisor |
supabase test db (pgTAP) |
RLS policy tests that run in CI |
Real cases
Section titled “Real cases”- CVE-2025-48757 (Lovable, 2025). Apps generated by Lovable up to April 15, 2025 had insufficient RLS policies. Anyone, without authenticating, could read or write arbitrary tables using only the front end’s public key (CVSS 9.3). The researcher reached personal data from user tables, third-party API keys and payment data whose status could be changed. The pattern is the lab’s
perfilesandnotastables. - Alerts and defaults (2025). Supabase started showing warnings in the table editor and emailing about tables created without RLS. It also announced that
pg_graphqlwould be disabled in new projects. Those alerts don’t replace an audit: they don’t covertrueread policies or business logic.
Checklist
Section titled “Checklist”- No secret key,
service_roleor database password in the front end, repositories or logs - Legacy keys disabled if no longer used; one secret per backend component
- RLS enabled on every table in the exposed schemas
- Each policy reviewed per operation (
select,insert,update,delete), withwith checkwhere needed - No
truepolicy on data that isn’t public - No policy based on
user_metadata; roles live inapp_metadata - Views with
security_invoker = onor no access foranonandauthenticated; no exposed materialized views -
SECURITY DEFINERfunctions withoutEXECUTEforanonandauthenticatedunless needed, and with a fixedsearch_path - Buckets with private data set to private; no broad listing policies
- Outside test with the publishable key: no session and two users
- Auth: email confirmation, OTP ≤ 3600 s, no test phone numbers, custom SMTP
- SSL Enforcement and Network Restrictions turned on
- MFA on the account and enforced in the organization; more than one owner
- Security Advisor with no errors and every warning justified
References
Section titled “References”- Supabase: Production security checklist
- Supabase: API keys
- Supabase: Row Level Security
- Supabase: Storage access control
- Supabase: Storage buckets
- Supabase: Advisors
- Supabase: Shared Responsibility Model
- Splinter: 0010 Security Definer View
- Splinter: 0015 RLS references user_metadata
- PostgreSQL: CREATE VIEW (security_invoker)
- NVD: CVE-2025-48757
- Matt Palmer: CVE-2025-48757