Skip to content

fix(orchestrator): reject empty broker secrets, bound file uploads, and remove client casts - #1851

Merged
nikhilunni merged 3 commits into
mainfrom
audit/p0-orchestrator-security
Dec 2, 2026
Merged

nikhilunni merged 3 commits into
mainfrom
audit/p0-orchestrator-security

Conversation

@nikhilunni

@nikhilunni nikhilunni commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Hardens orchestrator/ security boundaries and removes duplicated auth/client boilerplate:

  • Credential broker empty-secret guard: bearerMatches() (orchestrator/src/routes/connection-credential-broker.ts) rejects an empty expected secret. CONNECTION_BROKER_BEARER still falls back to CONTROL_PLANE_BEARER when unset: the Helm chart gives the coordinator's ENGRAM_CONNECTION_BROKER_BEARER the CONTROL_PLANE_BEARER key, so a fail-closed default would stop the broker in every chart deployment.
  • Bounded file upload streaming: orchestrator/src/routes/session-files.ts stops the stream at the declared size (x-upload-size, else Content-Length), cancels the reader, and returns 413 Payload Too Large. A Content-Length above 512 MiB is rejected before the RPC starts. The guest writes to a temporary file and removes it on failure, so a stopped upload leaves no partial file.
  • Centralized auth helpers: Consolidates duplicated HTTP requireAdmin (admin, integration-op, integration-oauth, oidc-key-admin) into routes/guard.ts and the GetSession type into auth/types.ts. The 401/403 semantics are unchanged; admin-guard.test.ts checks each route.
  • Type safety: Removes 30 as unknown as <Client> double casts across rpc/ and routes/. The default Connect clients (createClient(...) in control-plane/client.ts) are now assigned directly to the existing narrow client interfaces, so the compiler checks each interface against the generated client.

Validation

  • bun run typecheck: passed.
  • Focused bun test suites (session files, broker, broker config, admin guard): passed.
  • git diff --check: passed.

🤖 Generated with Claude Code

nikhilunni and others added 3 commits December 1, 2026 11:59
The upload stream stopped only at the 512 MiB ceiling, so a request that
declared one byte still sent 512 MiB to the coordinator before the host
rejected it. The stream now stops at the declared size. A Content-Length
above the ceiling is also rejected before the RPC starts, even when
x-upload-size is small.

The guest writes to a temporary file and removes it when the upload
fails, so a stopped upload leaves no partial file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The warning ran only when NODE_ENV is "production". No shipped
deployment sets NODE_ENV (the Helm chart, the orchestrator image, and
Tilt do not), so the warning never ran. The Helm chart also cannot set a
dedicated broker bearer: it gives the coordinator's
ENGRAM_CONNECTION_BROKER_BEARER the CONTROL_PLANE_BEARER key. A warning
that fires there would tell operators to do what the chart cannot do.

The test now covers the fallback itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nikhilunni
nikhilunni marked this pull request as ready for review December 2, 2026 21:52
@nikhilunni
nikhilunni merged commit 82b433e into main Dec 2, 2026
28 checks passed
@nikhilunni
nikhilunni deleted the audit/p0-orchestrator-security branch December 2, 2026 21:52
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