← Blog · 28 October 2026

Is your Supabase view ignoring Row Level Security? How to check and fix it

Start with the outside check: paste your app's address into the free Vibe-App Watchdog scan. It looks at what any visitor can see, like secret keys in your public JavaScript, open files such as /.env, and missing security headers. It cannot see your database rules, so the view check below is one you do yourself in Supabase.

You turned on Row Level Security (RLS) on every table. You added a policy so each user sees only their own rows. Then you, or your AI builder, made a view to make a page easier to load, for example profiles_with_orders. That view may hand every row to anyone who asks.

Why a view can skip RLS

Supabase's own docs say it plainly: "Views bypass RLS by default because they are usually created with the postgres user." Postgres creates views with security definer rights by default, so the view runs as its creator, not as the person asking (Supabase: Row Level Security).

So your table is locked, but the view in front of it is not. If the view is in the public schema, the Supabase API can serve it with your public anon key, which is in your frontend on purpose.

Supabase's Security Advisor has a warning for exactly this, called "Security Definer View" (lint 0010). Its docs give an example: a public security definer view that reads from auth.users "exposes all user records to all API users" (Supabase: Database Advisors).

How to check

Only check your own app and your own Supabase project.

  1. Run the Security Advisor. In your Supabase dashboard, open Advisors > Security Advisor. Look for "Security Definer View" warnings. Each one names a view.
  2. List your views. In the SQL Editor, run:
    select table_schema, table_name
    from information_schema.views
    where table_schema = 'public';

    Any view you see here can be reached through the API unless you have removed access.

  3. Test it logged out. Open your own app in a private window without logging in. In DevTools > Network, find a request to /rest/v1/ and change the table name in the address to the view's name. Add &limit=1 so you fetch as little as possible. If you get a row back that a logged-out visitor should not see, the view is open. Do not save or share what you see. You only need to know if data comes back.

If your app is on Lovable Cloud and you cannot open the Supabase dashboard, ask Lovable to run its security scan and to "list every database view and say whether it uses security_invoker".

How to fix it

On Postgres 15 and newer, make the view follow the RLS rules of the tables under it:

alter view public.your_view_name set (security_invoker = true);

For a new view, add it when you create it:

create view public.your_view_name
with (security_invoker = true)
as select ...;

Supabase's docs show this same setting (Supabase: Row Level Security). After the change, run the logged-out test again. You should now get an empty list or an error.

On older Postgres versions, the docs suggest taking access away from the anon and authenticated roles (revoke select on public.your_view_name from anon, authenticated;).

A prompt you can give your AI builder

List every view in my Supabase database. For each one, tell me if it uses security_invoker. Set security_invoker = true on any view in the public schema, unless it must show data to logged-out visitors. Do not change any table policies. Show me the SQL before you run it.

What about materialized views?

Supabase notes that materialized views do not support RLS at all (Supabase: Database Advisors). If you have one in the public schema with private data, remove access for anon and authenticated, the same way as above.

After the fix

Re-run the Security Advisor until the warning is gone, and repeat the logged-out test after every big change your AI builder makes to the database. Our scan cannot see views or database rules, so it cannot do this check for you. Then run a free outside scan of the live app to check the parts a visitor can see: keys in your JavaScript, open files and security headers.