Skip to content

Supabase

Scope: web apps, mobile apps and games whose clients call Supabase directly, on the hosted Supabase platform (projects on Postgres 15 and 17), with the Supabase CLI 3 and supabase-js 2 (CLI 2 still gets security fixes, but no new features, after the move to CLI 3): Row Level Security and grants, API keys, Storage, Edge Functions, migrations and environments, database connections, backups and Auth settings. Because clients query the database through the Data API, Row Level Security carries the server-side authorisation that SEC-1 asks for, and the key in the client is public (SEC-11 in Security). A Supabase database is PostgreSQL, so PostgreSQL applies to its schema, indexes and migrations; its rules aren't repeated here. Sign-in in general is covered in Authentication and sessions, personal data in Privacy and personal data, browser apps in Web front end, mobile games in Mobile games, and connecting from serverless functions in Serverless and edge hosting. For a document-database backend of the same kind, see Firebase.

Entries are sorted by score from 1 to 10 (criteria): 9โ€“10 start here or strongly recommended, 6โ€“8 recommended, 1โ€“5 further reading or conditional.

Adopted references

  • 8 Production Checklist: performance, availability (including your own SMTP server for Auth emails), deployment, and Auth rate limits and abuse prevention. Its security part is now the Production security checklist.
  • 8 Production security checklist: Row Level Security, SSL enforcement and network restrictions, account and organization access, Auth settings, and a threat review.
  • 8 Row Level Security: the baseline for data access: how grants and policies combine, securing a table step by step, testing policies with pgTAP, indexes for policies, helper functions such as auth.uid() and auth.jwt(), and security definer functions.
  • 8 Securing your API: grants and RLS for the Data API, default privileges, dedicated API schemas and pre-request checks.
  • 7 API keys: which key to use where, publishable and secret keys and the legacy anon and service_role keys, and handling secret keys safely.
  • 7 Shared Responsibility Model: what Supabase manages and what stays your job, such as access management, your data, security controls, schema design and third-party services.
  • 7 Managing Environments: local development with the CLI, migrations, and releasing them to staging and production projects with GitHub Actions. Read with Deploy database migrations.
  • 7 Advisors: the Security, Performance and Health Advisors, their checks, and how to run them from the dashboard, the CLI and the Management API.
  • 7 Database Backups: daily backups for each plan, physical and logical backups, restoring, and point-in-time recovery.
  • 7 Connect to your database: which connection method to use from where, the poolers' session and transaction modes, and client settings for serverless functions.
  • 7 Securing Edge Functions: the auth modes for calls from users, from other services, from anyone, and from external webhooks.
  • 6 Secure configuration of Supabase products: an index of the hardening guides for Auth, the database, Storage and Realtime.

Key rules

Row Level Security and grants

  • 10 SUPABASE-1 Enable Row Level Security on every table in an exposed schema, such as public, and grant the anon and authenticated roles only the operations your app needs. A table without RLS is readable and writable by any role with a grant on it, and policies don't remove grants. On existing projects, new tables in public get every privilege by default, so turn off "Automatically expose new tables" or revoke the default privileges. This applies SEC-1 and PG-15. (Row Level Security, Grants and policies, Securing your API: default privileges, Production security checklist: database)
  • 9 SUPABASE-2 Never create security definer functions in an exposed schema, set search_path = '' on every one, and create views with security_invoker = true or keep them out of exposed schemas. Both run with their owner's privileges and bypass RLS. A security definer function in an exposed schema can be called through the Data API, and new functions are executable by every role by default. (Row Level Security: use security definer functions, Views and RLS, Expose a view safely, Securing your API: default privileges)
  • 8 SUPABASE-3 Write a separate policy for each operation, name its role with to authenticated or to anon, compare owner columns with (select auth.uid()), add with check to insert and update policies, and base authorisation on app_metadata, never on user_metadata, which users can change themselves. (Row Level Security: write a policy for each operation, Specify roles in your policies, auth.jwt())
  • 7 SUPABASE-4 Test the policies of every table with pgTAP: a test file per table under supabase/tests that asserts which operations each role may and may not perform, run with supabase test db on every pull request. Until the tests pass, you don't know whether the policies do what you intended; test the denied cases as well as the allowed ones. (Row Level Security: secure a table with RLS, Policy tests, Testing overview: best practices)
  • 7 SUPABASE-5 Index every column that policies filter on, and wrap auth.uid() and auth.jwt() in a select so that Postgres evaluates them once per statement instead of once per row. This applies PG-5 to policies. (Row Level Security: add indexes, Call functions with select)
  • 7 SUPABASE-6 If you enable anonymous sign-ins, check the is_anonymous claim in restrictive policies on data that only permanent users may reach, and protect the sign-in endpoint with CAPTCHA. Anonymous users get the same authenticated role as permanent users, and bots can create them in bulk to fill your database. (Anonymous Sign-Ins: access control, Abuse prevention and rate limits)
  • 7 SUPABASE-7 Keep Storage buckets private unless every file in them may be public, control access with policies on storage.objects, for example per user folder, and give temporary access to private files with signed URLs. Anyone who has the URL of a file in a public bucket can download it. (Storage Buckets: access model, Storage Access Control)

