Описание
PraisonAI workflow include bypasses tools.py autoload opt-in and executes included recipe code
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:
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:
Expected vulnerable output:
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:
Expected vulnerable output:
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
Appendix B - pov_recipe_run.py
Пакеты
praisonaiagents
>= 0.12.12, < 1.6.58
1.6.58
PraisonAI
>= 3.9.26, < 4.6.58
4.6.58
Связанные уязвимости
PraisonAI is a multi-agent teams system. In versions 3.9.26 through 4.6.57 of praiseonai and 0.12.12 through 1.6.57 of praiseonaiagents, the workflow "include" feature is vulnerable to code execution. Workflow._execute_include() implicitly imports and runs an included recipe's tools.py via a raw importlib.util.spec_from_file_location() and spec.loader.exec_module() call, without honoring the PRAISONAI_ALLOW_TEMPLATE_TOOLS/PRAISONAI_ALLOW_LOCAL_TOOLS autoload opt-in gates or routing through the centralized safe loader that protects the other tools.py autoload paths. As a result, a workflow that includes an attacker-controlled local recipe directory executes arbitrary module-level Python code during include setup, before any child workflow parsing or model call, and the same sink is reachable through the higher-level praisonai.recipe.run() recipe API. An attacker who can cause a victim process to run a workflow or recipe that includes an untrusted local recipe achieves arbitrary Python c