Summary
PraisonAI's SubprocessSandbox previously invoked subprocess.run() with shell=True and relied on a string-based blocklist to filter dangerous commands.
Because sh and bash were not blocked as standalone executables, an attacker could trivially bypass STRICT mode restrictions and execute arbitrary shell commands, leading to high-impact system compromise wherever untrusted input reached the sandbox.
Affected context
This vulnerability affects installations of PraisonAI that:
- Use the SubprocessSandbox component in any mode (BASIC, STRICT, or NETWORK_ISOLATED), and
- Allow agent tools, plugins, or user-provided prompts/configuration to influence commands passed into the sandbox, and
- Run PraisonAI in an environment where the worker process has meaningful OS-level capabilities (file system access, network access, or privileged helpers).
In such setups, the sandbox is expected to restrict or sanitize commands, but the underlying shell invocation behavior undermines these assurances.
Exploit preconditions
- Attack surface: The API or internal interfaces that cause PraisonAI's SubprocessSandbox to execute system commands (e.g., tools, agents, scripts, or prompt-driven actions).
- Required access: Ability to influence or control the command string (or parts of it) that is passed into SubprocessSandbox; this may be via direct API input, task configuration, or higher-level abstractions within PraisonAI.
- Trigger point: Execution flows that call subprocess.run(..., shell=True, ...) within SubprocessSandbox, particularly in STRICT mode where a strong sandbox is assumed.
- Why exploitation is possible: The sandbox depends on a blocklist that excludes direct shell invocations (sh, bash) while still using shell=True. Attackers can craft inputs like
sh -c '<command>'that pass blocklist checks yet are interpreted by the shell, enabling arbitrary command execution.
Why this happens
The core issue is a mismatch between the intended security boundary and the underlying process execution model. SubprocessSandbox uses Python's subprocess.run() with shell=True, which delegates command parsing and execution to a system shell, inherently expanding the attack surface for command injection.
Instead of enforcing a strict allowlist or using argument-based invocation, the implementation uses string-pattern blocklisting to detect "dangerous" commands. Because the blocklist is necessarily incomplete and did not include shell entry points such as sh or bash, attackers can invoke a shell explicitly and run arbitrary commands. This maps directly to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where untrusted input is assembled into a shell command that is executed without robust, structural isolation.
Potential impact
- Execution of arbitrary OS commands within the PraisonAI runtime environment
- Reading, modifying, or deleting sensitive files accessible to the PraisonAI process
- Abuse of the host's network stack for data exfiltration, lateral movement, or service abuse (where network is available)
- Installation or execution of additional malware or backdoors under the PraisonAI process identity
- Circumvention of expected sandbox and STRICT-mode safety guarantees, undermining trust in multi-agent workflows
General mitigation guidance
Effective mitigation focuses on removing reliance on shell parsing and fragile blocklists:
- Prefer shell=False with subprocess.run(), passing the executable and arguments as a list to avoid shell interpretation of user-controlled data.
- Replace blocklist-based filtering with allowlist-based command policies, explicitly defining which binaries and argument patterns are permitted.
- Introduce a clear separation between trusted configuration and untrusted user/agent input, ensuring untrusted data cannot directly shape command strings or arguments without validation.
- Implement least-privilege execution for the PraisonAI worker processes (reduced OS permissions, sandboxed containers, and constrained filesystem/network access), limiting damage if a sandbox escape occurs.
- Where shell semantics are absolutely required, use specialized libraries or wrappers that enforce controlled subsets of allowed commands instead of arbitrary shell execution.
How teams detect issues like this
Detection typically combines code-level analysis with behavioral monitoring:
- Static analysis or manual code review to flag any use of subprocess.run(), subprocess.Popen(), or similar APIs with shell=True, especially in security-sensitive modules such as "Sandbox", "Executor", or "Runner".
- Search for and scrutinize string-based blocklists or regex filters around command execution logic; they are strong indicators of fragile protection that may be bypassed.
- Configure CI/CD pipelines to enforce linting or policy rules that disallow shell=True, or that require explicit security review for any code paths using shell invocation.
- At runtime, deploy monitoring and logging of executed commands from PraisonAI worker processes, looking for unexpected shells (sh, bash) or anomalous command patterns that may indicate sandbox bypass attempts.

