VAITP Dataset

← Back to the dataset

CVE-2026-44345

Dockerfile injection in BentoML via `bento.yaml` allows code execution.

  • CVSS 8.8
  • CWE-78
  • Input Validation and Sanitization
  • Local

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Prior to 1.4.39, src/bentoml/_internal/container/frontend/dockerfile/templates/base_v2.j2 interpolates docker.base_image raw with no escaping, newline filtering, or validation. A malicious bento.yaml with a multi-line docker.base_image value smuggles arbitrary Dockerfile directives into the generated Dockerfile, and bentoml containerize then runs docker build which executes the injected RUN directives on the victim host. This vulnerability is fixed in 1.4.39.

CVSS base score
8.8
Published
2026-05-27
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
BentoML
Fixed by upgrading
Yes

Solution

Upgrade BentoML to version 1.4.39 or later.

Vulnerable code sample

import jinja2

# This simulates the vulnerable logic in BentoML before the fix.
# It reads a configuration (as if from bento.yaml) and uses a Jinja2
# template to generate a Dockerfile.

def generate_dockerfile_vulnerable(config):
    """
    Simulates the vulnerable Dockerfile generation process.
    The 'docker.base_image' value is interpolated directly without sanitization.
    """
    # This represents the vulnerable template file (e.g., base_v2.j2)
    dockerfile_template_content = """
# Dockerfile generated by BentoML
FROM {{ config.docker.base_image }}

# Other legitimate Dockerfile instructions would follow
WORKDIR /home/bentoml
COPY . .
"""

    template = jinja2.Template(dockerfile_template_content)
    # The vulnerability occurs here: rendering with raw, un-validated user input.
    generated_content = template.render(config=config)
    return generated_content

# 1. Define a malicious configuration, simulating a user-provided bento.yaml
# The attacker injects a newline and a 'RUN' command into the 'base_image' field.
malicious_bento_config = {
    'docker': {
        'base_image': 'python:3.9-slim\nRUN touch /tmp/pwned_by_cve'
    }
}

# 2. Run the vulnerable generation function with the malicious config
compromised_dockerfile = generate_dockerfile_vulnerable(malicious_bento_config)

# 3. Print the resulting compromised Dockerfile.
# When 'docker build' is run on this file, it will execute the injected 'RUN' command.
print("--- Generated Compromised Dockerfile ---")
print(compromised_dockerfile)

Patched code sample

import sys

def fixed_dockerfile_generation(base_image: str, dockerfile_template: str) -> str:
    """
    Generates a Dockerfile content from a base image and a template,
    implementing the fix for CVE-2026-44345.
    """
    # THE FIX:
    # Before interpolating the base_image into the template, validate that it does
    # not contain newline characters. This prevents the injection of arbitrary
    # Dockerfile directives.
    if "\n" in base_image or "\r" in base_image:
        raise ValueError(
            "Invalid 'base_image' value: contains newline characters, which is not allowed."
        )

    # If validation passes, the base_image is considered safe to use.
    # This simulates the original, now safe, templating process.
    return dockerfile_template.replace("{base_image}", base_image)

Payload

service: "service:svc"
labels:
  owner: bentoml-team
  stage: dev
docker:
  base_image: |
    debian:slim
    RUN touch /tmp/pwned

Cite this entry

@misc{vaitp:cve202644345,
  title        = {{Dockerfile injection in BentoML via `bento.yaml` allows code execution.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-44345},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-44345/}}
}
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 ::