CVE-2026-62176
Arbitrary code execution via unsanitized agents_file f‑string injection in deploy/api.py.
- CVSS 9.1
- CWE-94
- Input Validation and Sanitization
- Remote
PraisonAI is a multi-agent teams system. Prior to version 4.6.78, 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. Version 4.6.78 patches the issue.
- CWE
- CWE-94
- CVSS base score
- 9.1
- Published
- 2026-10-07
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Upgrade PraisonAI to version 4.6.78 or later.
Vulnerable code sample
import subprocess
from pathlib import Path
def generate_and_run_server(agents_file: str, output_dir: Path) -> None:
"""
Generates a Python server script from the provided agents file and runs it.
"""
server_code = f"""#!/usr/bin/env python3
import json
def load_agents():
with open("{agents_file}", "r") as f:
return json.load(f)
if __name__ == "__main__":
agents = load_agents()
print("Loaded agents:", agents)
"""
script_path = output_dir / "generated_server.py"
script_path.write_text(server_code, encoding="utf-8")
# VULNERABLE: unsanitized interpolation of agents_file into code executed via subprocess
subprocess.Popen(["python3", str(script_path)])Patched code sample
import subprocess
import shlex
from pathlib import Path
def generate_and_run_server(agents_file: str, output_dir: Path) -> None:
"""
Generates a Python server script from the provided agents file and runs it.
"""
safe_path = shlex.quote(agents_file)
server_code = f"""#!/usr/bin/env python3
import json
def load_agents():
with open({safe_path}, "r") as f:
return json.load(f)
if __name__ == "__main__":
agents = load_agents()
print("Loaded agents:", agents)
"""
script_path = output_dir / "generated_server.py"
script_path.write_text(server_code, encoding="utf-8")
# FIX: agents_file is safely quoted to prevent code injection
subprocess.Popen(["python3", str(script_path)])Cite this entry
@misc{vaitp:cve202662176,
title = {{Arbitrary code execution via unsanitized agents_file f‑string injection in deploy/api.py.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-62176},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-62176/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
