Need to test RLS together with Auth, Storage and real user journeys? WZ-IT provides managed Supabase, migration and security reviews for production applications.
To audit Supabase RLS, two layers need to be read together: PostgreSQL privileges determine whether a role may perform an operation at all. Row Level Security then determines which rows the operation may affect.
Defects commonly appear not within one policy, but at the boundaries between grants, roles, Auth claims, views, functions, Storage and server-side keys. Status: 22 November 2026. The article Is Supabase secure? gives the overview of responsibility, keys, default changes and a self-test without signing in.
What RLS protects in Supabase
Supabase exposes tables and views of exposed schemas through the generated Data API, as far as the roles anon, authenticated or service_role have privileges on them (Securing your API). For exposed tables, RLS controls which rows these roles can access. Common rules include:
- users may read only their own profile
- tenants see only their own records
- roles may change selected status values
- anonymous users see published content only
- users may access files only in their own path
RLS does not replace authentication. Auth provides identity and claims; RLS consumes those inputs in database policies.
1. Inventory the data and attack surface
An audit starts with every reachable data path, not the first policy:
| Data path | Questions |
|---|---|
| Tables | Which schemas are exposed through APIs? Is RLS enabled? |
| Views | With the rights of which role does the view run: owner or caller (security_invoker)? |
| RPCs | Which functions are callable and with which rights? |
| Storage | Which buckets, paths and policies exist? |
| Realtime | Which tables and events are published? |
| Edge Functions | Which keys and user tokens do they use? |
| Backend | Where is service_role or a database role used? |
A table not referenced directly by the frontend can still be reachable through generic APIs when schemas, grants and roles allow it.
The publishable key no longer retrieves the table list of the OpenAPI overview (GET /rest/v1/): according to the API keys documentation, this address accepts only secret keys, and a publishable key gets HTTP 401 there. Table routes such as /rest/v1/<table> are not affected: a table that is reachable through schema and grants remains reachable without this overview. An inventory comes instead from the database system catalogs or the dashboard. A SQL query for it is in the self-test of the article "Is Supabase secure?", and dates and sources for the OpenAPI change are in the section Default changes 2026.
2. Separate roles and keys
Common roles and contexts include:
- anon for unauthenticated client requests
- authenticated for signed-in users, including anonymous sign-ins (claim
is_anonymous, Row Level Security) - service_role for controlled server-side administration
- database roles for internal processes or direct connections
The public key (publishable key; it replaces the legacy anon key, and both are currently valid in parallel) is not a secret: it identifies the application, not the user (API keys). Data access arises from the project URL and the publishable key together with schema exposure and grants, and RLS decides which rows are visible. Its safety therefore depends on the associated role having limited privileges and RLS applying. The secret key (or the legacy service_role key), by contrast, is highly privileged: it uses the service_role role with the BYPASSRLS attribute and bypasses RLS as long as the request carries no user token; if it carries one, that user's policies apply (Row Level Security). Object, column and schema privileges apply to it as well, and a missing grant returns a permission error. According to Supabase, it never belongs in a browser, a shipped app, source code or version control.
Supabase is replacing the JWT-based legacy anon and service_role keys with publishable keys (sb_publishable_...) and secret keys (sb_secret_...). The deprecation of the legacy keys is announced, not completed: the API keys documentation says "by the end of 2026", and the timetable of the Supabase discussion says "Late 2026, TBC", that is, a date that is not yet confirmed (date of the "Latest Update" section: 17 June 2025). A publishable key uses the anon role, or authenticated after sign-in; a secret key uses service_role. Supabase rejects secret keys in the browser by matching the User-Agent header and returning HTTP 401, but according to Supabase an attacker can still use them with other tools. Creating new keys does not disable the old ones; according to the documentation the legacy keys stay valid until they are disabled in the dashboard. The audit therefore includes switching off the legacy keys after the migration and cleaning up occurrences in code, CI and integrations.
3. Read RLS state and grants together
For each exposed table, check:
- Is RLS enabled?
- Is forced RLS needed for relevant owner access?
- Which rights do anon and authenticated receive?
- Are legacy or broad grants present?
- Which privileges do new objects receive automatically (default privileges of the project)?
- Does every required operation have an intentional policy?
- Do administrative processes use a bypass role?
Policies do not take automatically assigned grants back (Row Level Security): broad grants remain even when the policy for one operation is well written. Conversely, a request fails with error 42501 despite a matching policy when the table privilege is missing, because Postgres checks grants before RLS (API keys). A policy that matches no rows returns an empty result without an error. A violated WITH CHECK condition on INSERT or UPDATE also reports 42501 ("new row violates row-level security policy"): the error code alone does not distinguish the two cases, the error message names the reason.
Default privileges of new objects. Which privileges new objects receive differs between projects, depending on when the project was created and its Data API settings (Securing your API). According to the documentation, in existing projects new objects in the public schema receive privileges for anon, authenticated and service_role, for tables including select, insert, update and delete, for functions execute. New tables are then reachable through the Data API even when that is not intended. The setting "Automatically expose new tables" in the Data API settings of the dashboard revokes these automatic privileges for future tables, and the query "Check your default privileges" in the documentation shows what new objects receive in your own project.
Supabase announces that automatic exposure is to become the exception: according to the changelog of 28 April 2026 the behaviour can be selected at project creation, is to become the default for new projects from 30 May 2026 and is planned for existing projects from 30 October 2026. On 22 November 2026 the "Securing your API" documentation still says "Supabase is changing the platform default" and still describes the automatic privileges for existing projects. A rollout to all projects is therefore not documented, and what matters is the state of your own project. The change affects only new objects: existing tables keep their privileges and stay reachable through the Data API, so the switch does not close an old table. The sources are laid out in the section Default changes 2026 of the article "Is Supabase secure?".
RLS on new tables. Tables created in the dashboard have RLS enabled by default. For tables from the SQL Editor, from migrations or from other tools, RLS must be enabled explicitly (Securing your API). Alternatively, an event trigger enables RLS on newly created tables automatically: the documented example function covers new tables in the public schema (Event Triggers), and according to the Security Retro 2025 (7 January 2026) there is a one-click setup in the dashboard. The trigger applies only to tables created after it is installed; existing tables must be checked manually.
4. Use USING and WITH CHECK correctly
Policies distinguish existing and new row states:
- USING filters rows that SELECT, UPDATE or DELETE may see or affect.
- WITH CHECK validates new values for INSERT and UPDATE.
A common UPDATE flaw permits reading an owned row but does not prevent changing its tenant identifier. Write operations need both current access and the proposed state to be evaluated. If an UPDATE policy has no WITH CHECK, the USING expression also applies to the new row state (Row Level Security). The tenant identifier is then protected only if it is part of that condition.
5. Auth claims and null cases
Supabase documentation points out that the Auth user identifier is null for unauthenticated requests. Policies should express the intended authentication state explicitly.
Review:
- behaviour without a login
- expired or invalid tokens
- anonymous sign-ins (role
authenticated, claimis_anonymous) - email and role claims
- stale claims after role changes
- user metadata the user may change
- tenant switching or multiple memberships
Security decisions must not rely on freely editable client data.
6. Test tenant isolation as a business rule
One test account cannot verify a multi-tenant system. A minimal matrix uses:
- user A in tenant A
- user B in tenant A with another role
- user C in tenant B
- anonymous access
- a server-side process
Test:
| Operation | Positive test | Negative test |
|---|---|---|
| SELECT | own row visible | other tenant row invisible |
| INSERT | own tenant accepted | manipulated tenant ID rejected |
| UPDATE | allowed fields change | owner or role escalation blocked |
| DELETE | authorised role deletes | regular user and other tenant fail |
Negative cases reveal more than a generic “the API works” check.
For repetition, the documentation describes pgTAP tests with supabase test db, which switch the role with set local role anon and set local role authenticated (Row Level Security). The RLS Tester in the dashboard runs SELECT queries as any role, including a user who is not signed in, and shows which policies apply. It was announced as a feature preview on 24 April 2026 and, according to the announcement, supports only SELECT for now (announcement). It therefore does not cover write operations; pgTAP tests and the matrix above remain for those. The check without signing in is described by the self-test in "Is Supabase secure?"; it does not cover access between signed-in accounts and tenants.
7. Control views and functions
Views and database functions may run with rights different from the caller. Review:
- ownership and execution mode
- search path and schema resolution
- executable roles
- dynamic SQL
- input validation
- access to RLS-protected tables
- unintended aggregation of data
Views. By default, a view runs with the rights and the RLS rules of its owner, not of the caller (CREATE VIEW). RLS is bypassed when the owner is a superuser, has the BYPASSRLS attribute or owns the table without FORCE ROW LEVEL SECURITY (Row Security Policies). According to Supabase, views are mostly created with the user postgres (Row Level Security). With security_invoker = true (Postgres 15 and higher) the rights and RLS of the caller apply, and the caller then also needs privileges on the base tables. The Security Advisor reports such views in the schemas reachable through the API as lint 0010 ("Security Definer View").
Functions. A SECURITY DEFINER function runs with the rights of its owner (CREATE FUNCTION). Whether it bypasses RLS depends on the owner: if the owner has BYPASSRLS or is a superuser (Supabase names postgres as an owner with bypassrls), or owns the table without FORCE ROW LEVEL SECURITY, the function bypasses RLS. RLS does not act on the call itself; the EXECUTE privilege controls it (Securing your API), and new functions receive it by default through PUBLIC. If the function is in a schema exposed through the Data API, it can be called via POST /rest/v1/rpc/<name> (Advisors, lint 0028). The details and a query for this are in the section Supabase RLS: two layers and typical findings of the article "Is Supabase secure?".
Security-definer functions are not inherently wrong. They need a narrow purpose, fixed search path, minimum privileges and targeted tests.
8. Include Storage policies
Supabase Storage uses tables and RLS policies for object access. Audit:
- public and private buckets
- path structure and ownership logic
- upload, read, update and delete independently
- content-type and size restrictions
- signed URLs
- server-side uploads
- orphaned metadata or objects
Secure application tables do not automatically make files secure.
9. Edge Functions and backends
Server-side components can pass a user token, and then that user's policies apply. If they use a secret key (service_role) without a user token, the request bypasses RLS and the component owns authorisation itself; table and schema privileges still apply.
Ask:
- Is service_role genuinely required?
- Is user identity verified before an administrative action?
- Can the client manipulate object or tenant IDs?
- Are secrets logged?
- Are webhooks authenticated and safe to retry?
10. Repeatable RLS review gates
A one-time audit loses value with every schema change. Put RLS tests into migrations and releases:
- do not expose new tables automatically: check the default privileges of the project and revoke them where needed (setting "Automatically expose new tables")
- grant privileges explicitly per table and role
- enable RLS explicitly, including for tables from migrations (optionally with an event trigger), and version policies
- automate role and tenant tests, for example with pgTAP and
supabase test db - run negative cases on every change
- inventory service_role use
- record findings with severity and owner
This gate sets grants and RLS explicitly and applies regardless of whether the switch of the platform defaults has already taken effect for your own project (see section 3).
Status and methodology
Status: 22 November 2026. The quoted Supabase pages (API keys, Securing your API, Row Level Security, Event Triggers, Storage Access Control, Advisors), the changelog entry of 28 April 2026, the blog post of 7 January 2026 and the PostgreSQL pages were retrieved on that date and the quoted passages compared with their wording. Dates in the documentation and in changelog entries are announcements by Supabase. Whether and when a change applies to an individual project, we have not determined. For the date 30 October 2026 two statements exist: the changelog names it for all existing projects, and on 22 November 2026 the documentation still describes the switch as ongoing ("is changing"). We do not use comments by third parties in the Supabase GitHub discussions as evidence.
We ran the described Postgres behaviours in a test database with PostgreSQL 16, with re-created roles anon, authenticated and service_role (with BYPASSRLS), owner roles with and without privileges and a re-creation of auth.uid(): default-deny with RLS enabled and no policy, table owners with and without FORCE ROW LEVEL SECURITY, a role with BYPASSRLS without a table or schema privilege, error 42501 for a missing privilege and for a violated WITH CHECK condition, UPDATE without WITH CHECK, views with different owners and with security_invoker, and SECURITY DEFINER and SECURITY INVOKER functions with EXECUTE through PUBLIC. The test script is not part of this article. The test database does not re-create a Supabase project. Checked only against the documentation and not run are the behaviour of secret keys with and without a user token, the default privileges of a Supabase project, the setting "Automatically expose new tables", the event trigger in the dashboard, the RLS Tester, the HTTP 401 block in the browser, and Storage, Realtime and Edge Functions. The Supabase documentation changes frequently; check names and menu paths against the current state before implementing.
The Supabase documentation is not consistent on the secret key (as of 22 November 2026): the API keys page states that policies never apply to a secret key, while the Row Level Security page describes that with an additional user token that user's policies apply. We have not tested this against a Supabase project. Our recommendation: treat the secret key as if it bypassed RLS in every case.
Sources
- Supabase: Row Level Security
- Supabase: Auth and RLS
- Supabase: Storage access control
- Supabase: API keys
- Supabase: Securing your API
- Supabase: Event Triggers
- Supabase: Advisors
- Supabase blog: Supabase Security Retro: 2025, 7 January 2026
- Supabase changelog: Breaking Change: Tables not exposed to Data and GraphQL API automatically, 28 April 2026
- Supabase on GitHub: Upcoming changes to Supabase API Keys
- Supabase on GitHub: Feature Preview RLS Tester, 24 April 2026
- PostgreSQL: row security policies
- PostgreSQL: CREATE VIEW
- PostgreSQL: CREATE FUNCTION











