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)
| Threat | Surface | Mitigation | Why it works |
|---|---|---|---|
| Spoofing | /api/cron/* | Require CRON_SECRET header | Blocks random internet pings |
| Tampering | items, jobs tables | RLS + service-role writes only | Only workers can mutate |
| Repudiation | Ingestion pipeline | jobs table keeps a trail | Every fetch has an audit row |
| Information disclosure | Service keys | Server-only env vars, no client usage | Prevents accidental leaks |
| DoS | Twitter API limits | Backoff + caching inside twitter-fetch | We respect rate headers |
| Elevation | Cross-user access | Strict RLS policies (auth.uid() = user_id) | Tenants stay isolated |
AuthN/AuthZ matrix
| Operation | Actor | Guardrail |
|---|---|---|
Read /api/feed | Logged-in user | RLS confirms sources.user_id = auth.uid() |
| Manage sources | Owner | Insert/update/delete restricted by RLS |
| Bookmarks | Owner | All actions scoped to user_id |
| Gemini key storage | Owner | /api/ai/key writes into profiles.ai_settings |
| Ingestion writes | Service role | Edge Functions authenticate with service key |
Backups & migrations
- Backups — Supabase snapshots the database; we test restores quarterly.
- Migrations — Live in
supabase/migrations/. Usesupabase db resetlocally,supabase db pushin staging. We prefer roll-forward plans; no destructive drops without a backfill script.
Incident playbook (first 15 minutes)
- Triage — Check Vercel + Supabase status pages, then inspect
/api/cronlogs and Supabase Edge logs. - Contain — Pause cron by clearing
CRON_SECRETin Vercel if ingestion misbehaves. Roll back the last deploy withvercel rollback production. - Remediate — Re-run the job, patch the bug, update env vars if secrets leaked.
- 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.