Supabase RLS Checker: Free Scan for Exposed Tables
Missing RLS is the #1 vulnerability in Lovable and Bolt apps. This tool tests every public table through the anon key - exactly like an attacker would.
TEST YOUR SUPABASE TABLES NOW
Enter your deployed app URL - we discover the Supabase project from your bundle and probe every public table with the anon key.
Why missing RLS is the top Lovable/Bolt vulnerability
Lovable and Bolt both default to Supabase, and Supabase tables are created with RLS disabled. The app works in preview. In production, every row in users, orders, messages, and documents is readable by anyone with a browser console.
The Supabase anon key is meant to ship to the browser, because that is how the client SDK reaches the database. RLS is what constrains it. With RLS off, the anon key is a full read/write key for your entire schema, handed to every visitor.
What the checker does
- Discovers the Supabase project URL and anon key from your frontend bundle
- Enumerates public tables via the PostgREST
?select=*introspection on the OpenAPI spec at/rest/v1/ - Probes each table with an anon read, checking for:
- Unrestricted read (critical)
- Unrestricted write/delete (critical)
- Missing user-scoped policy (high)
- Over-permissive policy (medium)
- Storage bucket access via
storage/v1/object/public
- Reports each finding with the SQL to fix it and a verification query
It uses the same material an attacker already has: your HTML/JS and the anon JWT. It does not need your dashboard login. If the checker can read a table, so can they.
Common finding types
TABLE FULLY PUBLIC
Anon key reads every row. Critical. Most common finding.
WRITE PERMITTED
Anyone can insert/update/delete.
USER-SCOPE MISSING
RLS enabled but policy doesn't filter by auth.uid().
OVER-SHARED COLUMNS
RLS works but selects return email/phone/PII to every requester.
RPC WIDE OPEN
Postgres functions exposed via /rest/v1/rpc/* with no EXECUTE restriction.
STORAGE BUCKET PUBLIC
Public bucket with sensitive uploads (invoices, IDs, avatars containing EXIF).
VIEWS BYPASS RLS
Views defined as SECURITY DEFINER run as the owner - RLS on the underlying tables is silently bypassed.
SERVICE-ROLE KEY LEAK
Cross-check: if the bundle contains the service_role key (not just the anon key), every other RLS finding is moot.
How attackers find your Supabase project
- View source on your site and search
supabase.co. The URLhttps://<projectRef>.supabase.cosits next to the anon JWT. - Decode the JWT at jwt.io. The
refclaim confirms the project androle: anonconfirms it is the public key. - Request
https://<projectRef>.supabase.co/rest/v1/?apikey=<anonKey>to get the OpenAPI spec listing every table, view, and function in yourpublicschema. - For each table,
GET /rest/v1/<table>?select=*&limit=1000with the anon key. If RLS is off, you get rows.Rangeheaders page through the rest. - For writes,
POST /rest/v1/<table>with a JSON body. If RLS is off (or onlySELECTpolicies exist), inserts succeed. - For storage,
GET /storage/v1/bucketlists buckets. Each public bucket exposes/storage/v1/object/public/<bucket>/<path>.
No SQL injection is involved. The published API does the work.
Policy starter pack
Paste into the Supabase SQL editor:
-- Enable RLS on a table (RLS is OFF by default - you must opt in)
ALTER TABLE posts ENABLE ROW LEVEL SECURITY;
-- Force RLS even for table owners - protects against future role drift
ALTER TABLE posts FORCE ROW LEVEL SECURITY;
-- SELECT: users read their own rows
CREATE POLICY "posts_select_own" ON posts
FOR SELECT
TO authenticated
USING (auth.uid() = user_id);
-- INSERT: users can only create rows they own
CREATE POLICY "posts_insert_own" ON posts
FOR INSERT
TO authenticated
WITH CHECK (auth.uid() = user_id);
-- UPDATE: users can only modify rows they own (and can't change ownership)
CREATE POLICY "posts_update_own" ON posts
FOR UPDATE
TO authenticated
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id);
-- DELETE: explicit, separate from update
CREATE POLICY "posts_delete_own" ON posts
FOR DELETE
TO authenticated
USING (auth.uid() = user_id);
FORCE applies RLS even to the table owner, which limits surprise access through powerful DB roles. Enable it on multi-tenant tables.
Public read, private write (content sites)
CREATE POLICY "posts_public_read" ON posts
FOR SELECT TO anon, authenticated
USING (published = true);
CREATE POLICY "posts_author_write" ON posts
FOR ALL TO authenticated
USING (auth.uid() = author_id)
WITH CHECK (auth.uid() = author_id);
Do not use public read on tables that mix public fields with private columns (email next to bio). Split the table or use column-level views carefully.
Common policy pitfalls
| Mistake | What it looks like | Fix |
|---|---|---|
| RLS enabled, no policies | ENABLE ROW LEVEL SECURITY without any CREATE POLICY - table is fully blocked, app breaks, dev “fixes” by disabling RLS again |
Add at least one SELECT policy with auth.uid() filter |
USING (true) |
Policy exists but condition is always true | Replace true with the user-scope filter |
FOR ALL over-grants |
Single policy covers SELECT/INSERT/UPDATE/DELETE - easy to mis-scope | Split into per-action policies |
WITH CHECK missing on UPDATE |
User can update their row to set user_id to someone else’s |
Always pair USING with a matching WITH CHECK on UPDATE |
Anonymous (anon) policies |
TO anon accidentally added - defeats the purpose |
Use TO authenticated unless you genuinely want public reads |
| Service role used in client | Frontend uses service_role key “just to ship” - bypasses RLS entirely |
Rotate immediately, switch client to anon key |
SECURITY DEFINER views |
View runs as the owner, ignoring caller’s RLS context | Use SECURITY INVOKER (Postgres 15+) or rewrite as a function with row-filter logic |
| Policy on wrong column | Filters id instead of owner_id |
Match the ownership model your app actually uses |
Verify a fix from the command line
After deploying a policy change, replay what the scanner does:
# Should return [] for a properly RLS'd table when called with anon key
curl "https://<ref>.supabase.co/rest/v1/posts?select=*&limit=1" \
-H "apikey: <anon_key>" \
-H "Authorization: Bearer <anon_key>"
# Should return your row(s) only when called with a real user JWT
curl "https://<ref>.supabase.co/rest/v1/posts?select=*&limit=1" \
-H "apikey: <anon_key>" \
-H "Authorization: Bearer <user_jwt>"
If the first call still returns rows, the policy isn’t filtering. Likely causes: a leftover USING (true), or RLS was never enabled on this table (check pg_class.relrowsecurity).
select tablename, rowsecurity
from pg_tables
where schemaname = 'public';
What this scanner does not flag
- Tables in non-
publicschemas. PostgREST exposes only the schemas you configure. Data moved to a non-exposed schema is invisible to the scanner. - Custom JWT claims used by your policies. If a policy uses
auth.jwt()->>'org_id'and the scanner has no org-scoped JWT, it cannot tell whether cross-org isolation works. These are marked Pass-with-caveat and need authenticated re-testing. - Realtime subscription channels. Realtime has its own RLS evaluation. The scanner tests REST, not WebSocket subscriptions. Test channels manually with the JS client.
- Edge Function authorization. Edge Functions run with the service role by default and bypass RLS unless you pass the user’s JWT through. Covered by the full Vibe Code Scanner.
- Database backup files. If
pg_dumpsnapshots are accessible via Storage, RLS does not help.
Multi-tenant and org-scoped policies
SaaS apps often need more than auth.uid() = user_id:
-- Example: membership table drives access
create policy "org members read projects"
on projects for select to authenticated
using (
exists (
select 1 from org_members m
where m.org_id = projects.org_id
and m.user_id = auth.uid()
)
);
Common pitfalls: recursive policies that call tables without RLS, policies that check org only on SELECT, and clients that can insert themselves into org_members. Test with users in org A and org B, not just logged-in vs anon.
Harden membership so users cannot self-join:
-- Members cannot self-insert into arbitrary orgs
create policy "no self-join without invite"
on org_members for insert to authenticated
with check (false); -- inserts only via service role / edge after invite accept
Invite-accept handlers must set the role from the invite record, never from the client body.
Policy testing matrix:
| Actor | Table | Expected |
|---|---|---|
| anon | private rows | empty / 401 |
| user A JWT | user A rows | visible |
| user A JWT | user B rows | empty / 404 |
| user A JWT | org shared | only if member |
| service_role | any | bypass (server only - never in browser) |
Migration workflow
- Create the table in a migration.
- In the same migration, add
ENABLE ROW LEVEL SECURITYand policies (or FORCE RLS). - Deploy the migration before frontend code that depends on open access.
- Run this checker against the staging URL.
- Promote to production and scan the production URL.
- Remove any “temporary”
USING (true)policy in a follow-up PR.
AI tools often emit step 1 without step 2. Make step 2 a required review comment on every schema PR.
-- CI assertion: no public table lacks RLS
do $$
begin
if exists (
select 1 from pg_tables
where schemaname = 'public' and rowsecurity = false
) then
raise exception 'RLS disabled on a public table';
end if;
end $$;
For CI, spin up a branch database or local Supabase, apply migrations, seed two users with sample rows, run anon and cross-user probes, and fail on unexpected row counts. Store the probe script next to the migrations so policy and test change together. Point this scanner at the preview URL for environments that exist only after deploy.
Views, RPC, and storage bypasses
- SECURITY DEFINER views run as owner and ignore caller RLS. Prefer
SECURITY INVOKER(Postgres 15+) or filter inside the view definition. - RPC at
/rest/v1/rpc/*needs EXECUTE grants and internal authz. Table RLS does not apply inside security-definer functions. - Storage policies are separate from table RLS. A public bucket dumps files even when tables are locked.
- Realtime evaluates RLS on select. Wrong channel filters leak inserts across users.
-- Storage: owner-scoped objects (sketch)
create policy "own objects"
on storage.objects for select to authenticated
using (auth.uid()::text = (storage.foldername(name))[1]);
For each table, write one sentence: who can select, insert, update, and delete, under what ownership or membership rule. If the sentence is vague (“admins can do everything”), define admin through a membership table or claim, not a client-set boolean.
alter table public.projects enable row level security;
create policy projects_select_member on public.projects for select using (
id in (select project_id from public.project_members where user_id = auth.uid())
);
create policy projects_insert_owner on public.projects for insert
with check (auth.uid() = owner_id);
Fix order that minimizes downtime
- Enable RLS (locks the table closed).
- Add correct policies in the same migration.
- Test app login paths.
- Rescan.
Enabling RLS without policies in production is a total outage. Do not “fix” the outage with using (true).
After a green report
A clean result means anonymous probes did not read or write data they should not. It says nothing about Edge Functions, an exposed service role, or business logic abused through a valid session. Still verify:
- Authenticated user A cannot read user B’s rows (manual or deep agent).
service_roleis absent from the bundle (Token Leak Checker).- Storage list and one RPC pass a manual probe.
- Tables added after the scan are re-checked.
- Realtime subscriptions do not broadcast foreign rows.
Then run dual-user BOLA tests on the app’s primary resources and a full vibe code scan for keys and open routes.
Lovable / Bolt specific notes
- A prompt that adds a feature often adds a table without policies. Rescan after every prompt that touches data.
USING (true)appears when the AI “fixes” a locked table that broke the UI.- Edge Functions generated with the service role “for simplicity” reintroduce BOLA even when RLS is correct. Typical cause: a lookup by id with no owner check.
- Share-password on the Lovable preview does not protect PostgREST. Attackers skip the UI.
- Policies on SELECT only, with INSERT/UPDATE open to all authenticated users, are another common AI output.
Loop after each data-touching prompt: enable RLS and policies, deploy, run this checker, spot-check with two users.
Related tools and guides
- Lovable Safety Guide - full breakdown of what Lovable apps ship insecure by default.
- Token Leak Checker - confirms whether you accidentally shipped the
service_rolekey. - Free Security Self-Audit - 30-minute manual pass for Supabase + Auth + Edge Functions.
- Lovable Password Protection - pair with RLS to block credential-stuffing into otherwise locked-down rows.
- Supabase RLS Guide - deeper policy patterns.
- Supabase misconfiguration atlas - failure modes in the wild.
Common questions
What does 'missing RLS' actually mean?
How do I enable RLS?
Does the tool store my data or scan results?
Will enabling RLS break my Lovable app?
Does this replace a full pentest?
Can the checker see tables behind the service_role key only?
Why is RLS off by default on new tables?
Does FORCE ROW LEVEL SECURITY matter?
Audit every table auth flow
RLS on one table is not enough. The agent extends this into auth bypass testing and cross-user data probing on the full app.
14-day free trial · Cancel anytime