security: CAPA privilege escalation, CSV injection, AI rate-limit, prompt injection guard, open redirect, timing-safe cron secret, server-only admin client, notifications RLS

This commit is contained in:
2026-07-12 17:33:58 +08:00
parent c0ec6660ef
commit c80091c8d6
7 changed files with 49 additions and 6 deletions
@@ -0,0 +1,10 @@
-- Fix: notifications_log RLS was allowing any hse/admin to read ALL notifications.
-- Replace with per-user policy (everyone reads own) + admin-only policy for oversight.
DROP POLICY IF EXISTS "notifications_read_elevated" ON notifications_log;
CREATE POLICY "notifications_read_own" ON notifications_log
FOR SELECT USING (recipient_user_id = auth.uid());
CREATE POLICY "notifications_read_admin" ON notifications_log
FOR SELECT USING (auth_user_role() = 'admin');