CVE-2026-40158: PraisonAI Python sandbox escape via type.__getattribute__

CVE-2026-40158 · Severity: high · CVSS 8.6 · Published 2026-04-10

PraisonAI, a platform for building and running AI agents, contains a security flaw in its code execution sandbox. An attacker can bypass security restrictions to run unauthorized commands on the underlying system. This could lead to the theft of sensitive data like API keys, the deletion of files, or full control over the server hosting the AI agents.

Technologies: Praisonai, praisonai (PyPI). Vendors: Praison, PyPI.

Quick answers

Is CVE-2026-40158 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-40158 being exploited in the wild.
How severe is CVE-2026-40158?
High severity, with a CVSS score of 8.6, published 10 April 2026.
Which products and versions are affected?
praisonai (PyPI) ECOSYSTEM:introduced=0,fixed=4.5.128.
Is there a fix for CVE-2026-40158?
Yes. praisonai (PyPI): upgrade to 4.5.128 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-40158 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2026-40158?
Check whether you run Praisonai or praisonai (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • praisonai (PyPI): upgrade to 4.5.128 or later
    pip install "praisonai>=4.5.128"

Technical details

A sandbox escape vulnerability exists in the `_execute_code_direct` function within `praisonaiagents/tools/python_tools.py`. The implementation uses Abstract Syntax Tree (AST) filtering to block access to dangerous attributes such as `__subclasses__` and `__globals__`, but it only inspects `ast.Attribute` nodes. An attacker can bypass this check by using `type.__getattribute__(obj, 'attribute_name')`, where the attribute name is passed as an `ast.Constant` (string), which the filter ignores. This allows an attacker to traverse the Python object hierarchy to reach the `os` module or other sensitive components and achieve arbitrary code execution. The issue is resolved in version 4.5.128.

Affected products

  • MervinPraison PraisonAI < 4.5.128

Identifiers

  • CVE-2026-40158
  • GHSA-3c4r-6p77-xwr7
  • PYSEC-2026-2898

Timeline

  • 2026-04-09: disclosed: Vulnerability published to MervinPraison/PraisonAI repository
  • 2026-04-10: advisory: GitHub Advisory GHSA-3c4r-6p77-xwr7 published
  • 2026-04-10: patched: Version 4.5.128 released to address the issue

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.