Short answer: the Supabase Security Advisor runs fixed checks (lints) against your database and labels each finding ERROR, WARN or INFO. Treat every ERROR as a launch blocker: "RLS disabled in public" (lint 0013), "Security definer view" (0010), "Auth users exposed" (0002), "Policy references user_metadata" (0015) and "Sensitive columns exposed" (0023) all mean data can be read or changed by anyone with your public anon key. Most WARN findings, like "Function search path mutable" (0011) and always-true policies (0024), are quick SQL fixes. Fix the data exposure first, then rerun the advisor until it is clean or every remaining item is a deliberate choice.
If you built your app with Lovable, Bolt, v0, Cursor or Replit on top of Supabase, you have probably seen a red badge next to Advisors. This guide explains each common warning and how to fix it properly, instead of making the badge go away by turning things off.
Where to find the Security Advisor
You can run the same checks in a few places:
- Studio: Advisors, then Security Advisor, in your project dashboard.
- CLI:
supabase db advisorsagainst a linked project. - MCP: the
get_advisorstool withtypeset tosecurity, if you use Supabase from an AI coding agent.
Each finding links to a docs page with its lint ID, like 0013_rls_disabled_in_public.
ERROR level: fix these before launch
RLS disabled in public (0013)
Tables in the public schema are served by the Data API. If row level security is off, anyone with your project URL and public key can select, insert, update and delete every row. This is the single most common finding in AI-built apps.
alter table public.orders enable row level security;
create policy "owners read their orders"
on public.orders for select
to authenticated
using ((select auth.uid()) = user_id);
Enabling RLS with no policies blocks all access through the API, so add the policies your app needs right after. If your app suddenly errors with "new row violates row-level security policy", read how to fix that error safely instead of disabling RLS again. The Supabase RLS checklist covers policy patterns for each table type.
Sensitive columns exposed (0023)
This fires on tables with RLS off that also have columns named like password, api_key, token, ssn or card_number. Same fix as 0013, but do it first. Then ask whether those columns belong in an API-exposed table at all. Third-party API keys and tokens usually belong in Edge Function secrets or a private schema, not a public table.
Security definer view (0010)
Postgres views run with the privileges of the view owner by default. In Supabase that owner is usually postgres, which bypasses RLS. So a view in public can return every row of a table that is otherwise locked down. On Postgres 15 and later, make the view respect the caller's RLS:
alter view public.order_summaries set (security_invoker = on);
Or recreate it with create view public.order_summaries with (security_invoker = on) as .... After the change, test the view as a normal signed-in user. If it now returns nothing, the underlying tables need select policies for that user. The RPC and security definer functions guide explains the same issue for functions.
Auth users exposed (0002)
A view in public that selects from auth.users exposes emails, phone numbers and sign-in metadata for every user. AI tools often create one to show "author name" next to a post. Drop the view and use a profiles table with only the fields you want public:
drop view if exists public.users_view;
create table public.profiles (
id uuid primary key references auth.users on delete cascade,
display_name text,
avatar_url text
);
alter table public.profiles enable row level security;
create policy "profiles are readable by signed-in users"
on public.profiles for select
to authenticated
using (true);
This policy is deliberately open, so the advisor may list it under 0024 (below). That is acceptable here because the table only holds fields you chose to make visible. Populate it with a trigger on auth.users. Keep that trigger function simple, since an error inside it blocks signups.
Policy references user_metadata (0015)
Any user can change their own raw_user_meta_data by calling supabase.auth.updateUser({ data: { role: "admin" } }). A policy like auth.jwt() -> 'user_metadata' ->> 'role' = 'admin' is therefore an open door. Move roles to app_metadata or a roles table that users cannot write. Full steps are in how to add admin roles in Supabase securely.
Dynamic SQL functions and exposed queues (0031, 0032, 0019)
A function that runs execute on a string passed in by the caller, such as an exec_sql(query text) helper an AI agent added "for convenience", gives callers arbitrary SQL. Revoke it and drop it:
revoke execute on function public.exec_sql(text) from anon, authenticated, public;
drop function public.exec_sql(text);
The queue lint (0019) flags pgmq queues exposed through the API without RLS. Enable RLS on the queue tables or stop exposing them.
WARN level: quick fixes worth doing
Function search path mutable (0011)
A function without a fixed search_path resolves unqualified names like profiles using the caller's settings, which can be abused, especially in security definer functions. Pin it and schema-qualify every reference:
create or replace function public.get_my_orders()
returns setof public.orders
language sql
security invoker
set search_path = ''
as $$
select * from public.orders where user_id = (select auth.uid());
$$;
If you only want to patch the setting without rewriting, alter function public.get_my_orders() set search_path = ''; works, but the function will break if its body uses unqualified names. Test it after.
Security definer function executable by anon or authenticated (0028, 0029)
Postgres grants EXECUTE on new functions to PUBLIC, and Supabase also grants it to anon and authenticated. That means a definer function in public is callable at /rest/v1/rpc/<name> by anyone. Revoke from both roles together, because revoking only from anon still leaves it open to every signed-up user:
revoke execute on function public.admin_reset_credits(uuid) from public, anon, authenticated;
grant execute on function public.admin_reset_credits(uuid) to service_role;
Permissive RLS policy (0024)
RLS is on, but a policy uses using (true) or with check (true). That is common in generated code because it makes everything work. A using (true) select policy is fine for truly public data, like published blog posts. It is not fine on insert, update or delete, or on any table with private data. Replace it with an ownership check, as in the 0013 example.
Public bucket allows listing (0025)
Public Storage buckets already serve files by URL. Adding a broad select policy on storage.objects for that bucket also lets anyone list every file name. Remove the policy unless you need listing. See Supabase Storage security for private bucket setups.
GraphQL exposure (0026, 0027)
If you don't use the GraphQL endpoint, disabling the pg_graphql extension removes a second way to query your schema. It does not replace RLS.
Auth settings warnings
The advisor also reports Auth configuration, such as leaked password protection being off, long OTP expiry, or too few MFA options. These are set in the Auth settings pages, not SQL. Some, like leaked password protection, depend on your plan.
INFO level: read, then decide
- RLS enabled, no policy (0008): the table is locked to the API. That is safe. It is only a problem if your app needs to read it.
- Policy exists, RLS disabled (0007): you wrote policies but never turned RLS on, so they do nothing. Enable RLS.
- Anonymous sign-ins enabled (0012): anonymous users get the
authenticatedrole. Any policy writtento authenticatedapplies to them too. Add(select (auth.jwt() ->> 'is_anonymous')::boolean) is falsewhere only real accounts should have access.
Don't silence the advisor
The wrong fixes are tempting: disabling RLS because a query broke, granting everything to anon, or switching the app to the service role key. The service role key bypasses RLS completely, and if it ends up in client code anyone can use it. If that has already happened, follow how to rotate leaked Supabase and OpenAI keys.
After each fix, rerun the advisor and test with two real accounts: user A should never see user B's rows. A clean advisor is a good baseline, but it doesn't check your app logic, such as API routes that trust a user_id from the request. The guide to preventing IDOR in Next.js and Supabase covers that side.
Related guides
Get an automated check
PreflightPR reviews AI-built apps for tables without RLS, always-true policies, security definer functions, service role keys in client code and leaked keys in your repo. Run a free scan on a public repo for a launch score and a prioritized fix list, or install the PreflightPR GitHub App to check every pull request before it merges.