## Terminal Lifecycle Handler Faces Shell-Injection Audit Over Unsafe Command Interpolation
Security researchers have identified a shell-injection vulnerability pathway in the terminal command template used across the codebase. The issue centers on a shell-script string built for `pty.spawn` that directly interpolates user-controlled values — including worktree paths, branch names, and agent prompts — without escaping at the template stage. While the upstream `TerminalSpawnOptionsSchema.safeParse` provides baseline input validation, researchers warn that any future feature injecting context into the `command` field could re-introduce the injection risk, bypassing schema checks entirely.

The vulnerability emerges because the command template executes within a shell environment, placing interpolated values inside a shell script with no secondary quoting layer. Current audit efforts focus on tracing every call site that constructs the `command` field to confirm whether user inputs are properly rejected or shell-quoted before interpolation. The goal is to document explicit trust boundaries so contributors understand which inputs are safe to embed and which require sanitization.

Proposed remediation involves migrating the dominant use case — spawning agents within worktrees — to an array-args pattern paired with explicit `cwd` configuration. This approach bypasses shell interpolation entirely by passing arguments directly to the spawned process, eliminating the injection surface. The team faces the challenge of retrofitting existing call sites while maintaining backward compatibility and preventing regressions in edge-case workflows.

The issue raises broader questions about input-surface governance in high-privilege terminal subsystems. Without enforced discipline around shell quoting, new contributors or third-party integrations could inadvertently introduce vulnerabilities by adding context-injection features. The audit is framed as foundational work to establish clear security boundaries for the terminal lifecycle handler going forward.
---
- **Source**: GitHub Issues
- **Sector**: The Lab
- **Tags**: shell-injection, security-audit, pty.spawn, command-interpolation, terminal-spawn
- **Credibility**: unverified
- **Published**: 2026-04-28 20:54:13
- **ID**: 77943
- **URL**: https://whisperx.ai/en/intel/77943