Skip to content

Docs: the RLS guide's GRANT examples are a no-op in the public schema, and TRUNCATE is not covered by RLS #48382

Open

Description

@siliroid

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

  1. In the RLS guide, note that public already carries default grants for anon/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;
  1. Add one line to the production checklist: review information_schema.role_table_grants for anon/authenticated, and note that RLS does not cover TRUNCATE.

  2. Optionally: TRUNCATE, REFERENCES and TRIGGER aren'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

  1. coderabbitai commented on Jul 28, 2026

    @coderabbitai
    Contributor
    🔗 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 plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 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:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. changed the title [-]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[/+] on Jul 28, 2026
  3. added
    external-issue
    on Jul 28, 2026
  4. added
    documentation
    pr-opened
    and removed on Jul 29, 2026
  5. added a commit that references this issue on Aug 2, 2026
    49ade4a
  6. added 5 commits that reference this issue on Sep 4, 2026
    51b7f6d
    925bf20
    d4f3f63
    36d0679
    fa4def9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationexternal-issuepr-opened

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions