/

CVE-2026-44345

Severity:

HIGH RISK

(8.8)

OS Command Injection in BentoML Containerization Pipeline

CVE-2026-44345

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution on Build Host via Dockerfile Injection

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

BentoML's Dockerfile templating pipeline interpolates the docker.base_image field from bento.yaml directly into a Dockerfile template without escaping, newline filtering, or validation.

An attacker who can supply or modify a malicious bento.yaml can inject arbitrary Dockerfile directives and cause docker build to execute attacker-controlled commands on the host where bentoml containerize runs.

Affected context

This issue arises in environments where BentoML is used to containerize models or AI services and relies on user- or pipeline-provided bento.yaml files to define container settings.

The vulnerability specifically affects the Dockerfile generation logic in base_v2.j2, which interpolates docker.base_image into the Dockerfile without sanitization.

It becomes risky when bentoml containerize is run against bentos whose configuration can be influenced by untrusted users, CI inputs, or external model repositories, because the resulting Dockerfile is then built on the developer, CI, or build server host.

Exploit preconditions

  • Attack surface: The Bento packaging and containerization workflow, especially bentoml containerize.
  • Required access: Ability to create, modify, or supply a bento.yaml that will be consumed by BentoML (e.g., via a shared repo, CI pipeline, or multi-tenant ML platform).
  • Trigger point: Execution of bentoml containerize which renders the Dockerfile template and invokes docker build on the generated Dockerfile.
  • Why exploitation is possible: The docker.base_image field is interpolated into a Jinja2 Dockerfile template as raw text, with no escaping, newline stripping, or format validation. A multi-line value can break out of the expected FROM directive and inject arbitrary Dockerfile instructions (including RUN), which are executed during the Docker build process on the host.

Why this happens

The root cause is direct, unsanitized interpolation of untrusted configuration data into a command-executing build specification, mapping to CWE-78: Improper Neutralization of Special Elements used in an OS Command.

In this case, the Dockerfile acts as an indirect command execution medium: user-controlled fields from bento.yaml are written into the Dockerfile template without constraints, allowing attackers to introduce additional Dockerfile instructions.

When docker build processes these instructions, any injected RUN directives execute shell commands on the build host.

Conceptually, this is a form of templating injection where a configuration field, assumed to be a simple identifier (base image), is instead treated as trusted script content that the underlying build system executes.

Potential impact

  • Execution of arbitrary OS commands on the host that runs bentoml containerize and docker build.
  • Compromise of CI/CD agents, developer workstations, or build servers.
  • Theft or modification of sensitive data accessible from the build environment (secrets, tokens, SSH keys, environment variables, cached artifacts).
  • Insertion of backdoors or malware into produced container images, enabling downstream supply-chain attacks.
  • Lateral movement within the network from the compromised build host.

General mitigation guidance

Effective mitigation focuses on constraining how configuration values influence executable build steps and treating Dockerfiles as code, not as raw text sinks:

  • Treat fields like docker.base_image as data, not script: enforce strict patterns (e.g., registry/name:tag with no whitespace or control characters) and reject multi-line or otherwise malformed values.
  • Apply robust escaping and sanitization when interpolating configuration into templates, ensuring special characters and newlines cannot alter the structure of generated Dockerfile instructions.
  • Use whitelisting/allow-listing approaches for base images (e.g., selecting from a predefined set) instead of allowing arbitrary user-supplied values.
  • Isolate build processes by running docker build in locked-down, least-privilege environments (e.g., separate build nodes, limited filesystem access, reduced credentials) to minimize the blast radius of potential injection.
  • Separate trust levels: do not run containerization of untrusted or user-submitted bentos on the same infrastructure that stores sensitive secrets or production signing keys.

How teams detect issues like this

Detection typically involves both code-centric and pipeline-centric practices:

  • Static analysis and code review: Flag any templating where user- or config-controlled values are inserted into Dockerfiles, shell scripts, or command strings without validation or escaping. Look specifically for raw Jinja2 interpolations of configuration fields directly in Dockerfile templates.
  • Configuration validation: Implement schema validation for bento.yaml that rejects unexpected characters, multi-line values, or patterns inconsistent with legitimate base image references.
  • CI/CD policies: Enforce policies that scrutinize changes to bento.yaml and Dockerfile templates, requiring review by maintainers, especially for fields impacting base images or build instructions.
  • Runtime/build monitoring: Monitor build logs and generated Dockerfiles for unexpected RUN instructions or unusual network/file operations during builds, possibly via automated checks that diff against known-good templates.

Sources

SourceLink
github.comgithub.com/bentoml/BentoML/security/advisories/GHSA-78f9-r8mh-4xm2

Frequently asked

questions

It can be, depending on how BentoML is integrated. If a remote user can submit or influence bento.yaml files that are later containerized by an automated system (e.g., a model registry or multi-tenant platform that triggers bentoml containerize), then remote exploitation is possible. In smaller setups where only trusted developers author bento.yaml, the risk is more limited.

The attacker needs the ability to provide or modify a bento.yaml that will be used as input to the containerization process. This could be via source control access, contribution to a shared repository, integration hooks into CI, or any workflow where untrusted users can upload or edit Bento configurations.

The safest pattern is to enforce strict validation and encoding of all configuration values that affect build scripts or Dockerfiles. Treat docker.base_image as a constrained identifier, reject multi-line and malformed values, and ensure the template uses escaping or safe substitution mechanisms so user-controlled data cannot change the structure of Dockerfile instructions.

Apply a systematic policy that any time configuration can influence code, scripts, or build specifications, it must be treated as untrusted input. Combine schema validation, output encoding, defense-in-depth isolation for build environments, and automated checks within CI/CD to prevent untrusted configuration from being rendered into executable instructions without proper safeguards.

Find out what's already
exploitable in your codebase.