Summary
PraisonAI's workflow include feature can execute arbitrary Python code when it loads an untrusted local recipe. The code runs during include setup as the PraisonAI process user, before child workflow parsing or model execution, when an attacker can cause a victim process to run a workflow or recipe referencing that recipe.
Affected context
The issue affects PraisonAI and PraisonAI Agents deployments using the workflow include feature or the higher-level praisonai.recipe.run() API. It becomes risky when a workflow can reference a local recipe directory controlled or modified by an untrusted party, because the included recipe's tools.py is imported directly without the normal opt-in gates or centralized safe-loader protections.
Exploit preconditions
- Attack surface: Workflow and recipe include processing
- Required access: Ability to place, modify, or cause selection of an attacker-controlled local recipe
- Trigger point: Execution of
Workflow._execute_include()or the corresponding recipe API - Why exploitation is possible: The included
tools.pyis loaded with raw import machinery, causing module-level Python code to run before child workflow validation or model interaction
Why this happens
The vulnerability results from an include implementation that directly invokes importlib.util.spec_from_file_location() and spec.loader.exec_module() on a recipe's tools.py. This bypasses the application's opt-in controls for template and local tools and avoids the centralized loader intended to enforce safer autoload behavior. The issue maps primarily to CWE-94: Improper Control of Generation of Code, with related characteristics of CWE-426: Untrusted Search Path and CWE-829: Inclusion of Functionality from Untrusted Control Sphere.
Potential impact
- An attacker may execute arbitrary Python code as the PraisonAI process user
- The application runtime could be compromised
- Credentials, files, or environment data accessible to the process could be exposed
- The host or surrounding services could be affected depending on process privileges and network access
- Workflows or generated results could be altered or sabotaged
General mitigation guidance
Mitigation generally focuses on treating included recipes and their tools as untrusted code rather than ordinary configuration.
Common defensive patterns include:
- Route all tool and recipe loading through a centralized, policy-enforcing safe loader
- Honor explicit opt-in gates before importing local or template-provided tools
- Restrict workflow includes to trusted, allowlisted directories and artifacts
- Separate workflow data from executable Python modules where possible
- Validate recipe provenance and integrity before execution
- Run PraisonAI processes with least privilege and isolate them from sensitive host resources
- Reduce inherited credentials, filesystem access, and network permissions for workflow runners
How teams detect issues like this
Organizations can look for this issue through:
- Static analysis rules identifying direct use of
spec_from_file_location()andexec_module()on workflow-controlled paths - Code review checks for imports that bypass centralized loaders or security gates
- Repository searches for automatic
tools.pydiscovery in include and recipe execution paths - Policy enforcement that requires allowlists, provenance checks, and explicit consent before loading local modules
- Runtime monitoring of unexpected Python module imports, child-process creation, and filesystem access during workflow startup
- Automated security review tools that flag dynamic imports involving untrusted paths

