Spaces:
Sleeping
Sleeping
Commit History
-
Security hardening: RLS-as-user, rate limiting, headers, PII + endpoint cleanup
Tengo Gzirishvili +1: Claude Opus 4.8Defense-in-depth pass so a single mistake or leak can't expose user data: - RLS enforcement: per-user reads/writes now run AS THE USER (anon apikey + the requester's verified JWT) so Postgres RLS enforces row isolation — a forgotten user_id=eq. filter can no longer leak another user's rows. New _user_pgrst_headers() with graceful fallback to the service key when SUPABASE_ANON_KEY is unset (reversible rollout). Background workers and the genuine cross-user aggregates keep the service key. - user_id chokepoint: reject any JWT whose `sub` isn't a UUID (closes PostgREST filter-injection via a crafted sub at the single entry point). - Rate limiting: in-process per-(client,rule) sliding window on /api/* with 429 + Retry-After; bounded memory, fail-open, env escape hatch. - Security headers: X-Content-Type-Options, Referrer-Policy, Permissions-Policy, HSTS, and CSP frame-ancestors allowlisting turingdna.com (iframe-safe). - PII minimization: store only a /24-anonymized IP + s…702b153