1
0
Fork 0
fahrPool/supabase
Jonny 55c4ac5949 fix: gate auftraege RLS policies on user_role() to close readonly claim gap
Security review found two RLS gaps in the auftraege migration that exactly
followed the (flawed) plan:

- The fahrer UPDATE policy had no public.user_role() = 'fahrer' predicate,
  so any authenticated user -- including a readonly-role account (the
  default role for new signups) -- could self-assign any open order via
  the "status = 'offen'" branch of USING, since all app roles share the
  same Postgres role and only user_role() distinguishes them.
- The disponent/admin INSERT policy did not bind erstellt_von to
  auth.uid(), allowing a spoofed creator id on insert.

Adds public.user_role() = 'fahrer' to both USING and WITH CHECK on the
fahrer UPDATE policy, and erstellt_von = auth.uid() to the INSERT policy's
WITH CHECK. Column-level lockdown (fahrer changing abholort_id etc.) is
intentionally deferred to Task 4's trigger, not addressed here.

Verified behaviorally: with the pre-fix policy, a readonly-role user could
claim an open order (UPDATE 1); with the fix, the same attempt affects 0
rows. Migration amended in place since it was never applied outside this
local dev stack.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-05 11:27:27 +02:00
..
migrations fix: gate auftraege RLS policies on user_role() to close readonly claim gap 2026-07-05 11:27:27 +02:00
tests test: cover profiles UPDATE RLS boundary and privilege-escalation trigger 2026-07-05 00:45:27 +02:00
.gitignore feat: add profiles table, role enum and auto-create trigger 2026-07-04 11:30:13 +02:00
config.toml feat: add profiles table, role enum and auto-create trigger 2026-07-04 11:30:13 +02:00