Summary
PraisonAI's recipe runner contains an unguarded auto-import of a local tools.py file that allows remote recipes to inject and execute arbitrary Python code on the server.
Between versions 4.5.139 and 4.6.31, an attacker can point a recipe at a local path or GitHub repository, drop a tools.py next to TEMPLATE.yaml, and have it executed without authentication or explicit admin opt-in.
Affected context
The vulnerability affects PraisonAI multi-agent team deployments using versions 4.5.139 through 4.6.31 where:
- The recipe runner endpoint
/v1/recipes/runis exposed (e.g., via API, UI, or reverse proxy). - The default configuration is used, where
SecurityConfig.allow_any_githubis set toTrue. - Recipes can reference arbitrary local absolute paths or GitHub repositories as their source.
In this context, praisonai/templates/tool_override.py auto-imports and executes a tools.py module located adjacent to a TEMPLATE.yaml file without checking an environment gate like PRAISONAI_ALLOW_LOCAL_TOOLS.
Exploit preconditions
- Attack surface: HTTP API endpoint
POST /v1/recipes/run, typically reachable wherever the PraisonAI server is exposed. - Required access: No authentication required under default settings; attacker only needs network access to the API.
- Trigger point: Supplying a recipe definition that points to:
- A local absolute path controlled or influenced by the attacker, or
- A GitHub repository (since
allow_any_githubdefaults toTrue). - Why exploitation is possible:
praisonai/templates/tool_override.pyimports and executestools.pyviaexec_module()automatically on every recipe execution.- This import sink is not gated by the
PRAISONAI_ALLOW_LOCAL_TOOLSenvironment flag that protects other auto-import paths. - The recipe runner trusts the referenced path or GitHub repo and pulls in code adjacent to
TEMPLATE.yamlwithout validation, leading to arbitrary code execution in the server context.
Why this happens
The underlying issue is an incomplete fix for a prior vulnerability (CVE-2026-40287) where only some auto-import sinks were guarded behind an explicit opt-in flag (PRAISONAI_ALLOW_LOCAL_TOOLS=true).
While tool_resolver.py and api/call.py were updated, the third import path in praisonai/templates/tool_override.py was left unguarded.
This results in CWE-94: Improper Control of Generation of Code (Code Injection), where:
- Untrusted remote input (the recipe path or GitHub URL) controls which Python module is loaded.
- The system blindly executes the
tools.pymodule adjacent toTEMPLATE.yamlusingexec_module(). - There is no validation, sandboxing, or configuration gate to separate user-supplied templates from trusted server-side code.
Conceptually, this is an insecure dynamic code loading pattern: configuration or content locations implicitly double as executable code sources.
Potential impact
- Remote execution of arbitrary Python code with the privileges of the PraisonAI server process.
- Full compromise of the application environment, including access to connected tools, APIs, and data sources.
- Theft or modification of sensitive data processed or stored by PraisonAI.
- Use of the compromised server as a pivot point for lateral movement within the infrastructure.
- Deployment of persistent backdoors or malicious logic inside the multi-agent workflow.
- Supply-chain style abuse where malicious templates in GitHub repos affect multiple deployments that reference them.
General mitigation guidance
Effective mitigation focuses on removing implicit code execution from untrusted recipes and enforcing explicit trust boundaries:
- Eliminate automatic code execution from content locations:
- Avoid auto-importing and executing
tools.pyor any dynamic module based solely on template paths or Git repos. - Treat templates and recipes as data, and keep executable code in separately controlled, vetted locations.
- Introduce explicit trust and opt-in mechanisms:
- Require a configuration flag or allowlist to enable loading custom tooling from local paths or external repositories.
- Restrict accepted GitHub sources to curated, signed, or organization-controlled repositories rather than arbitrary URLs.
- Constrain execution privileges:
- Run PraisonAI services under least-privilege OS accounts and minimize their filesystem and network access.
- Consider process-level or container sandboxing for any component that might interpret user-controlled code.
- Harden configuration and deployment:
- Place the
/v1/recipes/runendpoint behind authentication and authorization controls. - Separate environments for experimentation (where custom tools are allowed) from production (where they are not).
- Apply secure-by-default patterns:
- Default configurations should disallow loading code from user-controlled paths or repos, requiring explicit administrator opt-in.
- Use clear configuration toggles and documentation so operators understand when they are enabling remote code execution behavior.
How teams detect issues like this
Organizations can detect and monitor for similar code injection risks using a combination of code-centric and runtime approaches:
- Static analysis and linting:
- Search for dynamic module loading and execution patterns (
exec_module,importlib,exec,eval) that are fed by configuration or network inputs. - Flag file-system or repository-based imports that are not guarded by explicit configuration checks or input validation.
- Use custom static analysis rules to ensure all auto-import sites are consistently wrapped with security gates (e.g., environment flags, allowlists).
- Code review practices:
- During review, scrutinize any feature that loads tools, plugins, or scripts from templates, recipes, or external repositories.
- Verify that fixes for previous vulnerabilities update all related code paths, not just the originally reported ones.
- Configuration and policy enforcement:
- Enforce policies that disable or restrict loading of code from arbitrary URLs or local paths in production builds.
- Integrate security checks into CI/CD to block deployments when dangerous patterns are introduced without proper gating.
- Runtime monitoring and logging:
- Log all recipe executions, including the source path or repository and any dynamic tool loading events.
- Monitor for unusual patterns, such as recipes referencing unexpected absolute paths or unknown GitHub repos.
- Use endpoint or container security tools to detect suspicious process behavior originating from the PraisonAI service.

