Senior software engineering · Vancouver, BC · Making software since 1994[email protected] · US and Canadian business hours

Insights

Is My Supabase Data Exposed? A Plain RLS Check

Many apps built with AI tools keep their data in Supabase. Whether strangers can read it comes down to one feature, Row Level Security, and a few settings you can check yourself.

Why this matters for apps built with AI

Lovable, Bolt, v0 and similar tools often connect your app to Supabase, a hosted Postgres database. The app in the browser talks to the database directly, using a key that ships with the app. That is by design. What keeps one visitor out of another visitor's data is not the key. It is Row Level Security, or RLS: rules on each table that say who can read and change which rows.

The two keys

Supabase gives a project two kinds of key, and the difference is the whole story.

  • The publishable key (older projects call it the anon key) is meant to be public. Supabase's documentation says it is safe to put in a web page or an app, because "it only reaches what Row Level Security allows". If RLS is off, that is everything in the table.
  • The secret key (older projects call it service_role) skips every rule. Supabase's documentation says it "bypasses every Row Level Security policy you have" and should never be put in a browser, a shipped app or source control.

So the first check: search your app's code for the secret key. If it is anywhere in what runs in the browser, treat the data as already readable, change the key in Supabase, and move it to a server function.

Check 1: is RLS on for every table?

Open your project in Supabase and look at the Security Advisor. It runs checks on your database and lists problems by level. Two matter most here:

  • RLS disabled in public (an error). Supabase's description: anyone with your project URL "can read, edit, and delete all data in this table".
  • Policy exists, RLS disabled (info). You wrote rules, but they do nothing until RLS is switched on for that table.

If either appears, the table needs alter table <table> enable row level security; before anything else. Once RLS is on with no rules, the publishable key reaches nothing in that table, so expect parts of the app to stop working until the rules are written. That is the right direction to break in.

Check 2: do the rules say what you think?

RLS being on is not the same as the rules being right. The common mistakes in AI-generated rules are plain to read once you know them:

  • A rule that is always true. A policy whose condition is true lets every visitor through. It often appears when a tool "fixes" an error by loosening the rule.
  • Read rules without write rules, or the reverse. A table can be private to read but open to insert, update or delete.
  • Rules that trust what the browser sends. A rule that checks a user id sent from the app, rather than the signed-in user from auth.uid(), can be bypassed by anyone who edits the request.
  • Views and functions that skip the rules. Some database functions and views run with more rights than the visitor. Check what each one returns.

Check 3: test it like a stranger

The only proof is a test. Supabase's documentation puts it bluntly: until a test suite of your policies passes, "you don't know whether the policies do what you intended". It describes database tests created with supabase test new and run with supabase test db.

A quick manual version, for a start: create two test accounts, sign in as the first, and try to read the second account's rows through the app. Then sign out and try again with only the publishable key. If either returns data it should not, you have found the problem before someone else did.

When to ask for help

If the advisor shows errors you do not understand, if fixing the rules breaks the app and the AI keeps loosening them again, or if real users' data was readable for any length of time, that is a job for an engineer. The rules need writing once, properly, with tests that run on every change.

Questions

Is it a problem that my publishable key is visible in the browser?

No, as long as RLS is on and the rules are right. The publishable key is designed to be public. The secret key is the one that must never be there.

My app works. Does that mean the rules are fine?

No. An app can work perfectly and still let anyone read every row. Working and private are tested separately.

Can my AI tool fix the rules?

Sometimes, and it is worth asking. Check the result with the advisor and a two-account test, because the tool can also loosen a rule to make an error go away.

Not sure what you are looking at? Get a free first look from a senior engineer. Send the link, never your keys.

Sources: Supabase documentation, opened November 17, 2026: Row Level Security, API keys, Database Advisors.

Want a second pair of eyes on your rules?

Send the link and the tool you built with. A senior engineer replies within one business day. No passwords or keys.

Get a free first look

Reply within one business day · Never send keys