Repository navigation
Description
Context
Several routes accept the static ADMIN_API_KEY as auth (synthetic user id admin_api_key, set by server/src/middleware/auth.ts:744-755). The most-exercised one is POST /api/organizations/:orgId/members/by-email (server/src/routes/organizations.ts:3008), used by internal tooling and incident scripts (e.g. scripts/incidents/2026-04-triton-promote-hayem.ts).
When the static admin key invokes one of these routes, audit log entries record:
workos_user_id: 'admin_api_key'inviter_email: 'admin-api-key@internal'- the route + verb
That tells us the static key was used but not which operator or script used it. If the key ever leaks, we can't trace which client owned the breach.
Proposal
For every static-admin-gated mutation, enrich the audit details field with:
req.ip(or first hop ofX-Forwarded-Forwhen behind Fly's edge).- A non-reversible fingerprint of the key —
sha256(ADMIN_API_KEY).slice(0, 8)— so rotations show up as a fingerprint change in the log without exposing the key. - An optional operator-supplied
X-Admin-Operatorheader echoed verbatim intodetails.operator. Internal scripts (the incident scripts inscripts/incidents/) already know who's running them; teach them to set the header.
This is a cross-cutting hardening — affects every static-admin-gated route, not just by-email. Surfaced by security-reviewer in PR #4207.
Out of scope
- Rotating or revoking the existing key (separate ops task).
- Changing the auth model to require human-in-the-loop (rejected during the same review — break-glass scripts need the static path).
Files to touch
server/src/middleware/auth.ts— add fingerprint helper, attachreq.adminKeyFingerprintalongsidereq.isStaticAdminApiKey.- All routes that gate on
isStaticAdminApiKey(grepisStaticAdminApiKey) — record fingerprint + IP + operator header in theirrecordAuditLogcalls. scripts/incidents/*— setX-Admin-Operatorso we know which script ran.
Activity
bokelley commentedon May 8, 2026
Triage
Classification: Security hardening
Bucket(s): security-sensitive, admin / ops tools
Status: deferred (fold candidate — blocked on #4207)
Structural call: All three proposed file touches (
auth.ts,isStaticAdminApiKeyroutes,scripts/incidents/*) overlap directly with the open PR #4207 diff (auth.ts+ the synthetic-user path are already in scope there). Folding this before #4207 merges avoids re-opening the same files in a follow-up and keeps the audit-enrichment paired with the WorkOS invite fix that exposed the gap.Security notes for whoever implements:
X-Admin-Operatorechoed verbatim into auditdetails→ sanitize before writing (strip newlines and control chars) to prevent log injection from a caller who holds the key.req.ip(Expresstrust proxy) over parsingX-Forwarded-Fordirectly; confirm which headerreq.ipresolves to under the Fly edge config — Fly setsfly-client-ipas the authoritative first-hop.Blocked-on: #4207 — resurfaces on merge
Triaged by Claude Code. Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
Generated by Claude Code
bokelley commentedon Sep 21, 2026
Archive review: the recorded blocker #4207 merged on 2026-05-08. Verify the shipped static-admin audit coverage against this follow-up; close if satisfied, otherwise replace the fold-candidate note with the remaining exact gaps. /triage