CVE-2026-16796
Command injection in AWS Bedrock AgentCore SDK via crafted package names.
- CVSS 8.4
- CWE-88
- Input Validation and Sanitization
- Remote
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.
- CWE
- CWE-88
- CVSS base score
- 8.4
- Published
- 2026-07-23
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- AWS Bedrock
- Fixed by upgrading
- Yes
Solution
Upgrade AWS Bedrock AgentCore Python SDK to version 1.18.1 or later.
Vulnerable code sample
import subprocess
class CodeInterpreterSandbox:
"""
A simplified representation of a code execution environment that can install packages.
"""
def install_packages(self, package_names: list):
"""
VULNERABLE IMPLEMENTATION (Pre-patch)
Installs Python packages by constructing a shell command from a list of names.
This method is vulnerable to command injection because it does not sanitize
the package names before joining them into a command string that is executed
with `shell=True`.
"""
if not package_names:
return
# VULNERABLE: Package names are directly joined into a string.
# An attacker can include shell metacharacters (e.g., ';', '&&', '|')
# in a "package name" to execute arbitrary commands.
packages_str = " ".join(package_names)
command = f"pip install {packages_str}"
# The use of `shell=True` with the unsanitized `command` string
# allows for command injection.
try:
subprocess.run(
command,
shell=True,
check=True,
capture_output=True,
text=True
)
except subprocess.CalledProcessError as e:
# In a real scenario, error handling would be more robust.
print(f"Failed to execute: {e.stderr}")Patched code sample
import subprocess
import shlex
def fixed_install_packages(package_names: list[str]):
"""
Represents the fixed version of the install_packages method.
The fix involves sanitizing each argument using shlex.quote(). This
function escapes any characters that have a special meaning to the shell,
such as ';', '&', '|', or spaces. By quoting each package name
individually, the command string becomes safe from argument injection,
as malicious inputs are treated as literal strings by the 'pip' command
instead of being executed by the shell.
"""
# VULNERABLE APPROACH (for context, not used):
# command_str = f"pip install {' '.join(package_names)}"
# subprocess.run(command_str, shell=True)
# FIXED APPROACH:
# Each argument is individually quoted to prevent shell interpretation.
sanitized_package_args = [shlex.quote(name) for name in package_names]
command = f"pip install {' '.join(sanitized_package_args)}"
# The command is now safe to execute, even with shell=True.
subprocess.run(command, shell=True, check=True, capture_output=True)Payload
numpy; whoami
Cite this entry
@misc{vaitp:cve202616796,
title = {{Command injection in AWS Bedrock AgentCore SDK via crafted package names.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-16796},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-16796/}}
}
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 ::
