Skip to content

sec: control-plane hardening batch (5 deepsec findings)#17

Merged
valvesss merged 1 commit into
mainfrom
sec/control-plane-hardening-batch
Jul 3, 2026
Merged

sec: control-plane hardening batch (5 deepsec findings)#17
valvesss merged 1 commit into
mainfrom
sec/control-plane-hardening-batch

Conversation

@valvesss

@valvesss valvesss commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Lote de fixes self-contained do control-plane (Svalinn/deepsec). Sem mudança de schema/data-plane; deploya com o container control-plane.

# Sev Fix Arquivo Card
eb871abc MED Comparação de token timing-safe (secretEqual/timingSafeEqual) nas 3 checagens (/v1, bypass skuld, /migrate) index.ts b87fd284
e1aba8d1 MED ident() no config.zeroDb (CREATE/ALTER DATABASE) zero.ts 78649811
56281121 BUG TOCTOU: pg_advisory_xact_lock + transação no provisionStorage storage.ts d62c24c2
41fb8f44 BUG storageExpected no gate allReady (auto-heal) lifecycle.ts 71d4dedc
502d50e7 BUG Comentário do apiKey corrigido (fail-closed, não "open") config.ts 822ea084

Verificação

  • tsc limpo (só erros pré-existentes de jobs.ts/pg-boss).
  • Teste de lógica 7/7: secretEqual (equal/diff/len/empty) + ident() (escapa " → injeção foo"; DROP... vira nome de DB, não executa).

Nota (TOCTOU)

O advisory lock resolve a corrida concorrente (2 callers mintando). Uma falha parcial (mint OK, UPDATE falha) ainda pode orfanar 1 chave — caso pré-existente e mais raro; a serialização cobre o que o finding pede.

Deploy

Não deployar agora. Acumula na main; rollout numa janela recriando SÓ o container control-plane (app hauldr = compose com o Postgres compartilhado). Junta com os Cards 1-2.

🤖 Generated with Claude Code

Batch of self-contained control-plane fixes flagged by the Svalinn/deepsec
scan. No schema or data-plane change; deploys with the control-plane container.

- Timing-safe bearer-token comparison (index.ts): replace the three bare
  `===`/`!==` token checks (global /v1 guard, Skuld enqueue bypass, /migrate
  handler) with a constant-time `secretEqual` (crypto.timingSafeEqual, length
  guarded). The /migrate path is the most exposed — it's the first guard a
  request hits after the middleware bypass. [MED eb871abc / card b87fd284]

- SQLi via unescaped identifier (zero.ts): wrap config.zeroDb with an ident()
  helper in the CREATE/ALTER DATABASE DDL, matching provision.ts. A stray `"`
  in HAULDR_ZERO_DB could otherwise break out of the identifier. [MED e1aba8d1
  / card 78649811]

- TOCTOU in provisionStorage (storage.ts): guard the read-check-mint-update
  with a transaction + pg_advisory_xact_lock(hashtext(name)) so two racing
  provisions of the same project can't both mint a Garage key (the loser's key
  would be orphaned with live bucket access, untracked, unrevokable). [BUG
  56281121 / card d62c24c2]

- storageReady excluded from auto-heal gate (lifecycle.ts): add storageExpected
  to the allReady conjunction so a project whose storage sidecar is still
  unhealthy isn't flipped to 'live' with services.storage.ready=false. [BUG
  41fb8f44 / card 71d4dedc]

- Misleading apiKey comment (config.ts): the middleware fails CLOSED (503) when
  HAULDR_API_KEY is empty; the comment said "Empty = open (dev only)". Fix the
  comment so nobody "restores" the documented-but-false open behaviour. [BUG
  502d50e7 / card 822ea084]

Deploy deferred: accumulate on main; roll out by recreating only the
control-plane container in a window (app 'hauldr' bundles the shared fleet DB).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@valvesss valvesss merged commit ee49048 into main Jul 3, 2026
2 checks passed
@valvesss valvesss deleted the sec/control-plane-hardening-batch branch July 3, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant