-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The Sandbox Is A Frozenset\n\nPraisonAI ships an `execute_code()` tool. The agent hands it Python; the tool runs the Python. Two modes: a subprocess sandbox (`sandbox_mode=\"sandbox\"`, the default) and an in-process direct mode (`sandbox_mode=\"direct\"`, legacy). Both modes funnel every input through one function, `_validate_code_ast`, before anything executes. CVE-2026-47392 is what happens when that one function disagrees with the interpreter about what the user's program is.\n\nThe function parses the input with `ast.parse`, walks the tree, and rejects nodes that touch a hardcoded list of names. Two frozen sets define the list. Post-patch:\n\n```python\n_SANDBOX_BLOCKED_ATTRS = frozenset({\n '__subclasses__', '__bases__', '__mro__', '__globals__',\n '__code__', '__class__', '__dict__', '__builtins__',\n '__import__', '__loader__', '__spec__', '__init_subclass__',\n '__set_name__', '__reduce__', '__reduce_ex__',\n '__traceback__', '__qualname__', '__module__',\n '__wrapped__', '__closure__', '__annotations__',\n '__self__', # C builtins leak real builtins module (GHSA-4mr5-g6f9-cfrh)\n # Frame/code object introspection\n 'gi_frame', 'gi_code', 'cr_frame', 'cr_code',\n 'ag_frame', 'ag_code', 'tb_frame', 'tb_next',\n 'f_globals', 'f_locals', 'f_builtins', 'f_code',\n 'co_consts', 'co_names',\n '__getattribute__', '__getattr__', '__setattr__', '__delattr__',\n '__dir__', '__get__', '__set__', '__delete__',\n})\n\n_SANDBOX_BLOCKED_CALLS = frozenset({\n 'exec', 'eval', 'compile', '__import__',\n 'open', 'input', 'breakpoint',\n 'setattr', 'delattr', 'dir', 'vars',\n})\n```\n\nThe author had read the prior art. Every classical Python sandbox-escape door is on the attrs list: `__subclasses__`, `__mro__`, `__globals__`, `__builtins__`, `__class__`, every frame and code-object descriptor. Then `__self__`. Then a comment.\n\nPre-patch, `__self__` was not in the list. `vars` was not in the calls list either. The diff makes two more changes that the comment does not advertise: the call check that used to fire only on `isinstance(func, ast.Name)` was widened to also fire on `isinstance(func, ast.Attribute)`, and the same direct-mode text-substring blocklist a few hundred lines down was missing `'__self__'` too. Four gaps. One PoC exercises all four.\n\n## Four Bypasses, One Payload\n\nThe advisory's PoC for CVE-2026-47392 is five lines. Read them as four separate observations about what the AST checker did not see.\n\n```python\nb = print.__self__\nd = b.vars(b)\nkey = \"_\" + \"_\" + \"import\" + \"_\" + \"_\"\nimp = d[key]\nmod = imp(\"os\")\nprint(mod.popen(\"id\").read())\n```\n\n**Line one.** `print` is a C-implemented builtin in CPython. Its `__self__` descriptor points at the module the function was bound from, which is the real `builtins` module. The AST walker visits `Attribute(value=Name('print'), attr='__self__')`. Pre-patch, `'__self__'` is not in `_blocked_attrs`. The check returns no error. After the line runs, `b` holds the live `builtins` module, the same module that owns `__import__`, `eval`, `exec`, `open`, and every primitive the validator was written to keep the agent away from.\n\n**Line two.** `b.vars(b)` is a `Call` whose `func` is `Attribute(value=Name('b'), attr='vars')`. Pre-patch, the call-check branch reads `if isinstance(func, ast.Name) and func.id in (...)`. The `func` here is an `Attribute`, not a `Name`. The branch never fires. Even with the structural fix, pre-patch `_blocked_calls` listed `dir` and not `vars`; the post-patch diff adds `vars` and the attribute-call branch in the same commit, two independent reasons this one line passed. `d` is now `builtins.__dict__`, the mapping from name to callable for every builtin in the interpreter.\n\n**Line three.** `\"_\" + \"_\" + \"import\" + \"_\" + \"_\"` is five `Constant` nodes joined by `BinOp` adds. The validator inspects each `Constant` by `node.value`, looping over `_blocked_attrs` and asking whether any blocked attr appears as a substring of the literal. None of the five literals contain `__import__`, `__class__`, `__globals__`, or any other forbidden token, because no literal here is longer than seven characters and the forbidden tokens are eight or more. The check is a per-literal substring scan. The addition that joins them is not a literal. The runtime string never appears in any AST node.\n\n**Line four.** `imp = d[key]` is a `Subscript`. It is not a `Call`. The validator has no branch for `Subscript`. The `Subscript`'s `slice` is a `Name`, not a `Constant`; even the literal-substring check would not have inspected it. `d[key]` returns `builtins.__dict__[\"__import__\"]`, the real importer.\n\n**Line five and six.** `imp(\"os\")` is `Call(func=Name(id='imp'))`. `'imp'` is not in `_blocked_calls`; it's a variable the user just created. The check passes; the call returns the `os` module. `mod.popen(\"id\")` is a `Call` whose `func.attr` is `'popen'`; `'popen'` is not on the blocklist either. The shell runs. The agent's UID owns the result.\n\nThe validator inspected every node in the tree. Each individual check did exactly what it was written to do. The composition of the five lines reaches a primitive the validator never saw, because the validator does not see compositions. It sees nodes.\n\n## The Validator Is Named `_validate_code_ast`\n\nThe Python runtime is not named `_resolve_names_only_at_parse_time`. It resolves names at runtime. It computes strings at runtime. It traverses descriptor protocols at runtime. It indexes dictionaries at runtime. Every primitive used in the PoC, every attribute access, every concatenation, every dict subscript, every call, is performed by the interpreter after the AST has been parsed, validated, compiled, and discarded.\n\nA sandbox built by enumerating names in the source text can only enforce constraints visible in the source text. The constraint the PraisonAI sandbox tried to enforce is \"do not reach the builtins module.\" The constraint cannot be expressed as a list of source-level identifiers, because every dynamic primitive in Python permits a name to be computed rather than written. `print.__self__` writes one path. `getattr(print, \"__self__\")` writes another. `getattr(print, \"_\" + \"_self_\" + \"_\")` writes a third. `getattr(__builtins__[\"print\"], \"_\" + \"_self_\" + \"_\")` writes a fourth. The pattern is unbounded, because the operation it expresses (reach the parent module of a callable) is a first-class capability of the runtime, not a syntactic event in the source.\n\nThis is the third instance of the **Source Grep Is Not A Sandbox** pattern in our catalogue this quarter. LiteLLM's `validate_custom_code` shipped a thirty-four-entry regex blocklist over the source string; the fix deleted the file and rebuilt the gate on top of `RestrictedPython`'s AST transformer plus a runtime `_getattr_` guard, because no regex over Python source survives runtime name resolution. Apache OFBiz's `SecuredUpload.isValidText` substring-scanned for `execute` and `import`; the PoC sent `\\u0065\\u0078\\u0065\\u0063\\u0075\\u0074\\u0065`, which the Groovy lexer resolved to `execute` after the deny-list had already approved the bytes. PraisonAI's `_validate_code_ast` walks the AST instead of grepping the text, which is the strongest version of the shape, and still fails for the same reason. The string the validator inspected and the program the interpreter ran are different artifacts.\n\n## The Comment Is Testimony\n\nA blocklist with thirty-three entries, one of them annotated with the GHSA that taught the maintainer the entry should exist, is not a sandbox specification. It is a changelog of bypasses, formatted as a frozenset. The next bypass produces the next entry. The next entry will be annotated with the next GHSA. The file will accrete one comment per CVE until the maintainer decides to delete the file and start over, which is what LiteLLM did.\n\nThis is a **Design Debt Driver**. The component is `_validate_code_ast`. The design is \"enumerate dangerous source-level names, pass the source to a dynamic interpreter.\" The design produces one CVE per primitive the enumeration did not include. The maintainer who wrote this file understood the threat: the pre-patch attribute list includes every `__*__` descriptor known to reach upward through Python's object graph, and the author had clearly read the canonical writeups. They missed `__self__` for the same reason every author of every blocklist of this shape misses the next entry. A blocklist defends against the doors you have enumerated. The interpreter offers every door.\n\n## Subprocess Isolation Is Just `env={}`\n\nThe default mode for `execute_code` is `sandbox_mode=\"sandbox\"`, the subprocess path. The word \"sandbox\" appears in the function name, the parameter, and the docstring. The docstring describes the mode as \"subprocess with resource limits, clean environment, no access to parent process files/env vars.\"\n\nThe actual isolation:\n\n```python\nenv = {} # Clean environment (no access to parent process env vars)\n\nprocess = subprocess.Popen(\n [sys.executable, temp_file],\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE,\n env=env,\n shell=False,\n text=True,\n cwd=tempfile.gettempdir()\n)\n```\n\nThe child is a new Python process. The new process has an empty env dictionary. The new process runs with `/tmp` as its working directory. The new process runs as the same Unix user as the parent, with that user's home directory mounted, that user's `~/.ssh/id_rsa` readable, that user's `~/.aws/credentials` readable, that user's outbound network. There is no `seccomp` filter, no namespace, no capability drop, no chroot, no resource limit applied at the OS level. `ResourceLimits.minimal()` controls a Python-side timeout and nothing else.\n\nThe validator that runs in the parent is repeated, verbatim, in the subprocess. The wrapper code template that `_execute_code_sandboxed` writes to disk re-parses the user code with `ast.walk` and re-applies the same blocked-attrs and blocked-calls checks against the same source string. Two AST passes against the same input, both running the same blocklist, both at parse time. The defense-in-depth has the shape of a depth and the dimension of a single layer.\n\nAfter the AST check is bypassed in the parent, the subprocess re-runs the check. After the AST check is bypassed in the subprocess, `os.popen(\"id\")` runs. The \"id\" is the praisonai agent's id. Every file the agent process can open, the bypass can open. The subprocess boundary did not exist at the layer the attacker crossed.\n\nThis is the genre's other recurring shape: **The Detector Is The Target**. `execute_code` is the central capability of an LLM agent framework, the hand the agent uses to do the job operators bought it for. The same hand is the attack surface, because the LLM's input is attacker-controlled by construction: prompt injection, tool-call manipulation, untrusted document content fed into reasoning. The agent's hand and the attacker's hand are the same hand. The blocklist is what was supposed to tell them apart.\n\n## The Patch\n\nThe patch is `__self__` added to one frozenset, `vars` added to another, one `isinstance` branch widened from `ast.Name` to also accept `ast.Attribute`, and `'__self__'` appended to the direct-mode text-pattern list. Four edits, sized exactly to the PoC the GHSA contains.\n\n```diff\n _SANDBOX_BLOCKED_ATTRS = frozenset({\n ...\n '__wrapped__', '__closure__', '__annotations__',\n+ '__self__', # C builtins leak real builtins module (GHSA-4mr5-g6f9-cfrh)\n ...\n })\n\n _SANDBOX_BLOCKED_CALLS = frozenset({\n 'exec', 'eval', 'compile', '__import__',\n 'open', 'input', 'breakpoint',\n- 'setattr', 'delattr', 'dir',\n+ 'setattr', 'delattr', 'dir', 'vars',\n })\n\n if isinstance(node, ast.Call):\n func = node.func\n if isinstance(func, ast.Name) and func.id in _SANDBOX_BLOCKED_CALLS:\n return f\"Call to '{func.id}' is not allowed\"\n+ if isinstance(func, ast.Attribute) and func.attr in _SANDBOX_BLOCKED_CALLS:\n+ return f\"Call to '{func.attr}' is not allowed\"\n```\n\nThe fix is correct for the bytes in the GHSA. It does not change the layer at which the validator operates. `__getattribute__` is on the attrs blocklist; `__getattr_`+`_ribute__` is not. `globals` (the function) is not on the calls blocklist; the constant `'globals'` is also not. A future PoC that substitutes one runtime-construction primitive for another will produce one more entry in the same frozenset, with one more inline comment naming one more GHSA, and the file will be one line longer.\n\nPoC: [GHSA-4mr5-g6f9-cfrh](https://github.com/advisories/GHSA-4mr5-g6f9-cfrh)\n","closing_line":"The patch is one frozenset entry. The interpreter has every other name.","hook_md":"The patched line in `praisonaiagents/tools/python_tools.py` reads:\n\n```python\n'__self__', # C builtins leak real builtins module (GHSA-4mr5-g6f9-cfrh)\n```\n\nThat is the entire CVE. The patch adds one entry to a frozenset. The comment in the entry names the GHSA the entry fixes. The blocklist held thirty-two attribute names before this commit; it holds thirty-three after. The next CVE will name the next entry.","post_id":525,"slug":"praisonai-cve-2026-47392-blocklist-added-one-more","title":"CVE-2026-47392: PraisonAI's Sandbox Blocklist Had Thirty-Two Names. The Patch Added One More.","type":"initial","unreadable_sentence":"The comment in the patch names the CVE the patch fixes. The next entry will name the next CVE."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCapHQ5wAKCRDeZjl4jgkQ Js/CAPwO2GBNbEKd9kZ2H221EuS9HGm6O2KsIjV8qXQYrRVxWwEAhRaCxxogpwmM IdzoIe7Zp4ywqtD+K1RyqG4qiRBc5wY= =lVcR -----END PGP SIGNATURE-----