Menu

New Supabase tables get privileges you never granted (and why ALTER DEFAULT PRIVILEGES needs FOR ROLE)
📰

New Supabase tables get privileges you never granted (and why ALTER DEFAULT PRIVILEGES needs FOR ROLE)

DEV Community: postgres·Masaru Nishino·1 day ago
#jsr34UDd
#devtopostgresql#devto#dev#privileges#role
Long article (943 words) — no AI summary yet.
Reading 0:00
15s threshold

Create a table in Supabase, and it may already have privileges for anon , authenticated and service_role . You never wrote a grant . They come from the default privileges of the role that created the table.

My client portal handled this the slow way: every migration revoked them, table by table. That works until one migration forgets. After a reader asked about it on a post about my RLS review , I tried to close the defaults instead. It took one migration, but two things surprised me on the way.

Why it matters (and why it's usually not a leak)

Privileges decide whether a role can touch a table at all. RLS decides which rows it sees. If RLS is enabled, extra privileges alone don't expose any rows.

The risk is the table where RLS was forgotten. Then the privileges are the only thing left, and they're already open. Closing the defaults means a forgotten grant fails loudly with "permission denied" instead of quietly working.

Step 1: read what new objects actually get

This is read-only.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.