<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Grzegorz Greg</title>
    <description>The latest articles on DEV Community by Grzegorz Greg (@grzegorz_greg_3135de67fdf).</description>
    <link>https://dev.to/grzegorz_greg_3135de67fdf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F99mvlsfu5tfj9m7ku25d.png</url>
      <title>DEV Community: Grzegorz Greg</title>
      <link>https://dev.to/grzegorz_greg_3135de67fdf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/grzegorz_greg_3135de67fdf"/>
    <language>en</language>
    <item>
      <title>Fixed Supabase's 42501 with GRANT ALL? Check what you just opened</title>
      <dc:creator>Grzegorz Greg</dc:creator>
      <pubDate>Sun, 15 Nov 2026 13:15:14 +0000</pubDate>
      <link>https://dev.to/grzegorz_greg_3135de67fdf/fixed-supabases-42501-with-grant-all-check-what-you-just-opened-5612</link>
      <guid>https://dev.to/grzegorz_greg_3135de67fdf/fixed-supabases-42501-with-grant-all-check-what-you-just-opened-5612</guid>
      <description>&lt;p&gt;&lt;em&gt;AI disclosure: this article was written by an AI model (Claude) working for Proofmerge, not by a human author. Every command and output below was actually run before publishing; details at the end.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Since 30 October 2026, every Supabase project creates new &lt;code&gt;public&lt;/code&gt; tables without Data API access. Supabase announced the change in &lt;a href="https://github.com/orgs/supabase/discussions/45329" rel="noopener noreferrer"&gt;discussion #45329&lt;/a&gt; (new projects have worked this way since 30 May 2026; existing tables keep the grants they already had). A new table now needs an explicit Postgres &lt;code&gt;GRANT&lt;/code&gt; before supabase-js or the REST API can see it. Until then, requests fail with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;permission denied for table invoices   (SQLSTATE 42501)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fastest fix, and one AI coding tools often suggest, is a single line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;grant&lt;/span&gt; &lt;span class="k"&gt;all&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="k"&gt;all&lt;/span&gt; &lt;span class="n"&gt;tables&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="k"&gt;schema&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;anon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works. The error disappears. Whether it was safe depends on something that line does not mention: Row Level Security.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two gates, not one
&lt;/h2&gt;

&lt;p&gt;A request from your frontend has to pass two separate checks in Postgres:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Privileges&lt;/strong&gt; (&lt;code&gt;GRANT&lt;/code&gt;): may the role &lt;code&gt;anon&lt;/code&gt; or &lt;code&gt;authenticated&lt;/code&gt; touch this table at all? Since 30 Oct, new tables start with "no", which is the 42501.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Row Level Security&lt;/strong&gt; (RLS policies): which rows may this caller see or change?&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Grant&lt;/th&gt;
&lt;th&gt;RLS&lt;/th&gt;
&lt;th&gt;What the anon key in your frontend can do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;any&lt;/td&gt;
&lt;td&gt;nothing (42501)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;off&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;read and change every row&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;on, no policy&lt;/td&gt;
&lt;td&gt;nothing: reads return no rows, writes are rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;on, owner policy&lt;/td&gt;
&lt;td&gt;only the rows the policy allows&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The schema-wide &lt;code&gt;grant all&lt;/code&gt; moves every table that has RLS off into the second row of that table. The anon key ships in your frontend bundle, so "the API role" means anyone who opens your site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reproduce it
&lt;/h2&gt;

&lt;p&gt;Two migrations, the kind you find in many AI-built projects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- supabase/migrations/20261102090000_invoices.sql&lt;/span&gt;
&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;invoices&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="kt"&gt;uuid&lt;/span&gt; &lt;span class="k"&gt;primary&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;gen_random_uuid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;user_id&lt;/span&gt; &lt;span class="kt"&gt;uuid&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="k"&gt;references&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;amount_cents&lt;/span&gt; &lt;span class="kt"&gt;integer&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;pdf_path&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- supabase/migrations/20261102093000_fix_permission_denied.sql&lt;/span&gt;
&lt;span class="c1"&gt;-- The app got "42501 permission denied for table invoices", so access was granted.&lt;/span&gt;
&lt;span class="k"&gt;grant&lt;/span&gt; &lt;span class="k"&gt;all&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="k"&gt;all&lt;/span&gt; &lt;span class="n"&gt;tables&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="k"&gt;schema&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;anon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The outputs below come from a local PostgreSQL 16 with stand-ins for Supabase's &lt;code&gt;anon&lt;/code&gt; and &lt;code&gt;authenticated&lt;/code&gt; roles and &lt;code&gt;auth.uid()&lt;/code&gt;, plus two test invoices that belong to two different users. Nothing here touches a real project. This read-only query shows the state of every table in &lt;code&gt;public&lt;/code&gt;, and you can run it as-is in the SQL editor of your own project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relname&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relrowsecurity&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;rls_enabled&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="nf"&gt;has_table_privilege&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'anon'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;oid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'SELECT'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;anon_can_select&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="nf"&gt;has_table_privilege&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'authenticated'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;oid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'SELECT'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;authenticated_can_select&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pg_class&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;
&lt;span class="k"&gt;join&lt;/span&gt; &lt;span class="n"&gt;pg_namespace&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;oid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relnamespace&lt;/span&gt;
&lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nspname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'public'&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relkind&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'r'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'p'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;order&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; table_name | rls_enabled | anon_can_select | authenticated_can_select
------------+-------------+-----------------+--------------------------
 invoices   | f           | t               | t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And as &lt;code&gt;anon&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="n"&gt;anon&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) as rows_visible_to_anon from public.invoices;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; rows_visible_to_anon
----------------------
                    2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both users' invoices, visible to someone who is not signed in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Catch it before it ships
&lt;/h2&gt;

&lt;p&gt;The query above checks a database. The grant, though, was written in a migration, so it can also be caught in the repository before anything is deployed. That is what &lt;a href="https://github.com/dobravaza/proofmerge-rls-check" rel="noopener noreferrer"&gt;&lt;code&gt;rls_check.py&lt;/code&gt;&lt;/a&gt; does (disclosure: it is published by Proofmerge, the company behind this account; details at the end). It is one Python file with no dependencies that reads &lt;code&gt;supabase/migrations&lt;/code&gt; and your app source offline. On the two migrations above (real output, v0.1.0):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 rls_check.py examples/grant-fix
Supabase RLS pre-launch check v0.1.0 - examples/grant-fix
Read 2 SQL file(s) and 0 app source file(s); 1 table(s) in exposed schema(s): public

table public.invoices
  [CRITICAL] RLS001  Table has no row level security
      where: supabase/migrations/20261102090000_invoices.sql:1
      why:   Without RLS, any API role with privileges on this table can read and change every row. Supabase projects created before 30 May 2026 gave anon those privileges automatically on every table made before 30 Oct 2026, and any later GRANT does the same; the anon key ships in your frontend.
      fix:   alter table public.invoices enable row level security;
             create policy "invoices_owner_all" on public.invoices for all to authenticated using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);

schema public
  [HIGH] GRANT002  Schema-wide grant to anon, authenticated on all tables
      where: supabase/migrations/20261102093000_fix_permission_denied.sql:2
      why:   Every table that existed at this point became reachable through the Data API for anon, authenticated, including 1 without RLS (public.invoices), so all their rows are open.
      fix:   revoke all on all tables in schema public from anon, authenticated;  -- then grant each table only what the app needs, after RLS and its policies exist, e.g. grant select, insert, update, delete on public.&amp;lt;table&amp;gt; to authenticated;

Summary: 1 critical, 1 high, 0 medium, 0 low  -&amp;gt;  FAIL (fail-on: high)
Limits: Static reading of migration files only: changes made in the Supabase dashboard are invisible to this tool, and it does not test policies against a live database or replace a human review.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit code 1, so a CI job fails on it.&lt;/p&gt;

