Supabase Row Level Security, Explained for Founders

Arrie Burger--8 min read

Open your app in a browser, open the developer tools, and you'll find your database address and a key sitting in plain sight. That isn't a leak. Supabase built it that way. Supabase row level security (RLS) is the set of rules inside your database that decides what that public key can read and change, row by row. If the rules are missing or wrong, anyone holding the key gets what the rules allow.

That matters most in apps made with Lovable, Bolt or a similar AI app tool, where Supabase is often the whole back end. The rules usually go wrong in one of five ways, and you can check your own project before lunch.

Everything below about Supabase comes from Supabase's docs, last checked on 15 October 2026. Supabase updates its docs and dashboard regularly, so check again before relying on a menu name.

What is Supabase row level security?

Think of a block of flats. The street door is unlocked, because every resident and every visitor has to get in. What stops a visitor walking into flat 4 is the lock on flat 4.

In a Supabase app, the street door is the publishable key (older projects call it the anon key). Supabase's API key docs say it is "safe to expose online", and that "Row Level Security decides what this client can reach, so enable it on every table before you deploy." Its guide to securing data puts the condition plainly: the key "is safe to expose with RLS enabled".

Each table gets a switch (RLS on or off) and a set of policies. A policy is one rule in plain database terms: who it applies to, which action (read, add, change, delete) and which rows. A good one reads almost like a sentence:

create policy "Users can view their own todos."
on todos for select
to authenticated
using ( (select auth.uid()) = user_id );

Translated: signed-in users may read a todo only when its owner is the person asking. auth.uid() is the signed-in user's id, taken from their login token, not from anything the browser chose to send.

Why does the public key make RLS the only lock?

Because in most apps made with these tools, the browser talks to the database directly. That includes Lovable apps and Bolt projects that use Supabase. There's no server in the middle checking anything. The page asks Supabase for rows, Supabase checks the policies, and that's the end of the inspection.

Supabase's Security Advisor describes an unprotected table this way: "anyone with the project's URL can CREATE/READ/UPDATE/DELETE (CRUD) rows in the impacted table". Lovable's Supabase docs are just as direct: "Missing RLS policies are the most common way app data gets exposed." Bolt's database docs describe a Security Audit that looks for "an open permission or a missing RLS policy". Three companies, one failure. Take the hint.

The public incidents are in whether a Lovable app is secure. What follows is the mechanism, so you can spot the problem in your own project instead of reading about someone else's.

Which RLS policies are broken? Five common examples

A policy can exist and still protect nothing. The usual mistakes come in five shapes.

1. RLS is off. The table has no lock at all. Supabase's advisor lists this as "Table publicly accessible". Switching RLS on without any policy is safe but breaks the app, because Postgres then assumes a "default deny" and returns nothing. That broken screen is often the moment someone asks the AI to "make it work", which leads straight to mistake two.

2. A policy that says yes to everyone. It looks like this:

create policy "Allow all" on invoices
for select using ( true );

true means every row, for every visitor. Fine for a public price list. Not for invoices. Supabase's lint for this says always-true policies "effectively bypass the security that RLS is meant to provide". In apps made with AI tools they are usually placeholders nobody came back to.

3. Careful on reading, careless on writing. The read policy checks the owner. Then an insert or update policy gets added later with with check ( true ) so a form can save. Now anyone the policy covers can write rows, including rows that claim to belong to someone else. Worse, the Postgres docs say policies are "permissive by default" and combined with "OR". One loose policy on a table beats every strict one beside it.

4. Trusting what the browser sends. An app that filters rows by a user id the page itself sends, with no policy behind it, trusts the visitor to say who they are. So does a policy that checks a "role" stored in the user's profile metadata. Supabase warns that user_metadata "can be modified by authenticated end users". If your admin check reads role = admin from there, any user can make themselves an admin. Base the rule on auth.uid() and on tables only your server can write.

5. The secret key in the browser. Supabase's secret key (older projects call it the service_role key) uses a role that has "the bypassrls attribute". Every policy above stops applying. Supabase's rule is "Never use a secret key in the browser or expose it to customers." It belongs in edge functions and server code only.

RLS policy examples: what breaks and what holds

Broken

  • RLS switched off on a table
  • using (true) on reads
  • with check (true) on inserts and updates
  • A role read from user metadata
  • The secret key in front-end code

Holds

  • RLS on for every table the app can reach
  • Rows matched to auth.uid()
  • Writes checked against the same owner
  • Roles kept in a table users cannot edit
  • The secret key only in server code

How to check RLS in your own Supabase project today

Four checks, in this order. The first two need no SQL at all.

Run the Security Advisor. Supabase's production checklist opens with it and links straight to it in the dashboard. It flags tables with RLS off, always-true policies, policies that rely on user-editable data and views that skip RLS. Fix each finding, or write down why you accepted it.

Look at the table list. The same checklist says to confirm RLS is on for every table from Database, then Tables. Include the tables you don't remember creating. The AI made some of them for you.

Ask the database directly. Open the SQL Editor and run these. Both only read, so they change nothing.

-- Tables in the public schema with RLS switched off
select tablename from pg_tables
where schemaname = 'public' and rowsecurity = false;
 
-- Every policy, what it covers and the rule it applies
select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public';

The first should return nothing. In the second, cmd is the action, qual is the rule for which rows are visible and with_check is the rule for what can be written. Any row where either says true is a door propped open. A table with a read policy and a loose write policy is mistake three.

If your app runs on Lovable Cloud rather than your own Supabase account, Lovable's database docs give you an RLS policies view and an SQL editor for the same job.

Prove it with two accounts. Sign up twice and try to read, change and delete the second account's records as the first. The Lovable production checklist walks through that test and the other launch checks, including where secrets should live.

How to check RLS before real users arrive

1

Security Advisor

Read every finding Supabase flags

2

Table list

RLS on for every table, including forgotten ones

3

Two SQL queries

No table with RLS off, no rule that just says true

4

Two accounts

One user tries to read and edit the other

The hard part isn't the SQL

Writing a policy takes five lines. Deciding what it should say is the real work, and an AI tool can't do it for you, because the answer lives in your business.

Should a coach see every client, or only their own? Can a tenant read the landlord's notes on their flat? Nobody types those questions into a prompt, so nobody gets them answered. The AI writes a policy that makes the screen load, and the screen loading feels like proof.

A policy that makes the screen load is not the same as a policy that keeps the right people out.

So write the rules down as sentences first. One sentence per table, per action. Then check that each policy says what its sentence says. If you can't write the sentence, the policy is a guess.

If you'd rather someone else read them, the free Exposure Check on our AI-built apps page looks at your live app from outside only and sends a short video of what turned up. The Quick Check reads the repo and the live app and gives you your top five risks in writing, typically within 48 hours, depending on complexity. The Lovable page and the Bolt page cover what we usually find in each.

Supabase gave every visitor a key to the street door on purpose. Whether they get into flat 4 is up to you.

How we help with this

Want to discuss this topic?

If this resonates with where your company is right now, we'd like to hear from you.