Skip to content

security(#237): revoke excess anon grants and drop duplicate RLS policies - #249

Merged
ChristopherRotnes merged 1 commit into
masterfrom
fix/237-db-permissions-cleanup
May 15, 2026
Merged

ChristopherRotnes merged 1 commit into
masterfrom
fix/237-db-permissions-cleanup

Conversation

@ChristopherRotnes

Copy link
Copy Markdown
Owner

Summary

Part 1 — revoke excess anon privileges across all 14 public tables:

  • TRUNCATE — bypasses RLS at the PostgreSQL level; PostgREST never exposes it but the privilege was there
  • TRIGGER / REFERENCES — never used by PostgREST; pointless for the anon role
  • Standard SELECT/INSERT/UPDATE/DELETE grants untouched

Part 2 — drop legacy {public} ALL policies that are exact duplicates of later {authenticated} replacements:

  • "Trenere ser egne økter" on sessions
  • "Tilgang via session" on session_exercises
  • "Tilgang via session_exercise" on muscle_activations

The {public} copies never granted anon access in practice (every USING clause checks auth.uid(), which is null for unauthenticated requests), but they added evaluation overhead and policy-list noise. The {authenticated} replacements with identical USING clauses remain.

"Same-gym users can read sessions" ({public} SELECT) is intentionally kept — it has no {authenticated} duplicate and provides co-instructor cross-visibility.

Migration applied to production via Supabase MCP and verified with two spot-check queries.

Test plan

  • anon has no TRUNCATE/TRIGGER/REFERENCES on any public table (verified live)
  • Legacy {public} ALL policies dropped; {authenticated} replacements intact (verified live)
  • "Same-gym users can read sessions" still present

🤖 Generated with Claude Code

… RLS policies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ChristopherRotnes
ChristopherRotnes merged commit 86a5167 into master May 15, 2026
@ChristopherRotnes
ChristopherRotnes deleted the fix/237-db-permissions-cleanup branch May 15, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

As a developer I want excessive anon grants and redundant RLS policies cleaned up so I can enforce least-privilege DB access

1 participant