&lt;p&gt;Besides these two, it looks for 11 other patterns, 13 in total, all from the migrations and source as they are in the repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RLS:&lt;/strong&gt; RLS never enabled, or switched off in a later migration; RLS on but no policy; &lt;code&gt;using (true)&lt;/code&gt; / &lt;code&gt;with check (true)&lt;/code&gt;; a table with an owner column whose policy never compares it with &lt;code&gt;auth.uid()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grants:&lt;/strong&gt; schema-wide grants and &lt;code&gt;alter default privileges&lt;/code&gt; to &lt;code&gt;anon&lt;/code&gt;/&lt;code&gt;authenticated&lt;/code&gt;; explicit grants to &lt;code&gt;anon&lt;/code&gt; on sensitive-looking tables.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other objects:&lt;/strong&gt; views without &lt;code&gt;security_invoker&lt;/code&gt;, &lt;code&gt;security definer&lt;/code&gt; functions without a fixed &lt;code&gt;search_path&lt;/code&gt;, storage buckets made public.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keys:&lt;/strong&gt; the service-role key in a browser-exposed env var (&lt;code&gt;NEXT_PUBLIC_&lt;/code&gt;, &lt;code&gt;VITE_&lt;/code&gt;, ...), referenced from client-side code, or hardcoded in source.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The real fix
&lt;/h2&gt;

&lt;p&gt;Undo the schema-wide grant, turn RLS on, write the policy, then grant only what the app uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- The fix for examples/grant-fix: undo the schema-wide grant, turn on RLS,&lt;/span&gt;
&lt;span class="c1"&gt;-- let each signed-in user read only their own invoices, and grant only what the app uses.&lt;/span&gt;
&lt;span class="k"&gt;revoke&lt;/span&gt; &lt;span class="k"&gt;all&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="k"&gt;all&lt;/span&gt; &lt;span class="n"&gt;tables&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="k"&gt;schema&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;anon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;alter&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;invoices&lt;/span&gt; &lt;span class="n"&gt;enable&lt;/span&gt; &lt;span class="k"&gt;row&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="n"&gt;security&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="n"&gt;policy&lt;/span&gt; &lt;span class="s2"&gt;"invoices_owner_select"&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;invoices&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt;
  &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;grant&lt;/span&gt; &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;invoices&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Line by line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;revoke all on all tables in schema public from anon, authenticated;&lt;/code&gt; removes the blanket grant from every table it reached, not just this one. Re-grant the other tables one by one after you have checked their RLS.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;enable row level security&lt;/code&gt; without a policy denies everything, so it is safe to run first.&lt;/li&gt;
&lt;li&gt;The policy compares the row's owner with the caller. &lt;code&gt;(select auth.uid())&lt;/code&gt; instead of a bare &lt;code&gt;auth.uid()&lt;/code&gt; lets Postgres evaluate it once per query instead of once per row.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grant select ... to authenticated&lt;/code&gt; gives signed-in users read access, still filtered by the policy. &lt;code&gt;anon&lt;/code&gt; gets nothing: signed-out visitors have no reason to read invoices. Add &lt;code&gt;insert&lt;/code&gt;/&lt;code&gt;update&lt;/code&gt; grants and matching &lt;code&gt;with check&lt;/code&gt; policies only for what the app really does.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same database, after this migration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; table_name | rls_enabled | anon_can_select | authenticated_can_select
------------+-------------+-----------------+--------------------------
 invoices   | t           | f               | t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;anon&lt;/code&gt; now gets &lt;code&gt;permission denied for table invoices&lt;/code&gt; (which is what you want for this table), and a session for user 1 sees exactly one row, their own. The checker agrees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 rls_check.py examples/grant-fix-fixed
Supabase RLS pre-launch check v0.1.0 - examples/grant-fix-fixed
Read 3 SQL file(s) and 0 app source file(s); 1 table(s) in exposed schema(s): public

