PraisonAI Sandbox Bypasses Enabled Arbitrary Code Execution in Agent Python Tools
Emerging Technology Risk · 2 sources · Updated 5mo ago · First seen Apr 8, 2026

Two high-severity vulnerabilities in PraisonAI exposed its Python sandbox protections to bypass, allowing arbitrary code execution when untrusted agent code was run. CVE-2026-39888 affected versions prior to 1.5.115 in praisonaiagents.tools.python_tools.execute_code() when sandbox_mode defaulted to sandbox; the subprocess wrapper relied on a restricted __builtins__ dictionary and an incomplete AST blocklist that omitted frame-traversal attributes including __traceback__, tb_frame, f_back, and f_builtins. By catching an exception and traversing frames, an attacker could recover the real Python builtins from the wrapper frame and invoke exec, defeating the intended sandbox restrictions.
A second flaw, CVE-2026-40158, affected PraisonAI versions prior to 4.5.128 in _execute_code_direct within praisonaiagents/tools/python_tools.py. That sandbox used AST filtering to block dangerous Python attributes, but only inspected ast.Attribute nodes and missed dynamic attribute resolution through built-in mechanisms such as type.__getattribute__. Attackers could therefore reach blocked capabilities such as __subclasses__ through a trampoline technique because the string appeared as an ast.Constant rather than an ast.Attribute, undermining the protection model until the vendor patched the issue in 4.5.128.
Why it matters
Impact assessment
Two high-severity PraisonAI sandbox bypasses allow arbitrary code execution when untrusted agent-supplied Python is executed, directly affecting organizations using PraisonAI to run agent code, automation workflows, or multi-agent tasks. The primary risk is full compromise of the host context running the Python tool, with potential data theft, credential exposure, workflow manipulation, and service disruption.
Severity and scope
- Affected product: PraisonAI multi-agent teams system.
- Affected populations: developers, AI platform teams, and enterprises that permit untrusted or semi-trusted agent code execution.
- Impact type: arbitrary code execution through sandbox escape.
- Likely consequences: host-level command execution in the Python runtime context, access to local files and secrets available to the process, downstream compromise of connected systems, and operational disruption of AI-driven workflows.
- Scope of exposure: potentially broad for deployments using vulnerable versions and enabling Python tool execution; exploitation requires the attacker to supply code to the agent execution path.
- Known exploitation: the provided references describe vulnerabilities and exploit mechanics but do not report confirmed in-the-wild exploitation.
Structured facts
- Entity: PraisonAI.
- Product area: praisonaiagents.tools.python_tools.
- Vulnerability theme: sandbox bypass leading to arbitrary code execution.
- Trigger condition: running untrusted agent code through Python execution features.
- Fixed versions: 1.5.115 for CVE-2026-39888 and 4.5.128 for CVE-2026-40158.


