fix(security): restrict terminal shell to platform allowlist (#5479)#6071
fix(security): restrict terminal shell to platform allowlist (#5479)#6071CVE-Hunter-Leo wants to merge 1 commit into
Conversation
…#5479) Add shell allowlist to resolveShell() so client-supplied shell values are validated against a platform-specific set of known binaries before being passed to pty.spawn(). - Posix: /bin/bash, /bin/sh, /bin/zsh, /bin/fish, /bin/dash and /usr/bin/ equivalents - Win32: powershell.exe, pwsh.exe, cmd.exe (case-insensitive) - Non-allowlisted values are silently dropped; falls through to env/default - Prevents arbitrary process execution via POST /api/projects/:id/terminals - Adds regression tests covering allowlist acceptance, arbitrary command rejection, path traversal, and platform-specific behavior Closes nexu-io#5479
|
Thanks @CVE-Hunter-Leo — good call tightening the shell gate inside Before pool review picks this up, could you add the missing Surface area and Validation sections to the PR body? The Summary/Changes content is already useful; what's still missing is a quick note on which user-facing/runtime surface this affects and what you ran to verify the allowlist behavior. Because this touches terminal startup behavior, we'll also put it through a manual QA pass before merge.
|
Summary
Adds a platform-aware shell allowlist to resolveShell() so client-supplied shell values on POST /api/projects/:id/terminals are validated before being passed to pty.spawn().
Before: any non-empty string from the client was passed directly to the PTY spawn, allowing arbitrary process execution as the daemon user (CWE-78).
After:
Changes
Surface area
This change affects the daemon terminal subsystem specifically:
POST /api/projects/:id/terminals(the terminal create endpoint)resolveShell()inapps/daemon/src/terminals.tsshellfield in the terminal create bodyValidation
pnpm --filter @open-design/daemon test -- terminals-shell-allowlist— all 7 test cases pass{"shell": "/bin/bash"}→ terminal spawns with bash ✓{"shell": "/tmp/evil"}→ terminal spawns with default shell (not evil) ✓{"shell": "/bin/bash; rm -rf /"}→ terminal spawns with default shell (exact match blocks injection) ✓shellfield → resolves from SHELL env as before ✓{"shell": "powershell.exe"}accepted,{"shell": "calc.exe"}dropped ✓Closes #5479