Sample alert How it works Coverage PENTEST METHODOLOGY DOCS PRICING FAQ MCP CONTACT LOG IN SCAN MY APP →

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

  1. Discovers the Supabase project URL and anon key from your frontend bundle
  2. Enumerates public tables via the PostgREST ?select=* introspection on the OpenAPI spec at /rest/v1/
  3. 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
  4. 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

  1. View source on your site and search supabase.co. The URL https://<projectRef>.supabase.co sits next to the anon JWT.
  2. Decode the JWT at jwt.io. The ref claim confirms the project and role: anon confirms it is the public key.
  3. Request https://<projectRef>.supabase.co/rest/v1/?apikey=<anonKey> to get the OpenAPI spec listing every table, view, and function in your public schema.
  4. For each table, GET /rest/v1/<table>?select=*&limit=1000 with the anon key. If RLS is off, you get rows. Range headers page through the rest.
  5. For writes, POST /rest/v1/<table> with a JSON body. If RLS is off (or only SELECT policies exist), inserts succeed.
  6. For storage, GET /storage/v1/bucket lists 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-public schemas. 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_dump snapshots 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

  1. Create the table in a migration.
  2. In the same migration, add ENABLE ROW LEVEL SECURITY and policies (or FORCE RLS).
  3. Deploy the migration before frontend code that depends on open access.
  4. Run this checker against the staging URL.
  5. Promote to production and scan the production URL.
  6. 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

  1. Enable RLS (locks the table closed).
  2. Add correct policies in the same migration.
  3. Test app login paths.
  4. 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:

  1. Authenticated user A cannot read user B’s rows (manual or deep agent).
  2. service_role is absent from the bundle (Token Leak Checker).
  3. Storage list and one RPC pass a manual probe.
  4. Tables added after the scan are re-checked.
  5. 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.

Common questions

What does 'missing RLS' actually mean?
Supabase exposes your Postgres database over a public REST API. Without Row Level Security (RLS) policies, anyone with your anon key can read, modify, or delete any row in any public table. The anon key is in your frontend - so anyone can use it.
How do I enable RLS?
In the Supabase dashboard, navigate to the table, enable RLS, then add policies like `auth.uid() = user_id` for reads. Or use SQL: `ALTER TABLE posts ENABLE ROW LEVEL SECURITY;` then `CREATE POLICY ...`. Rescan to verify.
Does the tool store my data or scan results?
Scan inputs (URL) are stored for support. Data read from your tables during probing is not stored - only counts and table names (which are already public).
Will enabling RLS break my Lovable app?
If you enable RLS with zero policies, the table blocks everyone - including your app. Add owner-scoped policies in the same change, then retest login flows. Never 'fix' breakage with USING (true).
Does this replace a full pentest?
No. It focuses on the anon-key / RLS surface that dominates AI-generated Supabase breaches. Combine with auth testing, Edge Function review, and a broader vibe code scan for BOLA and webhooks.
Can the checker see tables behind the service_role key only?
It uses the public anon key from your bundle - the same as visitors. If only service_role can read a table, that is correct for server-only data; ensure service_role never ships to the client.
Why is RLS off by default on new tables?
Postgres/Supabase require an explicit opt-in so greenfield schemas are not mysteriously empty. That default is correct for empty prototypes and catastrophic when the same table already holds production rows and PostgREST is public.
Does FORCE ROW LEVEL SECURITY matter?
Yes for table owners and bypass roles. FORCE applies RLS even to the table owner, reducing surprise access via powerful DB roles. Enable it on multi-tenant tables.

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

RUN FULL SCAN →