-
Notifications
You must be signed in to change notification settings - Fork 8.7k
[Security] telemetry-ingest uses service role key — bypasses RLS unnecessarily #675
Description
Summary
supabase/functions/telemetry-ingest/index.ts:46-49 — The edge function creates a Supabase client with SUPABASE_SERVICE_ROLE_KEY, which bypasses Row Level Security entirely. This is unnecessary — RLS policies already allow anon INSERT and SELECT on telemetry_events, plus INSERT/SELECT/UPDATE on installations (for upsert).
Using the service role key means any caller (even without proper credentials) gets unrestricted database access through this endpoint, enabling telemetry data poisoning.
Impact
Medium — permits unauthenticated telemetry poisoning and write amplification. The service role key bypass is unnecessary given existing RLS policies.
Fix
PR #664 replaces the service role key with the caller-provided apikey header (anon key). Returns 401 if the header is missing. RLS enforces access control. The client (bin/gstack-telemetry-sync) already sends the anon key — no client changes needed.
Found via sqry AST-based semantic code graph analysis.