The Sandbox Is A Frozenset
PraisonAI 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.
The 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:
_SANDBOX_BLOCKED_ATTRS = frozenset({
'__subclasses__', '__bases__', '__mro__', '__globals__',
'__code__', '__class__', '__dict__', '__builtins__',
'__import__', '__loader__', '__spec__', '__init_subclass__',
'__set_name__', '__reduce__', '__reduce_ex__',
'__traceback__', '__qualname__', '__module__',
'__wrapped__', '__closure__', '__annotations__',
'__self__', # C builtins leak real builtins module (GHSA-4mr5-g6f9-cfrh)
# Frame/code object introspection
'gi_frame', 'gi_code', 'cr_frame', 'cr_code',
'ag_frame', 'ag_code', 'tb_frame', 'tb_next',
'f_globals', 'f_locals', 'f_builtins', 'f_code',
'co_consts', 'co_names',
'__getattribute__', '__getattr__', '__setattr__', '__delattr__',
'__dir__', '__get__', '__set__', '__delete__',
})
_SANDBOX_BLOCKED_CALLS = frozenset({
'exec', 'eval', 'compile', '__import__',
'open', 'input', 'breakpoint',
'setattr', 'delattr', 'dir', 'vars',
})
The 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.
Pre-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.
Four Bypasses, One Payload
The advisory's PoC for CVE-2026-47392 is five lines. Read them as four separate observations about what the AST checker did not see.
b = print.__self__
d = b.vars(b)
key = "_" + "_" + "import" + "_" + "_"
imp = d[key]
mod = imp("os")
print(mod.popen("id").read())
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.
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.
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.
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.
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.
The 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.
The Validator Is Named _validate_code_ast
The 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.
A 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.
This 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.
The Comment Is Testimony
A 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.
This 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.
Subprocess Isolation Is Just env={}
The 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."
The actual isolation:
env = {} # Clean environment (no access to parent process env vars)
process = subprocess.Popen(
[sys.executable, temp_file],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
shell=False,
text=True,
cwd=tempfile.gettempdir()
)
The 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.
The 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.
After 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.
This 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.
The Patch
The 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.
_SANDBOX_BLOCKED_ATTRS = frozenset({
...
'__wrapped__', '__closure__', '__annotations__',
+ '__self__', # C builtins leak real builtins module (GHSA-4mr5-g6f9-cfrh)
...
})
_SANDBOX_BLOCKED_CALLS = frozenset({
'exec', 'eval', 'compile', '__import__',
'open', 'input', 'breakpoint',
- 'setattr', 'delattr', 'dir',
+ 'setattr', 'delattr', 'dir', 'vars',
})
if isinstance(node, ast.Call):
func = node.func
if isinstance(func, ast.Name) and func.id in _SANDBOX_BLOCKED_CALLS:
return f"Call to '{func.id}' is not allowed"
+ if isinstance(func, ast.Attribute) and func.attr in _SANDBOX_BLOCKED_CALLS:
+ return f"Call to '{func.attr}' is not allowed"
The 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.
PoC: GHSA-4mr5-g6f9-cfrh
The patch is one frozenset entry. The interpreter has every other name.