Keys and Edge Functions

  • 9 SUPABASE-8 Put only the publishable key, or the legacy anon key, in clients, and keep secret keys and the service_role key in servers and Edge Functions, out of source control. Secret keys bypass RLS, so a leaked one exposes all of the project's data. Give each backend component its own secret key, so that one leak forces only one rotation, and move off the legacy JWT-based keys, which Supabase is deprecating by the end of 2026. This applies SEC-11 and SEC-2. (API keys: which key do you use?, Handling secret keys safely, Migrating to publishable and secret API keys)
  • 7 SUPABASE-9 Check every caller of an Edge Function: keep verify_jwt on for functions that users call, and query with the client that applies their RLS policies; use the admin client, which bypasses RLS, only for work that must cross policies, and verify the signature of external webhooks. Keep third-party credentials in Edge Function secrets, and the local supabase/functions/.env file out of Git. (Securing Edge Functions: authenticated user calls, External webhooks, Edge Functions, Environment variables)

Migrations and environments

Connections and operations

  • 8 SUPABASE-11 Plan backups for your recovery point objective: Supabase backs up only paid-plan projects daily, so on the Free plan export the database regularly with supabase db dump --remote (CLI 3 dumps the local stack without --remote) and keep the copies off-site, and on paid plans enable point-in-time recovery when losing up to a day of data is too much. Database backups don't include the files in Storage, and deleting a project also deletes its backups. This is how Supabase projects follow DATA-8. (Database Backups, Point-in-Time recovery, Production Checklist: availability, Migrating to Supabase CLI v3)
  • 7 SUPABASE-12 Connect each runtime the way Supabase recommends: clients through the Data API, serverless and edge functions through the shared pooler in transaction mode, with prepared statements off and a pool of one connection per instance, and migrations, pg_dump and long-running backends through a direct connection or the pooler's session mode. This is how Supabase projects follow PG-9 and HOST-5. (Connect to your database: which connection method do you use?, Configure your client)
  • 7 SUPABASE-13 Turn on SSL enforcement and network restrictions for the database. Postgres and its poolers accept connections without SSL until you enforce it, and network restrictions limit which IP ranges can connect at all; the HTTP APIs always use TLS. This is how Supabase projects follow SEC-13, PG-14 and SEC-20. (Production security checklist: database, Postgres SSL Enforcement, Network Restrictions)
  • 6 SUPABASE-14 Leave the Spend Cap on, or watch the organization's usage page when it's off, so that an attack or a bug can't run up unlimited charges. With the cap on, usage beyond the plan's quota is blocked for items such as egress, Edge Function invocations, monthly active users and storage; compute, point-in-time recovery and other add-ons you opted into aren't covered. This is how Supabase projects follow OPS-17. (Control your costs: Spend Cap)

Auth settings

How to enforce

Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.

  • 7 Supabase Advisors: deterministic checks, based on the splinter lints, that run in the dashboard, or in CI with supabase db advisors --fail-on error against the local database. rls_disabled_in_public flags exposed tables without RLS, rls_references_user_metadata policies that read user_metadata, security_definer_view, function_search_path_mutable and anon_security_definer_function_executable views and functions that bypass RLS, auth_rls_initplan policies that call auth functions once per row, auth_allow_anonymous_sign_ins enabled anonymous sign-ins, and public_bucket_allows_listing public buckets whose files can be listed. Checks SUPABASE-2, and partly SUPABASE-1, SUPABASE-3, SUPABASE-5, SUPABASE-6 and SUPABASE-7.
  • 6 supabase test db: runs the pgTAP tests in supabase/tests against the local database, for example in a GitHub Actions workflow on every pull request. Checks SUPABASE-4, and partly SUPABASE-1, SUPABASE-3, SUPABASE-6 and SUPABASE-7, as far as the tests cover them.
  • 6 GitHub secret scanning push protection: blocks pushes that contain Supabase secret keys. Partly checks SUPABASE-8.

Tutorials and further reading

  • 6 Build a User Management App with React (Supabase): sign-up and sign-in, a profiles table protected by Row Level Security, and avatar uploads to Storage; the same tutorial exists for other frameworks.
  • 6 Advanced pgTAP Testing (Supabase): test helpers from database.dev for creating users, switching roles and checking RLS across a schema, with a multi-tenant example.
  • 6 Row Level Security performance (Supabase): measuring the cost of policies and tuning policies that are already correct.