Summary
Multiple API routes accept request bodies without Zod schema validation, relying on manual type checking that is inconsistent and incomplete.
Details
Routes missing Zod validation
POST /v1/auth/keys — name and rateLimit extracted without schema. Negative rateLimit accepted.
POST /v1/sessions/:id/send — text checked for truthiness but not typed
POST /v1/sessions/:id/command — command not schema-validated
POST /v1/sessions/:id/bash — same as command
POST /v1/sessions/:id/screenshot — fullPage, width, height passed through without validation
POST /v1/sessions/:id/hooks/permission — no body validation at all
POST /v1/sessions/:id/hooks/stop — no body validation at all
POST /v1/sessions/batch — manual array/type checking instead of Zod
POST /v1/pipelines — manual validation instead of Zod
Other validation gaps
ws-terminal.ts:182-206 — WebSocket resize accepts unbounded cols/rows values
mcp-server.ts:39-48 — workDir uses substring matching via includes() instead of exact/prefix
mcp-server.ts:51-53 — session IDs not validated as UUID format before URL construction
config.ts:161-168 — parseInt on env vars never checked for NaN
server.ts:1185-1186 — zombieReapDelayMs accepts NaN from env vars
cli.ts:186-189 — port not validated before setting env var
No batch session limit
POST /v1/sessions/batch accepts an unbounded array. An authenticated user could pass 10,000 specs, exhausting system resources.
Suggested Fix
- Define Zod schemas for all request bodies, use `safeParse` consistently
- Clamp viewport dimensions: `cols = Math.max(1, Math.min(cols, 1000))`
- Use exact UUID regex for session IDs in MCP server
- Add `isNaN`/`isFinite` checks after all `parseInt` calls on config
- Cap batch size at 50
Summary
Multiple API routes accept request bodies without Zod schema validation, relying on manual type checking that is inconsistent and incomplete.
Details
src/server.tsRoutes missing Zod validation
POST /v1/auth/keys—nameandrateLimitextracted without schema. NegativerateLimitaccepted.POST /v1/sessions/:id/send—textchecked for truthiness but not typedPOST /v1/sessions/:id/command—commandnot schema-validatedPOST /v1/sessions/:id/bash— same as commandPOST /v1/sessions/:id/screenshot—fullPage,width,heightpassed through without validationPOST /v1/sessions/:id/hooks/permission— no body validation at allPOST /v1/sessions/:id/hooks/stop— no body validation at allPOST /v1/sessions/batch— manual array/type checking instead of ZodPOST /v1/pipelines— manual validation instead of ZodOther validation gaps
ws-terminal.ts:182-206— WebSocket resize accepts unboundedcols/rowsvaluesmcp-server.ts:39-48—workDiruses substring matching viaincludes()instead of exact/prefixmcp-server.ts:51-53— session IDs not validated as UUID format before URL constructionconfig.ts:161-168—parseInton env vars never checked for NaNserver.ts:1185-1186—zombieReapDelayMsaccepts NaN from env varscli.ts:186-189— port not validated before setting env varNo batch session limit
POST /v1/sessions/batchaccepts an unbounded array. An authenticated user could pass 10,000 specs, exhausting system resources.Suggested Fix