Guide
How to check if Supabase RLS is on (Lovable, Bolt, Cursor apps)
Updated November 11, 2026
TL;DR
The anon key in your frontend is supposed to be there. The problem is a table with Row Level Security turned off, or a policy that allows every row: anyone with that public key can read it through the Supabase API. Check the Table Editor badges, the policy list, and the Security Advisor, then turn RLS on and limit rows with auth.uid() = user_id. HackOrBroke does not query your tables. The scan only notices Supabase and reminds you to check.
Why the anon key in the frontend is normal
Supabase apps built in Lovable, Bolt, Cursor, and similar tools talk to the database from the browser. To do that they ship two public values: the project URL (https://YOUR_PROJECT_REF.supabase.co) and the anon key. The anon key is a JWT whose role is anon. It is not a password.
That key is allowed to call the Data API. What it is allowed to see is decided by grants and by Row Level Security. If RLS is off, the key can do whatever the table grants allow. On a typical table created for these apps, that means reading, inserting, updating, and deleting rows. Anyone who copies the key out of your JavaScript — it is already in the file their browser downloaded — can send those requests themselves.
The key that must never appear in the frontend is service_role. That role bypasses RLS. If a scan or a search of the bundle finds it, rotate it in Project Settings → API and keep the new value on the server only. Related: Supabase service_role key in the frontend: what to do.
How to check in the Supabase dashboard
Open the project you own. Three places tell you whether the public tables are locked down.
- Table Editor. Look at each table for a badge that says RLS disabled or Unrestricted. RLS disabled means Row Level Security is off. Unrestricted means the table is exposed to the Data API without a restriction that would stop the anon key. Either badge means you should stop and read the policies before you share the URL. A table with no badge can still be wide open if a policy allows every row, so check the policy list too.
- Authentication → Policies. This is the list of policies by table. Open each one and read the expression, not just the name. If that menu is not in your sidebar, select the table in the Table Editor and open its policies panel. It is the same list.
- Security Advisor (under Advisors). It flags tables in exposed schemas that have RLS off, and it often flags views that bypass RLS. Treat it as a checklist. A policy of
using (true)can still leave the advisor showing RLS as enabled. Read the policy.
The SQL Editor runs as a privileged role. It can still read a table after you turn RLS on. That does not mean a visitor with the anon key can. Use the advisor, the badges, and the test further down for the public key.
SQL to list public tables without RLS
In the SQL Editor, this lists every table in the public schema and whether Row Level Security is enabled. rowsecurity is false when RLS is off.
select tablename, rowsecurity
from pg_tables
where schemaname = 'public';The query does not show policies, and it does not include views. It also only covers public. If you exposed another schema in the Data API settings, run the same query with that schema name. A row with rowsecurity = true is not a clean bill of health until you have read the policies:
select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public';In qual (the USING expression) and with_check, a value of true means that command is not limited to the signed-in user.
Risky leftovers: open policies, views, and public buckets
FOR ALL USING (true). Turning RLS on and then adding a policy of for all using (true) — especially to anon or to public — lets anyone with the anon key read and write every row. WITH CHECK (true) does the same for inserts and updates. The policy's name does not change that. Read the expression. If the table holds user data, replace it with auth.uid() = user_id.
Views without security_invoker. A view in an exposed schema runs as the view owner unless it was created with security_invoker. The owner bypasses RLS on the underlying tables, so the view can return rows the anon key should not see even when those tables have RLS on. List views in public:
select c.relname as view_name, c.reloptions
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
and c.relkind = 'v';If reloptions is null, or the list does not include security_invoker=true, the view does not run as the caller. The Security Advisor flags many of these. Recreate or alter the view so it does, then confirm the caller still has the grants it needs.
Public storage buckets. Storage is not covered by table RLS. In Storage → Buckets, a bucket marked public serves its files to anyone who has the URL. That is fine for images you mean to publish. It is a leftover when the bucket holds exports, invoices, or private uploads. You can list the flag directly:
select id, name, public
from storage.buckets;Also read policies on storage.objects. A policy of using (true) for insert lets anyone upload into your quota, public flag or not.
A quick test against your own project
Run this only against a Supabase project you own, with the anon key from that same project. Do not point it at someone else's URL. Do not use the service_role key here. That key bypasses RLS, so the result would be meaningless, and it should not land in your shell history.
The anon key is the public key in Project Settings → API (some projects label the public key publishable). It is the same value already in your frontend. Copy it from your own dashboard or your own bundle.
From a terminal, while you are not sending a user session, request one table. Replace the project ref, the table name, and the key:
curl -sS "https://YOUR_PROJECT_REF.supabase.co/rest/v1/YOUR_TABLE?select=*" \
-H "apikey: YOUR_ANON_KEY" \
-H "Authorization: Bearer YOUR_ANON_KEY"You can do the same check in a logged-out private window: DevTools → Network, then use the app or open the REST URL, and read the response from rest/v1. Do not sign in first. A signed-in session sends a user JWT, which is a different test.
- JSON rows, and you are logged out. Those rows are readable by anyone who has the anon key. If they are not public data, RLS is missing or a policy is allowing them.
- An empty array. This query returned no rows. The table might be empty, or a policy might be hiding them. It does not prove the other tables are locked.
- A permission error. RLS or a missing grant blocked this request. Check the next table. One refusal does not cover the whole project.
The response can contain your users' data. Don't paste it into a chatbot or a ticket. This test reads. It is not a fix.
How to fix it
Enable RLS on each table that should not be world-readable. Do it in the same change as the policies. With RLS on and no policies, the anon and authenticated roles are denied, so the app will start failing those reads until the policies exist.
alter table public.your_table enable row level security;Then limit rows to the signed-in user. Use the owner column the table already has (user_id is the usual name; it might be owner_id or similar):
create policy "select own rows"
on public.your_table
for select
to authenticated
using (auth.uid() = user_id);
create policy "insert own rows"
on public.your_table
for insert
to authenticated
with check (auth.uid() = user_id);
create policy "update own rows"
on public.your_table
for update
to authenticated
using (auth.uid() = user_id)
with check (auth.uid() = user_id);
create policy "delete own rows"
on public.your_table
for delete
to authenticated
using (auth.uid() = user_id);to authenticated means a logged-out visitor with only the anon key does not match. auth.uid() = user_id means a signed-in user only gets their own rows. Drop the old FOR ALL USING (true) policy in the same change, or it still wins. A table that is genuinely public, such as a blog, can allow select to anon and still keep inserts and updates on authenticated.
For a view that bypasses RLS, turn on security invoker:
alter view public.your_view set (security_invoker = true);For storage, turn the public flag off on buckets that hold private files, and add a policy so the object path is scoped to auth.uid(). Keep using the anon key in the browser. Keep service_role on the server, and only for work that has already checked who the user is.
A prompt you can paste into Lovable or Cursor
Paste this into the tool that wrote the app, after you have looked at the dashboard yourself. It tells the model to change policies. It does not ask it to query production or to print keys.
This app uses Supabase from the client. The anon key in the frontend is expected. Do not remove it. Do not put the service_role key in any client component, NEXT_PUBLIC_ variable, or VITE_ variable.
For every table in the public schema, and any other schema exposed through the Data API:
- Enable Row Level Security.
- Drop policies that are FOR ALL USING (true), or that use WITH CHECK (true), for the anon or public role. Those policies let anyone with the anon key read or write every row.
- Add policies so an authenticated user can select, insert, update, and delete only rows where auth.uid() equals that table's user id column (use the column this table already has).
- If a table is intentionally public, allow select for anon and still require auth.uid() for writes.
For views in those schemas, set security_invoker = true so the view respects RLS on the underlying tables.
For storage, set buckets to private unless the files are meant to be public, and add policies so users can only read and write their own objects.
Do not query production tables, do not print keys, and do not call the Data API to test this. When you are done, list the tables and buckets you changed.What HackOrBroke actually checks
HackOrBroke does not query anyone's tables. The free scan fetches the public page you submit and a few of its JavaScript files. If those files contain a supabase.co URL or an anon (or service_role) JWT, the report says so and tells you to confirm RLS yourself.
It does not connect to your database, list tables, read policies, or open storage. A reminder in the report is not a pass or a fail of your rules. Projects that call Supabase only from a route the scan did not open will not show a Supabase finding at all. If you use Supabase, check the dashboard anyway.
A key that starts with sk- in the same bundle is a separate problem. That one is covered in OpenAI API key exposed in your frontend? What to do now.
Common questions
Is a Supabase anon key in the frontend a leaked secret?
- No. The anon key is designed to be public, and Lovable, Bolt, and Cursor apps ship it in JavaScript on purpose. It identifies the project. It does not bypass Row Level Security. The secret is a table with RLS turned off, or a policy that lets everyone through. The service_role key is different: that one bypasses RLS and must not be in the frontend.
What does an RLS disabled or Unrestricted badge mean?
- In the Supabase Table Editor, RLS disabled means Row Level Security is off for that table. Unrestricted means the table is exposed without a restriction that stops the anon key. Treat both as not ready to ship. Anyone who copies the anon key from your JavaScript can read the rows the grants allow. On a typical Supabase table those grants also include changing and deleting rows.
Does FOR ALL USING (true) mean the table is protected?
- No. RLS can be on and still allow every row. A policy of FOR ALL USING (true), or WITH CHECK (true), for the anon or public role lets anyone with the anon key read or write the whole table. Replace it with a policy that compares auth.uid() to the row's user id.
Does HackOrBroke check whether RLS is on?
- No. HackOrBroke does not connect to your database and does not query your tables. The free scan only looks at the public page and a few of its scripts. If it sees a Supabase URL or anon key, it reminds you to check RLS yourself. A reminder is not a test of your policies.
Run the free scan
Point it at a URL you own. If the page uses Supabase, the report says so and reminds you to check RLS. It does not connect to your database, and it does not read your tables.
Related: OpenAI API key exposed in your frontend? What to do now