CVE-2026-45369
python-utcp is vulnerable to shell command injection via tool_args.
- CVSS 8.3
- CWE-78
- Input Validation and Sanitization
- Local
python-utcp is the python implementation of UTCP. Prior to 1.1.3, the _substitute_utcp_args method in cli_communication_protocol.py inserts user-controlled tool_args values directly into shell command strings without any sanitization or escaping. These commands are then executed via /bin/bash -c (Unix) or powershell.exe -Command (Windows), allowing an attacker to inject arbitrary shell commands. This vulnerability is fixed in 1.1.3.
- CWE
- CWE-78
- CVSS base score
- 8.3
- Published
- 2026-05-14
- 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
- python-utcp
- Fixed by upgrading
- Yes
Solution
Upgrade python-utcp to version 1.1.3.
Vulnerable code sample
import subprocess
import sys
# Represents the vulnerable code in cli_communication_protocol.py prior to version 1.1.3
class CliCommunicationProtocol:
def _substitute_utcp_args(self, command_template, tool_args):
"""
UNSAFE: Inserts user-controlled arguments directly into a command string.
"""
# The vulnerability is the direct, unsanitized formatting of user input.
return f"{command_template} {tool_args}"
def execute_tool(self, tool_executable, tool_args):
"""
Constructs and executes a command using the vulnerable substitution method.
"""
# The user-controlled `tool_args` are passed to the vulnerable method.
command_string = self._substitute_utcp_args(tool_executable, tool_args)
# The resulting command string is executed via the system's shell,
# allowing for command injection. This mimics the behavior of using
# /bin/bash -c or powershell.exe -Command.
subprocess.run(command_string, shell=True)Patched code sample
Since the specified CVE is not real, the actual patch code from the `python-utcp` library cannot be provided. The following Python code example demonstrates the common and correct way to fix the type of command injection vulnerability described.
The vulnerability lies in placing unescaped user input directly into a command string that is executed by a shell. The fix is to use `shlex.quote()` to properly escape the user input, ensuring the shell treats it as a single, literal string argument rather than as executable code.
```python
import shlex
import subprocess
def fixed_execute_command(command_template, user_controlled_arg):
"""
Represents the fixed method that safely incorporates a user-controlled
argument into a shell command before execution.
Args:
command_template (str): A command string with a placeholder '{}' for the argument.
user_controlled_arg (str): A string originating from a user, which could be malicious.
"""
# The vulnerability is fixed by using shlex.quote() to sanitize the
# user-controlled input. This function escapes any characters that have
# a special meaning to the shell, ensuring the input is treated as a
# single, literal argument.
safe_arg = shlex.quote(user_controlled_arg)
# The sanitized argument is inserted into the command string.
full_command = command_template.format(safe_arg)
# The command is now safe to be executed by a shell.
# For example, if user_controlled_arg was "file.txt; rm -rf /",
# the shell would receive the command:
# /path/to/tool 'file.txt; rm -rf /'
# The shell would look for a file with that literal name and would not
# execute the 'rm -rf /' command.
subprocess.run(["/bin/bash", "-c", full_command], check=False)Payload
"; whoami; #
Cite this entry
@misc{vaitp:cve202645369,
title = {{python-utcp is vulnerable to shell command injection via tool_args.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-45369},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-45369/}}
}
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 ::
