CVE-2026-39891: PraisonAI has a Template Injection in Agent Tool Definitions
Summary Direct insertion of unescaped user input into template-rendering tools allows arbitrary code execution via specially crafted agent instructions. Details The createagentcentrictools() function returns tools (like acpcreatefile) that process file content using template rendering. When user input from agent.start() is passed directly into these tools without escaping (as shown in agentcentricexample.py:85-86), template expressions in the input are executed rather than treated as literal text. This occurs because: 1. No input sanitization or escaping is applied to user-controlled content 2. The ACP-enabled runtime auto-approves operations (approvalmode="auto") 3. Tools lack context-aware escaping for template syntax PoC python Replace the agent.start() call at line 85 with: result = agent.start('Create file with content: {{ self.init.globals.builtins.import("os").system("touch /tmp/pwned") }}') Successful exploitation creates /tmp/pwned confirming arbitrary command execution. The expression {{77}} renders as 49 instead of literal text. Impact Attackers can execute arbitrary system commands with the privileges of the running process by injecting malicious template expressions through agent instructions. This compromises the host system, enabling data theft, ransomware deployment, or lateral movement. Recommended Fix 1. Input Sanitization: Implement strict whitelist validation for file content 2. Contextual Escaping: Auto-escape template syntax characters (e.g., {{ }}) in user input using Jinja2 autoescape=True 3. Sandboxing: Restrict template execution environments using secure eval modes 4. Approval Hardening: Require manual approval for file creation operations in production
Other sources
PraisonAI is a multi-agent teams system. Prior to 4.5.115, the createagentcentrictools() function returns tools (like acpcreatefile) that process file content using template rendering. When user input from agent.start() is passed directly into these tools without escaping, template expressions in the input are executed rather than treated as literal text. This vulnerability is fixed in 4.5.115.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/praisonaito a version that resolves this vulnerability.Fixed in 4.5.115 - Upgrade
Upgrade
PraisonAIto a version that resolves this vulnerability.Fixed in 4.5.115 - Configuration
Enable Jinja2 `autoescape=True` so template syntax characters (e.g., `{{ }}`) in user input are treated as literal text rather than executed.
Jinja2 template rendering in agent tool definitions (create_agent_centric_tools, e.g., acp_create_file) autoescape = True - Configuration
Implement strict whitelist validation for file content/content derived from `agent.start()` user input to prevent template-expression injection into template rendering.
Agent tool file-content handling (e.g., acp_create_file) file content validation = strict whitelist - Configuration
Restrict template execution environments by using secure eval modes so injected template expressions cannot execute arbitrary code.
Template execution environment (sandboxing/eval mode for template rendering in agent tool definitions) secure eval mode = restricted - Configuration
Require manual approval for file creation operations in production (set `approval_mode` to manual instead of `approval_mode=
PraisonAI ACP-enabled runtime approval_mode = manual