Repository navigation
Description
Improve the documentation
Following up on a comment I left in #43884, where I offered to raise this separately.
Short version: the RLS guide's examples imply that the privilege baseline in public is nothing, and you add from there. The actual baseline is everything, granted to anon and authenticated by default privileges. So the documented action is a no-op and the action that is actually required — revoking — never appears.
Where
guides/database/postgres/row-level-security currently says:
RLS is enabled by default on tables created with the Table Editor in the dashboard. If you create one in raw SQL or with the SQL editor, remember to enable RLS yourself and grant only the permissions each Postgres role needs.
followed by:
GRANT SELECT ON <schema_name>.<table_name> TO anon;
GRANT SELECT, INSERT, UPDATE, DELETE ON <schema_name>.<table_name> TO authenticated;"Grant only the permissions each role needs" is the right instruction, but a reader following those examples ends up where they already were. On a stock project, a table created in public with plain create table already has this, with no grant statement anywhere in the migration:
heat_purchase | anon | DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE
heat_purchase | authenticated | DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE
Granting SELECT to anon on top of that changes nothing. The example reads as tightening and is a no-op.
guides/deployment/going-into-prod — the security section covers enabling RLS but does not mention table or function grants at all, so a reader working the checklist has no prompt to look at this.
The specific thing I think is worth a sentence
TRUNCATE is in that default grant, and RLS does not apply to it. Same table, same role, same transaction, RLS enabled with no permissive policy:
set local role anon;
delete from heat_purchase; -- blocked by RLS. row survived.
truncate heat_purchase; -- succeeded. table went to 0 rows.DELETE and TRUNCATE sit next to each other in the same privilege string and only one has a policy layer behind it, so this is genuinely hard to spot by reading the grant list. REFERENCES and TRIGGER are in there too and are likewise not reachable through PostgREST.
Suggested change
- In the RLS guide, note that
publicalready carries default grants foranon/authenticated, and show the revoke-then-grant form rather than grant-only:
revoke all on table <schema>.<table> from anon, authenticated;
grant select on table <schema>.<table> to anon;-
Add one line to the production checklist: review
information_schema.role_table_grantsforanon/authenticated, and note that RLS does not coverTRUNCATE. -
Optionally:
TRUNCATE,REFERENCESandTRIGGERaren't usable via the Data API, so excluding them from the default grant would remove the one operation RLS cannot gate. That's a product change rather than a docs one, so it may belong with Unexpected Default EXECUTE Privileges on Functions in API Schema #43884.
Happy to open a PR for 1 and 2 if that's useful — say the word and I'll write it against the current MDX.
Activity
coderabbitai commentedon Jul 28, 2026
🔗 Related PRs
#42634 - docs: improve discoverability of custom schemas documentation [merged]
#47576 - fix: Rephrasing and improved output for framework quick starts instructions [merged]
#47952 - docs: clarify supabase_admin default privileges [merged]
#48157 - docs(realtime): schema restriction [merged]
#48308 - docs: note SELECT RLS needed for INSERT RETURNING via Data API [open]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
[-]Docs: RLS guide's GRANT examples are a no-op in , and TRUNCATE isn't covered by RLS[/-][+]Docs: the RLS guide's GRANT examples are a no-op in the public schema, and TRUNCATE is not covered by RLS[/+]docs: fix RLS guide for default grants and note TRUNCATE is outside RLS
docs: note TRUNCATE is outside RLS and review table grants in prod ch…
docs: review table grants and TRUNCATE in production checklist
docs: note that RLS does not apply to TRUNCATE
docs: restore full RLS guide and note TRUNCATE is outside RLS
docs: review table grants and TRUNCATE on the production checklist