From 047da755aac25207a3be6d17ca209eabface1186 Mon Sep 17 00:00:00 2001 From: rouges78 Date: Thu, 26 Nov 2026 23:16:23 +0100 Subject: [PATCH] Close the open DELETE policy on forum_reactions "Community delete reactions" (20260627) let anyone holding the anon key delete any reaction, so other people's likes could be wiped. It is no longer needed: inserting a reaction already requires a signed-in user with user_id = auth.uid(), and "Author delete reactions" covers the app's unlike path (toggleLike deletes the row found by the user's uid). Already applied to the live gamestringer-community project. Co-Authored-By: Claude Opus 5.5 --- .../20261126090000_close_reactions_delete.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 supabase/migrations/20261126090000_close_reactions_delete.sql diff --git a/supabase/migrations/20261126090000_close_reactions_delete.sql b/supabase/migrations/20261126090000_close_reactions_delete.sql new file mode 100644 index 00000000..f6ec5d18 --- /dev/null +++ b/supabase/migrations/20261126090000_close_reactions_delete.sql @@ -0,0 +1,15 @@ +-- ════════════════════════════════════════════════════════════════════════════ +-- forum_reactions: niente più DELETE aperta a chiunque — 2026-11-26 +-- ════════════════════════════════════════════════════════════════════════════ +-- 20260627 aveva aggiunto "Community delete reactions" (USING user_id IS NOT NULL, +-- ruolo public) per far togliere il like agli utenti community anonimi. Effetto: +-- con la anon key chiunque poteva cancellare QUALSIASI reazione, quindi azzerare +-- i like altrui. +-- +-- Non serve più: l'INSERT richiede già il login con user_id = auth.uid() +-- ("Authenticated insert reactions"), quindi un anonimo non può mettere un like, +-- e "Author delete reactions" (user_id = auth.uid()) copre il "togli like" +-- dell'app (lib/social/forum.ts, toggleLike: cancella la riga trovata per uid). +-- Idempotente. + +DROP POLICY IF EXISTS "Community delete reactions" ON public.forum_reactions;