VibeCPR

← All fixes

Supabase · RLS

Fix Supabase RLS policy USING (true) that makes a table publicly readable

Updated (first published ) · Applies to: Supabase, Lovable, Bolt, v0, Cursor, Replit, Claude Code

TL;DR fix: A policy like USING (true) or WITH CHECK (true) for anon or authenticated means every row is allowed for that operation. With a grant on the table, anyone who has your public anon (publishable) key can read or write the whole table through the Data API. Keep RLS on, drop the always-true policy, and replace it with a scoped check such as (select auth.uid()) = user_id. USING (true) on SELECT is only OK for data that is meant to be public.

Steps

  1. Confirm the table is reachable with the anon key. Your anon (publishable) key is meant to be public. The risk is the table behind it. In the browser Network tab or with curl, a GET to /rest/v1/<table>?select=* with only the anon key returning rows for a private table means the grant plus policy combo is too open.
  2. Open Security Advisor and list policies. In the Supabase dashboard go to Advisors → Security Advisor. Fix flags for RLS disabled and permissive policies (always-true). Also open Authentication → Policies (or the table in Table Editor) and read every USING / WITH CHECK expression.
  3. Find USING (true) and WITH CHECK (true). Any policy whose USING or WITH CHECK is literally true (or a tautology like 1=1) allows every row for that operation and role. On INSERT, UPDATE or DELETE for anon, that is almost never intentional. On SELECT it is only OK for genuine public catalogs.
  4. Drop the always-true policy and write a scoped one. Keep RLS enabled. Drop the bad policy, then create one that checks (select auth.uid()) = user_id (or your ownership column) for authenticated. Grant anon SELECT only when the data is meant to be public, and only with an intentional public-read policy.
  5. Retest as anon and as a signed-in user. Logged out: private tables should return empty or 401/403, not other users' rows. Logged in: you should see only your own rows. The SQL editor bypasses RLS, so always retest through the app or REST with the anon key.
  6. Re-run Security Advisor. Confirm the permissive-policy and RLS-disabled warnings are gone, then load the live app once more as a logged-out visitor.

In the news, Nov 2026: 159,041 Lovable projects scanned

Added November 3, 2026. Security firm Crissy Field reports that, working with Handelsblatt (story by Lina Knees, Nov 2, 2026, in German), it looked at 159,041 Lovable projects found in Common Crawl from December 2025 to September 2026. By its own count:

  • 34,545 used Supabase, and 24,664 of those sites sent Supabase records on page load, with no login required.
  • With more read-only requests, it found records containing email addresses in 10,560 tables across 7,403 of those sites (30%).
  • Examples it gives include more than 1,000 records with passport details at one service provider, and more than 200,000 chat messages from one forum.

Crissy Field says the 30% is not a confirmed leak rate, and that its sample isn’t representative of all Lovable apps. These are its figures; we haven’t checked them independently. The cause it describes is access rules set up wrong in Supabase, not a hack.

Lovable users: in Workspace settings → Security → Privacy & security, turn on Block publishing with critical issues. Per Lovable’s docs it is available on all plans and is off by default (except on new Enterprise workspaces Lovable creates). Lovable notes that passing the scan doesn’t prove your app is secure, so run the check below too.

The 2-minute check

Run this in the Supabase SQL editor. Any public table with rowsecurity = false is open to anyone holding your anon key:

select schemaname, tablename, rowsecurity
from pg_tables
where schemaname = 'public'
order by rowsecurity, tablename;

Then list the always-true policies. Each row is a table where that role sees or writes every row:

select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
  and (qual = 'true' or with_check = 'true');

Keep a row only when the table is meant to be public, like a product catalog. For anything else, use the fix below. Then load your live app logged out and check that no private rows come back.

The fix in SQL

Run this in the Supabase SQL editor. Replace profiles and user_id with your table and owner column. Keep RLS on.

-- Keep RLS enabled (do not disable it)
alter table public.profiles enable row level security;

-- Remove always-true policies (adjust names to match yours)
drop policy if exists "Allow public read access" on public.profiles;
drop policy if exists "Enable read access for all users" on public.profiles;
drop policy if exists "Allow all" on public.profiles;

-- Signed-in users read only their own rows
create policy "users read own rows"
  on public.profiles for select
  to authenticated
  using ((select auth.uid()) = user_id);

-- Signed-in users update only their own rows
create policy "users update own rows"
  on public.profiles for update
  to authenticated
  using ((select auth.uid()) = user_id)
  with check ((select auth.uid()) = user_id);

-- Optional: if this table must be readable when logged out (public catalog only)
-- grant select on public.profiles to anon;
-- create policy "public read catalog"
--   on public.profiles for select
--   to anon, authenticated
--   using (true);  -- intentional public SELECT only — never for insert/update/delete

Supabase’s own RLS guide states that a policy to anon using ( true ) grants every unauthenticated visitor read access to every row the role can already reach through grants, and should be used only for data that is meant to be public. Security Advisor lint 0024_permissive_rls_policy flags always-true USING / WITH CHECK expressions for the same reason.

Why AI-built apps hit this so often

Coding agents often enable RLS (or inherit it from the Table Editor), then add a placeholder policy so the app “works” on the first run: using (true) or with check (true). That clears insert errors and blank lists, and looks like a successful fix in the chat transcript. It also recreates the failure mode behind CVE-2025-48757 and the open tables UpGuard counted at 16,326 on October 14, 2026: the public anon key can reach every row.

Related footguns we already document separately:

Reproduce it: RLS on, one always-true policy, whole table readable

