Skip to content

Permissive festival-assets storage policies bypass admin-only restriction #36

@chiptus

Description

@chiptus

Problem

The festival-assets storage bucket has two conflicting sets of RLS policies on storage.objects:

  • supabase/migrations/20250811140000_add_festival_logo.sql creates INSERT/UPDATE/DELETE policies gated only on auth.role() = 'authenticated' (any logged-in user can write to the festival-logos folder).
  • supabase/migrations/20250827000000_add_festival_edition_metadata.sql later adds INSERT/UPDATE/DELETE policies gated on is_admin(auth.uid()).

Postgres combines permissive RLS policies with OR. The policy names differ, so both sets coexist — and a non-admin authenticated user still satisfies the earlier permissive policy. The intended admin-only restriction is effectively bypassed: any authenticated user can upload/update/delete festival logo assets.

Suggested fix

Add a migration that DROPs the three permissive write policies from 20250811140000_add_festival_logo.sql:

  • "Allow authenticated users to upload festival logos"
  • "Allow users to update their festival logos"
  • "Allow users to delete festival logos"

Keep the public-read policy (it matches the later "Anyone can view festival assets"). Also prefer role scoping (TO authenticated) + admin checks over auth.role() going forward.

Context

Flagged by Copilot review on PR #34. Pre-existing issue, not introduced by that PR — tracking separately since it is a security change rather than a db-sync change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions