Supabase says your table is publicly accessible (RLS disabled): what to do, in order
Supabase warns you when a table in the public schema has Row Level Security (RLS) turned off. You may see it as a Security Advisor warning in the dashboard (the lint is called rls_disabled_in_public ) or as an email about a publicly accessible table. If you got one, treat it as real. Here is what to do, in order. What the warning means With RLS off, any request that carries your project's anon…
Supabase alerts users when a table in the public schema has Row Level Security (RLS) disabled, notifying them through the dashboard or email. This warning indicates that the table is accessible via the API, with the anon key present in the app's JavaScript, allowing anyone to read and, often, write to it. To address this, follow these steps:
1. Enable RLS on the affected table using the SQL command `alter table public.your_table enable row level security;`.
2. Once RLS is enabled, add policies to restrict access. For data belonging to a user, create policies allowing the owner to read and insert, using `auth.uid()` to identify the user. Implement similar policies for update and delete operations.
3. After implementing policies, review your API logs to ensure the table was not read by unauthorized clients. If it contained personal data, notify your legal or privacy contact, as required by your jurisdiction.
4. Test the fix by attempting to access the table from an unauthenticated session using only the anon key. Confirm that no private rows are returned, and then test with two different user accounts to verify that one user cannot see another's data.
5. Check for additional tables with disabled RLS by running `select tablename, rowsecurity from pg_tables where schemaname = 'public';`. Also, review your storage bucket policies and any instances of the service_role key in your front-end code. Utilize free tools like [Supabase RLS Checker](https://proofforge.live/tools/supabase-rls-checker) and [Fix Guide](https://proofforge.live/fix/supabase-rls-disabled) to assist with the process. Be prepared for potential policy errors when adding new rules.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to