Security Checklist
Operational security posture for a Spine deployment — what the platform already enforces, and the surfaces you must keep an eye on yourself. Related reading: Auth & API Keys, Permissions, Environment Variables.
Secrets that must stay server-side
SUPABASE_SERVICE_ROLE_KEYbypasses RLS entirely. It is read only by functions and the CLI (adminDbin.framework/functions/_shared/db.ts) and must never appear under aVITE_*name —VITE_*vars are compiled into the public browser bundle. Older docs recommendedVITE_SUPABASE_SERVICE_ROLE_KEY; that is an anti-pattern the audit flagged (S-004). If it ever shipped, rotate the key.netlify.tomlSECRETS_SCAN_OMIT_KEYSwhitelists only vars that are meant to be public (VITE_SUPABASE_URL,VITE_SUPABASE_ANON_KEY,APP_BASE_URL,SITE_URL, …). Do not add secrets to it.INTERNAL_INVOKE_SECRET,SCHEDULER_API_KEY,RESEND_API_KEY,OPENAI_API_KEY,NETLIFY_ACCESS_TOKEN— server-side Netlify env only..envis gitignored and excluded from the shipped file set; no framework command writes it (see Project Map).
API key hygiene
- Keys mint as
sk_<uuid>; onlykey_prefix(first 8 chars) and apbkdf2$<iters>$<salt>$<hash>value (100k iterations, SHA-256,timingSafeEqualverify) are stored (.framework/functions/api-keys.ts,.framework/functions/_shared/hash-api-key.ts). The raw key is returned once asraw_key;omitSecretFieldsstripskey_value/key_hashfromlist,get, andrevokeresponses. - Grant scopes, not
*:*. A machine key with*:*resolves to thesystem_adminrole and effectively becomes an RLS-immune superuser (.framework/functions/_shared/principal.ts).is_internalkeys are for platform machinery. - Every key has a rate limit (default
100/60s) plus a per-IP ceiling (SPINE_IP_RATE_LIMIT, default300/60s); usage lands inapi_key_usage_logs— read via/api/api-keys?action=usage-logsbefore revoking so you see what the key touched. - Revoke, don't delete:
POST /api/api-keys?action=revokesetsis_active=false. Auditapi_keysrows for a non-nullkey_valuecolumn — a legacy column that can hold plaintext (the S-001 incident class); nothing in_sharedreads it, butselect('*')surfaces used to return it.
Credential sanitization
- Integration credentials resolve server-side only:
credentials.<field>.source = 'env_var'readsprocess.envinside the function (.framework/functions/_shared/resolve-credentials.ts); literalvalueentries are stored inintegrations.credentials— treat that column as secret. integrationsis a second-surface table: non-system-admin and machine reads are sanitized to minimal fields by.framework/functions/_shared/permissions.ts.- Outbound stage configs (
http_request) reference thegeneric-httpintegration — credentials live on the integration row, never in the pipeline stage JSON.
Ban / blocklist surface
/api/security (.framework/functions/security.ts) is gated by requireSystemContextWithAudit — system-admin only. Actions: flagged_accounts, ban_user, unban_user, blocklist, blocklist_add, blocklist_revoke. A ban is three layers:
security_blocklistrows (person/email/account/IP) — the authoritative layer; enforced per-request increateHandler(isBlockedRequest) and on public endpoints (isBlockedIp).- Supabase Auth ban (
auth.admin.updateUserById, ~100yban_duration). - Netlify edge deny rule
spine-security:blocklist— only whenNETLIFY_ACCESS_TOKEN+NETLIFY_SITE_IDare set; skipped silently otherwise (auth/edge failures are audited, not thrown).
Caveat: blocklist enforcement fails open when security_blocklist is absent (pre-049 installs) — a missing table means no blocking, not an error.
Signup & first-run surface
- First-registrant claim window.
handle_new_auth_usergrantssystem_adminto a new registrant only whenpublic.peopleis empty — the first person to register claims the instance. On a public deployment, runnpx spine-framework bootstrapbefore the site is reachable (or disable public signup), or the first stranger who finds/registerowns the instance. See Install and first run. - Post-bootstrap registration is safe to leave on. With
peoplenon-empty, subsequent registrants land unplaced/pending — no privilege. Verify once by registering a second user and checking its role. - Turnstile is conditional.
VITE_TURNSTILE_SITE_KEYunset → auth pages render with no widget; set → the widget enforces on register/login. Confirm both states at least once per environment — a site key set without the secret (or vice versa) silently degrades to the unset behavior. - Headless access is
x-api-key, not cookies.x-api-key: <SPINE_API_KEY>authenticates/api/*for machine callers — no Turnstile, no session. Scope it (never*:*); the full discipline is in "API key hygiene" above.
Endpoint exposure notes
debug-auth(/api/debug-auth) is gated by any authenticated principal, not system-admin — it reports principal type andSET/NOT_SETenv flags. Diagnostic, not product surface; consider whether it belongs in a hardened production deploy (see debug-auth)./api/system(manifest,health,openapi) likewise answers any authenticated principal — the OpenAPI spec and manifest are not admin-only information.- Public endpoints (
invites,integration-routes, registration flows) run throughcreatePublicHandler— anonymous by design; their abuse controls are IP blocklist, rate limits, and Turnstile, not auth.
Known ungated surfaces
Honest list — the audit found these; mitigate by key discipline until they are tightened:
logs?action=cleanupusesctx.dbwith noisSystemAdmincheck and no account scoping (.framework/functions/logs.ts). Machine principals getadminDbfromgetPrincipalDb— so any valid API key can delete log rows across all accounts. Mitigation: issue machine keys narrowly, watchapi_key_usage_logs, rotate on suspicion.api-keyslist/getselect*viaadminDbfor system admins — andctx.dbis alsoadminDbfor machine principals, so a scoped machine key readsapi_keysmetadata cross-account (api_keysrows are stripped ofkey_value/key_hash, but slugs, integration links, rate limits, and scopes are visible).- Function-level RLS is uneven — mutating handlers branch
isSystemAdmin ? adminDb : ctx.db; a scoped machine key still getsadminDb, so "machine keys are always RLS-bounded" is not a safe assumption anywherectx.dbis used without an explicit account filter. pipelines,ai_agents,prompt_configs, andembeddingswrites are ungated for humans — their mutating handlers branchisSystemAdmin ? adminDb : ctx.dbwith no engine check, so any account member — not justsystem_admin— can create/modify/delete these config objects via/api/*, bounded only by account-scoped RLS.timers/triggershad this same shape until decision0026(handler gates + migration081); the remaining tables are not yet adjudicated, so treat their writes as tenant-writable, not admin-only.timersandtriggerswrites are enforced (fixed by decision0026): mutating handlers callcanAccessConfigObject—system_adminonly — and migration081replaced the account-scopedFOR ALLpolicies with account-scoped read + system-admin write, so direct PostgREST matches the API. Kept here as context for the residual surfaces above.
Checklist
- [ ] No
VITE_-prefixed secret anywhere; service-role key server-only. - [ ]
INTERNAL_INVOKE_SECRET,SCHEDULER_API_KEY,APP_BASE_URLset;SITE_URLpinned to the real origin for CORS. - [ ] Machine keys carry least-privilege scopes (never
*:*for third parties), rate limits, and expiry where possible. - [ ]
api_keysrows audited for legacykey_valueplaintext. - [ ] Blocklist tested end-to-end (a banned IP gets 403); Netlify edge sync env vars set if edge bans are wanted.
- [ ]
debug-authand/api/systemexposure reviewed for the environment. - [ ] Machine-principal surfaces above understood —
ctx.db= service role for machines.