Check and fix Supabase RLS, step by step

The whole check on a test project: copy the catalog query, read who can reach each table, apply the fixes, generate policies, test as each user and check again.

·

The player loads from YouTube (youtube-nocookie.com) when you press play.

Transcript

0:00 Is your app open?

In one study, over seven thousand Lovable sites let anyone read email records, no login needed. Some may be test data or public contacts, so it’s not a confirmed rate. Built on Supabase with Lovable or Bolt? Let’s check yours, then fix it without breaking your app.

0:17 Why tables end up open

Your app uses a publishable key, or the older anon key. Every visitor gets it, by design. Row-level security, or RLS, decides which rows each request gets, through rules called policies. Tables made in Supabase’s dashboard get RLS on. Tables made with SQL need you to switch it on.

Lovable’s scan can flag this, even suggest a fix. Checking the rules is still on you.

0:44 Step 1: Get your schema

Open the tool. Pick Check my project. No migration files? That’s fine. Click Copy the query. It reads settings, like policies, grants and Storage buckets, and never the rows in your tables.

In Supabase, open the SQL Editor. Paste, and run. You get one row with one value. Copy all of it. Paste it into Your schema. It checks at once, and what you paste stays in your browser.

1:11 Step 2: Read the board

Headline: one table is open to anyone. The board shows who can reach each table. Out is signed out: anyone with your public key. In is signed in.

Red All rows: every row. Yellow Own rows: only their own. A dash: no access. Profiles has RLS off: anyone can read, add, change and delete every row. Notes has RLS on, with three policies. Yet anyone can read every note, and any signed-in user can change any note.

1:40 Step 3: Findings and fixes

Click a row. You’ll see only its findings. Each one explains the problem. Most come with fix SQL. The warning: the update rule only checks that someone is signed in. Its fix ties each note to its owner.

The note: every note is public. That’s fine for public content. Read each fix, and run it on a test project first.

2:01 Step 4: Generate policies

To set every rule at once, use Generate policies. It doesn’t read your project. You set it up to match your tables. Start from Personal app. Rename the tables and owner columns to match yours.

Click a cell to cycle: no access, Yes for every row, Own for their own. The card shows you the policy it writes, in words and SQL. Should signed-out visitors see something? Set Anyone to Yes.

This SQL removes the old policies on these tables, even the one that let anyone read everything, and grants only what the plan needs.

2:36 Step 5: Run, test, check again

Copy the SQL. Run it in the SQL Editor, on a test project first. Then open Test as each user. Paste in a real user ID, and run one block at a time. Each rolls back. Signed in as Maya, you get only Maya’s profile and note, not Leo’s or Ana’s.

Run the check query again, and paste the new value. Nothing serious found. Signed out, you see nothing. Signed in, you see only your own rows.

3:10 What this check can’t see

One limit: it reads settings, not your app’s code. So it can’t spot a secret key, or the old service role key, in your app. That key skips every rule. Keep it on the server. It’s free, with no sign-up: nestedbit.com, Free tools, Supabase RLS Generator.

Sources

Where the facts in this video come from. Everything shown on screen is a test project with made-up data.

Check your own project for free.

Generate row-level security policies and check a schema for tables left open.

Open the Supabase RLS Generator

More videos

  • Is My App Open? · Part 1 One key, every row Why the key in your app’s page can read every row of a Supabase table when row-level security is off.
  • Is My App Open? · Part 2 Check yours in 4 steps Check every table in your Supabase project with the free tool. It reads settings, never your rows.
  • Is My App Open? · Part 3 Fix it without breaking your app Turn row-level security on with the right rules in place, so your app’s lists don’t come back empty.