/

CVE-2026-34955

Severity:

HIGH RISK

(8.8)

OS Command Injection in PraisonAI SubprocessSandbox

CVE-2026-34955

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.

Sources

SourceLink
github.comgithub.com/MervinPraison/PraisonAI/security/advisories/GHSA-r4f2-3m54-pp7q

Frequently asked

questions

Exploitability depends on how commands are constructed and who can influence them. In setups where agents, tools, or users can indirectly shape the command string passed into SubprocessSandbox, exploitation can be straightforward, particularly in STRICT mode where operators may incorrectly assume strong confinement.

Typically, yes. Attackers generally need some authenticated or otherwise legitimate access path that lets them control or influence the inputs that reach SubprocessSandbox. However, in multi-tenant or shared deployments, a single compromised agent or user account might be enough to impact the underlying host.

The most robust fix is to stop using shell=True for commands influenced by untrusted input and to switch to argument-based execution (shell=False) with explicit allowlists. Any remaining shell usage should be tightly scoped, use fixed command templates, and never concatenate raw user data into the shell command string.

Treat sandbox and executor components as high-risk and subject them to security design reviews. Avoid blocklist-based command filtering, mandate static checks for shell invocation, and run these components with minimal privileges in hardened environments (containers, separate users, or isolated VMs). Incorporate secure coding guidelines around process creation into development standards and automated tooling.

Find out what's already
exploitable in your codebase.