Security & Reliability

A focused HUD is only as good as its guardrails. We lean on Supabase RLS, tight secrets hygiene, and a lightweight incident playbook to keep the signal clean.

Threat model (STRIDE-lite)

ThreatSurfaceMitigationWhy it works
Spoofing/api/cron/*Require CRON_SECRET headerBlocks random internet pings
Tamperingitems, jobs tablesRLS + service-role writes onlyOnly workers can mutate
RepudiationIngestion pipelinejobs table keeps a trailEvery fetch has an audit row
Information disclosureService keysServer-only env vars, no client usagePrevents accidental leaks
DoSTwitter API limitsBackoff + caching inside twitter-fetchWe respect rate headers
ElevationCross-user accessStrict RLS policies (auth.uid() = user_id)Tenants stay isolated

AuthN/AuthZ matrix

OperationActorGuardrail
Read /api/feedLogged-in userRLS confirms sources.user_id = auth.uid()
Manage sourcesOwnerInsert/update/delete restricted by RLS
BookmarksOwnerAll actions scoped to user_id
Gemini key storageOwner/api/ai/key writes into profiles.ai_settings
Ingestion writesService roleEdge Functions authenticate with service key

Backups & migrations

  • Backups — Supabase snapshots the database; we test restores quarterly.
  • Migrations — Live in supabase/migrations/. Use supabase db reset locally, supabase db push in staging. We prefer roll-forward plans; no destructive drops without a backfill script.

Incident playbook (first 15 minutes)

  1. Triage — Check Vercel + Supabase status pages, then inspect /api/cron logs and Supabase Edge logs.
  2. Contain — Pause cron by clearing CRON_SECRET in Vercel if ingestion misbehaves. Roll back the last deploy with vercel rollback production.
  3. Remediate — Re-run the job, patch the bug, update env vars if secrets leaked.
  4. Retro quickly — Document timeline, add tests or alerts, update the relevant ADR if the architecture shifts.

Tip Keep a shared “weird incidents” doc. Patterns jump out faster when you log the small stuff, too.