Knowledge > Runbooks > Technical Ops > Respond to a Security Incident
Respond to a Security Incident
Contain, assess, and recover from a security incident such as an exposed API key, unauthorized database access, or credential compromise.
Prerequisites
- Access to all CLIs:
vercel,stripe, Supabase dashboard STRIPE_LIVE_SECRET_KEYfromknowledge/.envfor live mode operations- Ability to rotate keys in each service's dashboard
Incident Types
| Type | Immediate Action |
|---|---|
| Exposed API key (committed to git, logged, etc.) | Rotate the key immediately — do NOT wait |
| Unauthorized admin session | Invalidate sessions in church_admin_sessions |
| Suspected SQL injection | Check Supabase logs, assess data exposure |
| Exposed PII (church or parishioner data) | Assess scope, notify founder, prepare notification |
| Vercel env var exposed in logs/errors | Rotate the exposed secret |
Steps
Phase 1: Contain (Do Immediately)
-
Identify which secret or credential is exposed
Common secrets across the portfolio:
SUPABASE_SERVICE_ROLE_KEY— widest access, rotate firstSTRIPE_SECRET_KEY(test or live)STRIPE_WEBHOOK_SECRETANTHROPIC_API_KEYOPENAI_API_KEYRESEND_API_KEYTWILIO_AUTH_TOKENNEXT_PUBLIC_SUPABASE_ANON_KEY— lower risk (public), but still rotate
-
Rotate the exposed key immediately
Supabase service role key:
- Supabase Dashboard → Project Settings → API → Regenerate service role key
- Update Vercel:
echo "new-key" | vercel env add SUPABASE_SERVICE_ROLE_KEY production - Repeat for all three Vercel projects that use it
Stripe secret key:
- Stripe Dashboard → Developers → API keys → Roll key
- Update Vercel:
echo "sk_live_..." | vercel env add STRIPE_SECRET_KEY production
Webhook secret:
- Stripe Dashboard → Developers → Webhooks → endpoint → Reveal signing secret → Roll
- Update Vercel:
echo "whsec_..." | vercel env add STRIPE_WEBHOOK_SECRET production
Other API keys:
- Regenerate in the respective service dashboard
- Update in Vercel immediately after
-
Redeploy affected projects to pick up rotated keys
cd /c/dev/churchwiseai-web && vercel --prodcd /c/dev/pewsearch/web && vercel --prodcd /c/dev/sermon-illustrations && vercel --prod
Phase 2: Assess Scope
-
Check for unauthorized admin sessions
SELECT id, church_id, created_at, last_active, ip_addressFROM church_admin_sessionsWHERE created_at > now() - interval '7 days'ORDER BY created_at DESC;If any sessions appear unauthorized (unfamiliar IP, unexpected church_id):
-- Invalidate specific suspicious session (get founder approval first)DELETE FROM church_admin_sessions WHERE id = 'suspicious-session-id'; -
Check Supabase logs for suspicious queries
Supabase Dashboard → Logs → API logs → filter by timeframe and look for:
- Unexpected high volume from a single IP
- Queries targeting sensitive tables (
premium_churches,church_admin_sessions) - SQL patterns that suggest injection attempts
-
Assess data exposure
If unauthorized access may have read sensitive data, identify which tables were accessible with the exposed key:
SUPABASE_SERVICE_ROLE_KEY→ all tables (RLS bypassed)SUPABASE_ANON_KEY→ tables with public RLS policies only- Application API key → only what the API routes expose
Phase 3: Remediate and Notify
-
Fix the root cause
If a key was committed to git:
# Remove from git history if recently committedgit log --oneline -10 # find the commit# Inform founder — git history rewriting on shared branches requires coordinationIf a key appeared in logs:
- Find the code path that logged it
- Fix the logging statement
- Deploy the fix
-
Notify affected customers if PII was exposed
If any parishioner PII (prayer requests, contact info, visitor data) may have been accessed:
- Add an item to
FOUNDER_ACTIONS.mdwith severity P0 - Draft customer notification email for founder review
- Do NOT send notifications without founder approval
- Add an item to
-
Document in DECISION_LOG.md
- 2026-03-25: Security incident — [type]. Rotated [key names]. [Brief scope assessment]. [Customers affected: Y/N].
Verification
- New keys are active in all Vercel projects (test with a lightweight API call)
- No new unauthorized sessions appear in
church_admin_sessions ops_error_reportsshows no auth-related errors from the rotated keys- Old keys are fully revoked in service dashboards (test that old key returns 401)
See Also
- Error Log Triage Runbook
- Deployment: Env Var Rotation
FOUNDER_ACTIONS.md— FA-010 key rotation checklist