Summary
A command injection vulnerability in PraisonAI's shell() helper validates only the first whitespace-delimited token while passing the entire input to a system shell. If an attacker can influence the helper's command argument, they may append shell syntax that executes arbitrary commands with the PraisonAI process privileges.
Affected context
The issue occurs in PraisonAI deployments using the affected TypeScript utility-tools shell() helper. Risk is present when untrusted or insufficiently constrained input can reach the helper and the process invokes a shell with the complete command string after checking only its initial token.
Exploit preconditions
- Attack surface: The PraisonAI TypeScript utility-tools shell() helper
- Required access: Ability to influence the command string supplied to the helper
- Trigger point: Execution of the constructed command through Node.js child_process.exec()
- Why exploitation is possible: Validation covers only the first token, while the complete original string is interpreted by a shell
Why this happens
The underlying bug is incomplete command validation combined with shell-based execution. Checking whether only the first token belongs to an allowlist does not constrain later shell operators or additional commands, and passing the original string to child_process.exec() leaves those elements available for interpretation. This maps primarily to CWE-78, OS Command Injection, with related concerns involving insufficient enforcement of security controls and authorization checks.
Potential impact
- An attacker may execute arbitrary operating-system commands
- The application process and its accessible files or secrets could be compromised
- Sensitive data could be read, modified, or exfiltrated
- The vulnerable process could be used for lateral movement or persistence
- Service availability could be disrupted
General mitigation guidance
Mitigation generally focuses on removing shell interpretation from
security-sensitive execution paths.
Common defensive patterns include:
- Prefer direct process-spawning APIs that accept an executable and separate argument array
- Use strict allowlists for complete commands and structured arguments rather than validating only a command prefix
- Treat all externally influenced command values as untrusted
- Avoid interpolating user-controlled data into command strings
- Apply least-privilege permissions, restricted environment variables, and sandboxing to the executing process
- Enforce authorization and policy checks before command execution
How teams detect issues like this
Detection approaches may include:
- Static analysis rules identifying child_process.exec() or equivalent shell-enabled APIs
- Searches for allowlist checks applied only to prefixes, tokens, or command names before full-string execution
- Code review checks for string concatenation or interpolation in process-execution calls
- Runtime logging and policy enforcement for unexpected command arguments or shell metacharacters
- Automated security review tools that flag shell execution with data-flow from untrusted inputs