Summary: 0 critical, 0 high, 0 medium, 0 low  -&amp;gt;  PASS (fail-on: high)
No findings. That means none of the known patterns matched, not that the app is secure.
Limits: Static reading of migration files only: changes made in the Supabase dashboard are invisible to this tool, and it does not test policies against a live database or replace a human review.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both projects are in the repository (&lt;a href="https://github.com/dobravaza/proofmerge-rls-check/tree/main/examples/grant-fix" rel="noopener noreferrer"&gt;&lt;code&gt;examples/grant-fix&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://github.com/dobravaza/proofmerge-rls-check/tree/main/examples/grant-fix-fixed" rel="noopener noreferrer"&gt;&lt;code&gt;examples/grant-fix-fixed&lt;/code&gt;&lt;/a&gt;) if you want to run them yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two more versions of the same mistake
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;alter default privileges in schema public grant all on tables to anon, authenticated;&lt;/code&gt; does the same thing for every table the same role creates later (in Supabase migrations, usually &lt;code&gt;postgres&lt;/code&gt;), which quietly undoes the point of the 30 Oct change. The checker reports it as GRANT002 too. The severity depends on what it opens: it is LOW when every table in the migrations already has RLS and a policy, and higher when a table without RLS becomes reachable.&lt;/li&gt;
&lt;li&gt;Views are covered by the same default privileges, so a new view in &lt;code&gt;public&lt;/code&gt; also starts without grants. Granting &lt;code&gt;select&lt;/code&gt; on it without &lt;code&gt;security_invoker = true&lt;/code&gt; (Postgres 15+) lets it read the underlying tables as the view's owner, past their RLS. On the fixed database above, a plain &lt;code&gt;create view public.invoices_v as select * from public.invoices&lt;/code&gt; with &lt;code&gt;select&lt;/code&gt; granted to &lt;code&gt;anon&lt;/code&gt; returned both invoices to &lt;code&gt;anon&lt;/code&gt; again. With &lt;code&gt;security_invoker = true&lt;/code&gt;, the same query fails with &lt;code&gt;permission denied for table invoices&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In CI
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Supabase RLS check&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;curl -fsSLo rls_check.py https://raw.githubusercontent.com/dobravaza/proofmerge-rls-check/v0.1.0/rls_check.py&lt;/span&gt;
    &lt;span class="s"&gt;echo "b50ee6a168a68493db3f3b866506ef137a6156c94728de98ada5ac54ab94b419  rls_check.py" | sha256sum -c -&lt;/span&gt;
    &lt;span class="s"&gt;python3 rls_check.py . --fail-on high&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pinning the hash means a changed file fails the build instead of running.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does not detect
&lt;/h2&gt;

&lt;p&gt;It reads files. Changes made in the Supabase dashboard or SQL editor that never reached a migration are invisible to it. It does not connect to a database, so it cannot tell you what a policy actually returns for a given user. It knows 13 patterns; a policy that is valid SQL but compares the wrong column, or a table it does not recognise as sensitive, passes. It also does not check &lt;code&gt;EXECUTE&lt;/code&gt; privileges on functions. One example it stays silent on: &lt;code&gt;alter default privileges in schema public revoke execute on functions from public;&lt;/code&gt; looks like a lockdown but changes nothing, because PostgreSQL adds per-schema default privileges to the global ones and a per-schema revoke cannot remove a global grant (tracked as &lt;a href="https://github.com/dobravaza/proofmerge-rls-check/issues/1" rel="noopener noreferrer"&gt;issue #1&lt;/a&gt;, not implemented). A PASS means none of those patterns matched, not that the app is secure. Run the read-only query above against the real database too, and look at Supabase's Security Advisor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a static check cannot replace a security review
&lt;/h2&gt;

&lt;p&gt;A checker like this is good at one thing: catching known, mechanical mistakes in the files, every time, for free. Most of what decides whether user A can see user B's data lives elsewhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Runtime behaviour.&lt;/strong&gt; Only a request made with a real session shows what a role can do. Sign up two test users on a staging project and try to read and change each other's rows through the API, not only through the UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-side code.&lt;/strong&gt; Edge Functions and API routes that use the service-role key bypass RLS entirely. Each of them has to check who the caller is and what they may touch; no migration scan sees that logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Business rules.&lt;/strong&gt; Can a user change a price, upgrade their own plan, or read another organisation's records by guessing an ID? Those are authorization questions about your product, not about Postgres syntax.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration outside the repository.&lt;/strong&gt; Auth settings, redirect URLs, storage policies edited in the dashboard, secrets in the deployed frontend bundle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So use the static check as a floor that runs on every pull request, and before a launch also test the running app with two accounts and read every place that uses the service-role key.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Disclosure: this article was written and edited by Claude, an AI model, working for Proofmerge at its founder's direction and published on the founder's account. Proofmerge publishes &lt;code&gt;rls_check.py&lt;/code&gt; and also sells security reviews, which you should know before reading the last section. The checker is free, MIT-licensed, runs offline and sends nothing anywhere. It is not a Supabase product. Every command and output in this article was run against a local PostgreSQL 16 and &lt;code&gt;rls_check.py&lt;/code&gt; v0.1.0 before publishing; the dates of the Supabase change come from the linked announcement. Corrections will be added here as dated updates.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>postgres</category>
      <category>security</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
