CVE-2026-40158
Received Received - Intake
AST Sandbox Bypass in PraisonAI Enables Arbitrary Code Execution

Publication date: 2026-04-10

Last updated on: 2026-04-20

Assigner: GitHub, Inc.

Description
PraisonAI is a multi-agent teams system. Prior to 4.5.128, PraisonAI's AST-based Python sandbox can be bypassed using type.__getattribute__ trampoline, allowing arbitrary code execution when running untrusted agent code. The _execute_code_direct function in praisonaiagents/tools/python_tools.py uses AST filtering to block dangerous Python attributes like __subclasses__, __globals__, and __bases__. However, the filter only checks ast.Attribute nodes, allowing a bypass. The sandbox relies on AST-based filtering of attribute access but fails to account for dynamic attribute resolution via built-in methods such as type.getattribute, resulting in incomplete enforcement of security restrictions. The string '__subclasses__' is an ast.Constant, not an ast.Attribute, so it is never checked against the blocked list. This vulnerability is fixed in 4.5.128.
CVSS Scores
EPSS Scores
Probability:
Percentile:
Meta Information
Published
2026-04-10
Last Modified
2026-04-20
Generated
2026-06-16
AI Q&A
2026-04-10
EPSS Evaluated
2026-06-15
NVD
EUVD
Affected Vendors & Products
Showing 1 associated CPE
Vendor Product Version / Range
praison praisonai to 4.5.128 (exc)
Helpful Resources
Exploitability
CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-94 The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
CWE-693 The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.
Attack-Flow Graph
AI Quick Actions
Instant insights powered by AI
Compliance Impact

This vulnerability allows attackers to execute arbitrary code with the host process's privileges, leading to unauthorized access to sensitive data such as environment variables, API keys, and local files. Such unauthorized access and potential data exfiltration can result in violations of data protection regulations like GDPR and HIPAA, which mandate strict controls over the confidentiality and integrity of sensitive information.

Because the vulnerability enables sandbox escape and arbitrary system command execution, it increases the risk of data breaches and system compromise, which are critical compliance concerns under these standards.

Executive Summary

CVE-2026-40158 is a high-severity vulnerability in PraisonAI's AST-based Python sandbox that allows attackers to bypass security restrictions and execute arbitrary code. The sandbox attempts to block dangerous Python attributes like __subclasses__, __globals__, and __bases__ by filtering AST attribute nodes. However, it only inspects ast.Attribute nodes and fails to check ast.Constant nodes, which can contain these dangerous attribute names.

Attackers exploit this by using the built-in method type.__getattribute__ as a trampoline to dynamically access blocked attributes that the filter misses. This enables them to enumerate subclasses, access internal class globals, and ultimately execute arbitrary system commands, escaping the sandbox.

Impact Analysis

This vulnerability can have severe impacts including unauthorized access to sensitive data such as environment variables, API keys, and local files. Attackers can execute arbitrary system commands, modify or delete files, and potentially gain full control over the affected system.

It is especially dangerous in environments running untrusted code, such as multi-tenant agent platforms, CI/CD pipelines, or shared systems, where it can lead to data exfiltration, lateral movement, and full system compromise.

Detection Guidance

Detection of this vulnerability involves identifying if the PraisonAI version in use is vulnerable (versions ≀ 4.5.117) and if untrusted agent code is being executed within the AST-based Python sandbox that can be bypassed.

Since the vulnerability exploits the sandbox's failure to block dynamic attribute resolution via type.__getattribute__, detection can focus on monitoring for suspicious use of this method or unusual system command executions originating from the PraisonAI process.

  • Check the installed PraisonAI version to confirm if it is older than 4.5.128.
  • Monitor logs or runtime behavior for calls to type.__getattribute__ or unexpected system commands executed by PraisonAI.
  • Use commands like `ps aux | grep praisonai` to identify running PraisonAI processes.
  • Inspect the PraisonAI installation version with commands such as `praisonai --version` or checking package metadata.
  • If possible, audit or review agent code execution logs for evidence of code injection or use of dynamic attribute access patterns like `type.__getattribute__`.
Mitigation Strategies

The primary and immediate mitigation step is to upgrade PraisonAI to version 4.5.128 or later, where this vulnerability is fixed.

Until the upgrade can be applied, restrict execution of untrusted agent code within PraisonAI to trusted users or environments to minimize risk.

Implement monitoring to detect suspicious activity such as unexpected system command executions or use of dynamic attribute resolution methods.

Consider isolating PraisonAI processes in restricted environments or containers to limit potential impact of exploitation.

Chat Assistant
Ask questions about this CVE
Hi! I’m here to help you understand CVE-2026-40158. Ask me anything about the vulnerability, its impact, or mitigation strategies.
0/70
EPSS Chart