background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

fix(types): validate session boundary payloads

Open open-inspect opened this issue 5 months ago • 3 comments

This is an automated nightly unsafe-cast remediation sweep. It fixes three high-risk control-plane/session trust-boundary casts by parsing instead of asserting, following the TypeScript Coding Standards guidance for unsafe casts and the Zod boundary-validation pattern established in PR #807.

Finding Risk Cast removed Fix
packages/control-plane/src/session/http/handlers/messages.handler.ts:47 HIGH (await request.json()) as EnqueuePromptRequest Added local Zod enqueuePromptRequestSchema and safeParse; invalid bodies return the existing bad-request style response.
packages/control-plane/src/session/http/handlers/sandbox.handler.ts:146 HIGH (await request.json()) as AddParticipantRequest plus role assertion Added local Zod addParticipantRequestSchema with owner/member role validation; invalid bodies return 400.
packages/control-plane/src/session/event-stream.ts:91 HIGH JSON.parse(row.data) as SandboxEvent bypassing existing schema Reused shared sandboxEventSchema.safeParse; invalid persisted replay/history rows are skipped, matching existing malformed-row behavior.

Verification:

Command Result
npm run build -w @open-inspect/shared Passed
npm run build -w @open-inspect/control-plane Passed
npm run typecheck Passed
npm run lint Passed after temporarily moving unrelated untracked .opencode/ out of the workspace; the command failed before that only because .opencode/ is untracked local tooling and not part of this PR.
npm run lint -w @open-inspect/control-plane Passed
npm run format Passed
npm test -w @open-inspect/control-plane -- src/session/http/handlers/messages.handler.test.ts src/session/http/handlers/sandbox.handler.test.ts src/session/event-stream.test.ts Passed
npm test -w @open-inspect/control-plane Passed

Created with Open-Inspect

open-inspect avatar Jul 03 '26 06:07 open-inspect

Terraform Validation Results

Step Status
Format ✅
Init ✅
Validate ✅

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @open-inspect[bot], Action: pull_request

github-actions[bot] avatar Jul 03 '26 06:07 github-actions[bot]

Terraform Validation Results

Step Status
Format ✅
Init ✅
Validate ✅

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @ColeMurray, Action: pull_request

github-actions[bot] avatar Jul 08 '26 06:07 github-actions[bot]

Terraform Validation Results

Step Status
Format ✅
Init ✅
Validate ✅

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @ColeMurray, Action: pull_request

github-actions[bot] avatar Jul 08 '26 06:07 github-actions[bot]