In a test project (or any Postgres) this takes a minute. Do not run it against production.

create table public.profiles (id uuid primary key default gen_random_uuid(), user_id uuid not null, username text, email text);
alter table public.profiles enable row level security;
grant select on public.profiles to anon, authenticated;
insert into public.profiles (user_id, username, email) values
  (gen_random_uuid(), 'alice', '[email protected]'),
  (gen_random_uuid(), 'bob',   '[email protected]');

-- The placeholder an AI tool adds to "make the list show up":
create policy "Enable read access for all users" on public.profiles for select using (true);

set role anon;                          -- same as calling /rest/v1/profiles with only the anon key
select username, email from public.profiles;   -- returns every row, emails included
reset role;

Over REST that is GET /rest/v1/profiles?select=* with only your anon key in the apikey header. Now find every always-true policy in your project:

select schemaname, tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
  and (qual in ('true', '(1 = 1)') or with_check in ('true', '(1 = 1)') or (qual is null and cmd = 'SELECT'))
order by tablename, policyname;

Anything on INSERT, UPDATE or DELETE for anon or authenticated should be dropped and replaced with the auth.uid() policies above. A SELECT policy is fine only on tables whose contents are meant to be public.

Copy-paste: lock down grants too, not just policies

Policies and grants are separate layers: a role needs a table grant and a passing policy, so on projects with default grants, anon can reach every table where a permissive policy exists. On projects that still grant everything by default, revoke what each role doesn’t need:

-- Private table: nothing for logged-out visitors, only the operations the app really uses for signed-in users
revoke all on table public.profiles from anon, authenticated;
grant select, insert, update, delete on table public.profiles to authenticated;

-- Genuinely public read-only catalog: SELECT only, for the roles that need it
-- revoke all on table public.products from anon, authenticated;
-- grant select on table public.products to anon, authenticated;

Then run the same anon test again: private tables should now return permission denied (no grant) or empty (no matching policy), never other people’s rows.

RLS on, USING (true) gone, and it still leaked: views

The other common way RLS gets skipped has nothing to do with policies. A Postgres view runs with its owner’s rights, and on Supabase the owner is postgres, which bypasses RLS. Supabase’s docs state that views bypass RLS by default.

On October 23, 2026 the builder Max Hirsch reported that 35,000 profiles in his Supabase app were wiped overnight. In his words he had “bypassed RLS with a view so users could see each other’s profiles, and didn’t revoke Supabase’s default anon permissions, so the public key could delete everyone through it.” The table’s RLS was fine. The view and its default grants were the hole.

Check your views and close the hole (Postgres 15+):

revoke insert, update, delete, truncate on public.your_view from anon, authenticated;
alter view public.your_view set (security_invoker = true);

Reproduction, an audit query for every view, and what to do if users must see each other’s public fields: Fix a Supabase view that bypasses RLS.

Prompt for Cursor, Lovable or Bolt

Audit public.<table> for policies with USING (true) or WITH CHECK (true).
Do NOT disable RLS. Do NOT leave always-true write policies for anon or authenticated.
Drop those policies and replace them with (select auth.uid()) = user_id
(USING and WITH CHECK as appropriate). USING (true) is allowed only for
intentional public SELECT on non-sensitive data. Show me the SQL diff first.

When to get help

Get help if an AI tool keeps regenerating USING (true) policies, if you have many tables and are not sure which ones should be public, or if Security Advisor is clean but REST still returns other users' rows.

FAQ

Can RLS be on and still let the anon key delete rows?

Yes. RLS only applies to the table when it is read through the table itself. A view created by the postgres user runs as its owner and skips RLS, and if anon still has a write grant on that view it can delete rows through it. A builder reported losing 35,000 profiles this way on October 23, 2026. The fix is to revoke write grants on views from anon and authenticated and set security_invoker = true on views over protected tables. Guide: https://vibecpr.com/fix/supabase-view-bypasses-rls-security-invoker

What does an RLS policy with USING (true) mean?

USING (true) means the policy allows every row for that operation. Combined with a GRANT to anon or authenticated, anyone holding your public anon key can perform that operation on every row through the Data API. Supabase's Security Advisor flags this as a permissive RLS policy. Replace it with a real condition such as (select auth.uid()) = user_id, unless the table is intentionally public and the policy is SELECT-only.

Is this the same as RLS being disabled?

No. With RLS disabled, grants alone decide access and every granted role can touch every row. With RLS on and USING (true), policies exist but do not restrict rows, so the effect for that operation is the same: full table access for the role. Fix by scoping the policy, not by turning RLS off.

How do I check if my Supabase tables are publicly readable?

Run Security Advisor, then try the REST endpoint for each sensitive table with only your anon key (no user JWT). If private rows come back, the table is publicly readable. Step-by-step checklist: https://vibecpr.com/blog/check-supabase-rls-in-two-minutes

Is my anon key leaked if it is in the frontend?

No. The anon (publishable) key is designed to sit in client code. The leak is data: tables the anon role can read or write because RLS is off or a policy is USING (true) / WITH CHECK (true). Never put the service_role or secret key in the browser.

How does this relate to CVE-2025-48757 and UpGuard's findings?

CVE-2025-48757 covered Lovable apps whose Supabase tables had missing or insufficient RLS, so the public anon key could read or write data. UpGuard's October 14, 2026 study found 16,326 Supabase databases with publicly readable tables across ~300,000 domains, including cases where policies existed but did not adequately restrict access. Always-true policies are one of those inadequate patterns.

Sources

Related fixes