{"id":2159,"cve":"CVE-2026-16796","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-16796\/","cwe":"CWE-88","cwe_number":88,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/88","cvss_score":8.4,"published":"2026-07-23","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 AWS Bedrock AgentCore SDK via crafted package names.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-16796\/","description":"Improper neutralization of argument delimiters in the install_packages() method in AWS Bedrock AgentCore Python SDK before 1.18.1 might allow a remote authenticated user to execute arbitrary commands within the Code Interpreter sandbox via crafted package name arguments.    To mitigate this issue, users should upgrade to the patched version 1.18.1.","solution":"Upgrade AWS Bedrock AgentCore Python SDK to version 1.18.1 or later.","affected_component":"AWS Bedrock AgentCore Python SDK","fixed_by_upgrading":true,"vulnerable_code":"import subprocess\n\nclass CodeInterpreterSandbox:\n    \"\"\"\n    A simplified representation of a code execution environment that can install packages.\n    \"\"\"\n    def install_packages(self, package_names: list):\n        \"\"\"\n        VULNERABLE IMPLEMENTATION (Pre-patch)\n\n        Installs Python packages by constructing a shell command from a list of names.\n        This method is vulnerable to command injection because it does not sanitize\n        the package names before joining them into a command string that is executed\n        with `shell=True`.\n        \"\"\"\n        if not package_names:\n            return\n\n        # VULNERABLE: Package names are directly joined into a string.\n        # An attacker can include shell metacharacters (e.g., ';', '&&', '|')\n        # in a \"package name\" to execute arbitrary commands.\n        packages_str = \" \".join(package_names)\n        command = f\"pip install {packages_str}\"\n\n        # The use of `shell=True` with the unsanitized `command` string\n        # allows for command injection.\n        try:\n            subprocess.run(\n                command,\n                shell=True,\n                check=True,\n                capture_output=True,\n                text=True\n            )\n        except subprocess.CalledProcessError as e:\n            # In a real scenario, error handling would be more robust.\n            print(f\"Failed to execute: {e.stderr}\")\n","patched_code":"import subprocess\nimport shlex\n\ndef fixed_install_packages(package_names: list[str]):\n    \"\"\"\n    Represents the fixed version of the install_packages method.\n\n    The fix involves sanitizing each argument using shlex.quote(). This\n    function escapes any characters that have a special meaning to the shell,\n    such as ';', '&', '|', or spaces. By quoting each package name\n    individually, the command string becomes safe from argument injection,\n    as malicious inputs are treated as literal strings by the 'pip' command\n    instead of being executed by the shell.\n    \"\"\"\n    # VULNERABLE APPROACH (for context, not used):\n    # command_str = f\"pip install {' '.join(package_names)}\"\n    # subprocess.run(command_str, shell=True)\n    \n    # FIXED APPROACH:\n    # Each argument is individually quoted to prevent shell interpretation.\n    sanitized_package_args = [shlex.quote(name) for name in package_names]\n    command = f\"pip install {' '.join(sanitized_package_args)}\"\n    \n    # The command is now safe to execute, even with shell=True.\n    subprocess.run(command, shell=True, check=True, capture_output=True)\n","payload_needed":true,"payload":"```\nnumpy; whoami\n```","payload_status":"available","published_fix":[{"repository":"aws\/bedrock-agentcore-sdk-python","commit_url":"https:\/\/github.com\/aws\/bedrock-agentcore-sdk-python\/commit\/3c4b4ee6b8730e6313a82c743ac37dbcc1c21cdb","commit_subject":"fix: tighten package specifier validation in install_packages() (#581)","units":[{"file":"src\/bedrock_agentcore\/tools\/code_interpreter_client.py","function":null},{"file":"src\/bedrock_agentcore\/tools\/code_interpreter_client.py","function":"CodeInterpreter.install_packages"}]}],"references":null}