Why Supabase projects need permission tests
Supabase makes it easy to put a database directly behind your front end. The browser talks to the database through an API using a publishable key, and row-level security policies in Postgres decide which rows each signed-in user can see. When the policies are right, that is a clean, efficient design. When they are wrong, the database is one modified request away from showing every customer’s data to anyone with an account.
The trouble is that policies are easy to get subtly wrong, and AI app builders write a lot of them quickly. A policy that checks the user is signed in but not that they own the row reads plausibly in review. So does a view that was created for convenience and quietly ignores the policies on the table beneath it. Reading policies is not enough; you need tests that act as real users.
What the work involves
I start from your intended access rules, written in plain language, and turn them into tests before looking closely at the policies. The tests sign in as different users and roles and try to read, insert, update and delete each other’s data through the same API your app uses. Then I review the parts that commonly bypass or weaken row-level security, checked against Supabase’s current documentation:
- Keys. Secret (service role) keys bypass row-level security and must never reach the browser. I trace where each key is used.
- Views. Views created by the default database owner bypass the policies of their underlying tables unless they are set to run with the caller’s rights or kept out of exposed schemas.
- Database functions. Functions marked to run with elevated privileges can read across policies; each one needs a reason and its own checks.
- Storage. Bucket policies are separate from table policies and are often left open.
- Performance. Policies filter every query, so the columns they reference need indexes, and per-row function calls in policies can be restructured.
- Environments and migrations. Separate development and production projects, schema changes in versioned migrations, and a way to roll back.
The same approach is written up in my practical guide to hardening Supabase row-level security.
The signature deliverable
You receive scoped database, authorisation and production remediation: the permission test suite, the fixes, and a short runbook. Illustrative example of permission test results:
| Table or bucket | Rule | Test | Before | After |
|---|---|---|---|---|
documents | Owner and shared users only | User C reads A’s document by ID | Allowed | Denied |
team_members | Admins manage, members read | Member promotes self to admin | Allowed | Denied |
invoices_summary (view) | Owner only | User B lists all rows | All rows returned | Own rows only |
avatars bucket | Public read, owner write | User B overwrites A’s avatar | Allowed | Denied |
Illustrative example. Not taken from a client engagement.
How acceptance is judged
The permission suite is the acceptance test: every rule you agreed must pass, as every role, in CI. Performance work is accepted on before-and-after timings for the specific queries we agreed to fix, measured on a copy of your data. Environment and migration changes are accepted when your developer can deploy a schema change to staging and production using the documented process.
Ownership and handover
The tests, migrations and policy changes live in your repository. The runbook explains how to add a new table without reopening the same gaps: enable row-level security, write the policy, add tests for each role, then merge. Your named developer runs through that procedure once before handover.
I am an independent practitioner; not affiliated with, endorsed by or holding any certification from Supabase.
When to choose something else
If you need a launch review of the whole AI-built application, see take an AI-generated application into production. If the project is stuck and salvage is the question, see rescue an AI application that cannot ship.