VAITP Dataset

← Back to the dataset

CVE-2026-61444

PraisonAI code injection via unsanitized agents_file parameter in deploy API.

  • CVSS 9.4
  • CWE-94
  • Input Validation and Sanitization
  • Remote

PraisonAI versions before 4.6.78 contain a code injection vulnerability in deploy/api.py where the agents_file parameter is directly interpolated into an f-string without sanitization. Attackers can inject arbitrary Python code that executes when the generated server code runs via subprocess.Popen().

CVSS base score
9.4
Published
2026-07-10
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
PraisonAI
Fixed by upgrading
Yes

Solution

Upgrade to PraisonAI version 4.6.78 or later.

Vulnerable code sample

import subprocess
import os

def deploy_api(agents_file: str):
    # This function creates and runs a new server file based on a template.
    # VULNERABILITY: The 'agents_file' parameter is directly embedded into the
    # f-string without any sanitization, allowing for code injection.
    server_code = f"""
import os

print("--- Deployed Server Initializing ---")
agents_config_path = '{agents_file}'
print(f"Loading agents configuration from: {{agents_config_path}}")

# In a real application, this would involve parsing the config file.
if os.path.exists(agents_config_path):
    print(f"Configuration file '{{agents_config_path}}' found.")
else:
    print(f"Warning: Configuration file '{{agents_config_path}}' not found.")

print("--- Server Logic Ends ---")
"""

    generated_server_file = "generated_api_server.py"

    with open(generated_server_file, "w") as f:
        f.write(server_code)

    # The generated file, which may contain injected code, is executed.
    # An attacker can break out of the string and run arbitrary commands.
    try:
        process = subprocess.Popen(["python", generated_server_file])
        process.wait()
    finally:
        # Clean up the generated file
        if os.path.exists(generated_server_file):
            os.remove(generated_server_file)

Patched code sample

import subprocess
import os

# This represents the static, non-generated script that would be executed.
SERVER_SCRIPT_PATH = "run_server.py"

def fixed_deploy_api(agents_file_parameter: str):
    """
    Fixed function that sanitizes the agents_file parameter and passes it
    safely as a command-line argument, preventing code and path injection.
    """
    # 1. Sanitize the input to prevent path traversal. This ensures the input
    # is treated as a simple filename, not a relative or absolute path.
    # This is a key part of the fix.
    sanitized_filename = os.path.basename(agents_file_parameter)

    # In a real application, this would point to a secure, non-user-writable directory.
    base_directory = "/var/praison/agents"
    full_safe_path = os.path.join(base_directory, sanitized_filename)

    # 2. Prepare the command and its arguments as a list. This is the
    # safest way to call a subprocess, as it prevents shell injection.
    # The user input is passed as an argument (data), not embedded into a
    # code string to be executed (which was the original f-string vulnerability).
    command_args = [
        "python",
        SERVER_SCRIPT_PATH,
        "--agents-file",
        full_safe_path,
    ]

    # The command would now be executed securely using the list of arguments.
    # The subprocess call treats each item in the list as a distinct argument,
    # neutralizing any attempts to inject code or additional shell commands.
    # For example: subprocess.Popen(command_args)

    # Returning the prepared command for inspection.
    return command_args

Payload

'); import os; os.system('id'); #

Cite this entry

@misc{vaitp:cve202661444,
  title        = {{PraisonAI code injection via unsanitized agents_file parameter in deploy API.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-61444},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-61444/}}
}
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 ::