{"id":1745,"cve":"CVE-2026-34937","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-34937\/","cwe":"CWE-78","cwe_number":78,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/78","cvss_score":9.8,"published":"2026-04-03","owasp":"A03 Injection","odc":"Checking","cdc":"Incorrect Check","category":"Input Validation and Sanitization","subcategory":"Command Injection","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Command injection in PraisonAI run_python due to improper shell escaping.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-34937\/","description":"PraisonAI is a multi-agent teams system. Prior to version 1.5.90, run_python() in praisonai constructs a shell command string by interpolating user-controlled code into python3 -c \"<code>\" and passing it to subprocess.run(..., shell=True). The escaping logic only handles \\ and \", leaving $() and backtick substitutions unescaped, allowing arbitrary OS command execution before Python is invoked. This issue has been patched in version 1.5.90.","solution":"Upgrade PraisonAI to version 1.5.90 or later.","affected_component":"PraisonAI","fixed_by_upgrading":true,"vulnerable_code":"import subprocess\n\ndef run_python(code: str):\n    \"\"\"\n    This function represents the vulnerable state of PraisonAI's run_python\n    prior to version 1.5.90, as described in CVE-2026-34937.\n    \"\"\"\n    # Flawed escaping that only handles backslashes and double quotes, leaving\n    # shell command substitution characters like $() and `` unescaped.\n    escaped_code = code.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\", \"\\\\\\\"\")\n\n    # Insecurely constructs a shell command by embedding the escaped code.\n    command = f'python3 -c \"{escaped_code}\"'\n\n    # The use of shell=True with the improperly sanitized 'command' string\n    # creates a command injection vulnerability. The shell will process\n    # substitutions like $(command-to-run) before invoking python3.\n    result = subprocess.run(\n        command,\n        shell=True,\n        capture_output=True,\n        text=True,\n        check=False\n    )\n\n    return result","patched_code":"import subprocess\nimport shlex\n\ndef run_python(code: str):\n    \"\"\"\n    Executes a string of Python code in a secure manner, demonstrating the\n    fix for a command injection vulnerability.\n\n    The vulnerability (CVE-2026-34937) was caused by using `shell=True` with an\n    improperly sanitized, user-controlled string. The fix is to avoid the\n    shell entirely for command execution by passing arguments as a sequence.\n\n    By setting `shell=False` (which is the default) and passing the command\n    and its arguments as a list (`['python3', '-c', code]`), the user-provided\n    `code` string is treated as a single argument to `python3 -c` and is not\n    interpreted by the shell. This prevents shell metacharacters like `$` or\n    backticks from being executed as commands.\n    \"\"\"\n    try:\n        # The command and its arguments are passed as a list.\n        # `shell=False` is the default and is the secure way to call subprocesses\n        # when arguments are involved, as it prevents shell injection.\n        command_args = [\"python3\", \"-c\", code]\n\n        result = subprocess.run(\n            command_args,\n            capture_output=True,\n            text=True,\n            check=False,  # Do not raise exception for non-zero exit codes\n            timeout=10    # Add a timeout for safety\n        )\n        return result.stdout, result.stderr\n    except subprocess.TimeoutExpired:\n        return \"\", \"Error: Code execution timed out after 10 seconds.\"\n    except Exception as e:\n        return \"\", f\"An unexpected error occurred: {e}\"\n","payload_needed":true,"payload":"$(touch \/tmp\/pwned)","payload_status":"available","published_fix":[],"references":null}