Skip to content
NASHSOFTWARE SERVICES
Writing

Published For buyers

Can Your Users See Each Other's Data? Checking Row Level Security in Supabase

If your app runs on Supabase, row level security decides who can read which rows. How to check it in the dashboard and with two test accounts, step by step.

Mike Nash · Fractional CTO and independent code reviewer

If your app keeps its data in Supabase, whether one user can see another's data comes down to row level security (RLS). With RLS switched on and sensible rules on every table, the public key in your app can only reach the rows the signed-in person should see. With RLS off on a table, anyone who has your project address and that public key can read it, and both of those sit in the browser by design.

You can check most of this yourself in an hour. Only test an app you own or are authorised to test, and use made-up data throughout.

For the wider picture, how to tell if an AI-built app is safe to launch covers the other questions.

Why the public key isn't the problem

Supabase gives your app a publishable key (older projects call it the anon key), and it's meant to be in the browser. Supabase's docs say it's safe to expose, because once RLS is on, that key gets nothing until you write a policy allowing it. What matters is what those policies allow.

Step 1: run the Security Advisor

In the Supabase dashboard, open your project and go to Advisors, then Security Advisor. It lists problems it can spot in your database settings. The ones that matter here:

  • "RLS disabled in public" means a table your app can reach has RLS off. Supabase marks it as an error, because anyone with the project URL can get at that table. Fix these first.
  • "Policy exists RLS disabled" means someone wrote a rule but never switched RLS on, so the rule does nothing.
  • A permissive policy warning means a rule is always true, such as using (true). RLS is on, and everyone gets in anyway.
  • A security definer view runs with its creator's rights and skips the RLS on the tables underneath it.
  • A warning about user metadata means a rule trusts user_metadata, which users can edit themselves

The advisor can't tell whether a rule matches what your app is meant to do, so carry on to step 2.

Step 2: read the rules on each table

Open the policies for each table that holds anything belonging to a user: profiles, orders, messages, uploads, notes. For each one, ask four questions, because Postgres treats reading, adding, changing and deleting as separate operations:

  1. Who can read rows? A typical rule for "my own rows" compares the signed-in user's ID with a column on the row, something like (select auth.uid()) = user_id.
  2. Who can add rows? The insert rule needs a with check condition, or a user could create a row with someone else's user_id on it.
  3. Who can change rows? The using part decides which rows someone can target, and with check decides what the row may look like afterwards. If only using is there, Postgres applies it to both.
  4. Who can delete rows? This one gets forgotten, so check it says what you expect.

Two patterns to look out for. A rule with or auth.uid() is null in it lets anyone who isn't signed in see every row, because signed-out requests have no user ID. And a single for all rule makes it hard to tell which operation it's meant to cover.

If you have views, check each one. On Postgres 15 and later, a view created with (security_invoker = true) follows the RLS on its tables. Without that, it doesn't.

Step 3: check file storage

Files uploaded through Supabase Storage have their own rules, on a table called storage.objects. Uploads are blocked until there's a policy allowing them. Downloads from a bucket marked public skip the rules entirely: anyone with the link gets the file. That's fine for product images. It's wrong for invoices, ID documents or anything personal.

For each public bucket, ask whether you'd be happy for a stranger to download every file in it.

Step 4: test it with two accounts

Reading rules only goes so far, so test what the app actually does. Do it through the app itself: the SQL editor in the dashboard runs as an administrator role that skips RLS, so it shows you everything.

  1. Create two accounts with made-up names and email addresses you control. Call them A and B.
  2. Sign in as A. Create one of everything: a record, an upload, a message.
  3. Note the web address of each thing you made. Many apps put an ID in the address.
  4. Sign out and sign in as B in a private browser window.
  5. Paste in each of A's addresses. Try to view it, edit it and delete it.
  6. Sign out completely and try the same addresses again.

If B, or a signed-out visitor, can see or change any of A's things, that's a fix before launch.

One more look while you're signed in as B. Open your browser's developer tools (F12 in most browsers), go to the Network tab and reload a page that lists records. Click the requests going to your Supabase address and look at what came back. If the response holds rows that belong to A, and the page simply isn't showing them, the hiding is happening in the browser, where anyone can undo it.

When the answers aren't clear

If the advisor is clean, the rules read sensibly and the two-account test holds, you've done the check I'd start with on any Supabase app. It doesn't prove the app is secure. Server code that uses the secret key bypasses RLS completely, so anything running with that key needs checking separately, and that's covered in whether your API keys are visible in the browser.

If you couldn't tell what a rule does, or the test turned something up and you're not sure how far it goes, that's where a second pair of eyes helps. The Launch Check I run on the code audit for AI-built software page includes who can read and change which records and the same two-account test on made-up data. It reads the code and configuration. It isn't a penetration test, and it doesn't attack your live system.

Official documentation

Share