/

CVE-2026-44346

Severity:

HIGH RISK

(8.8)

Command Injection in Build Pipeline in BentoML

CVE-2026-44346

Analyzed

Vulnerability type

Category:

Command Injection in Build Pipeline

CWE:

CWE-78, CWE-94

Impact:

Arbitrary Command Execution during Docker Image Build

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

A crafted bentofile.yaml in BentoML can inject arbitrary shell commands into the generated Dockerfile via newline-injected values in envs[*].name.

When a victim runs bentoml containerize on a malicious bento, the unquoted RUN directives in the Docker build context may execute attacker-controlled commands on the host during image build.

Affected context

This vulnerability arises in workflows where:

  • Developers or CI systems import or consume bentos that include a bentofile.yaml, and
  • bentoml containerize is used to generate a Dockerfile and build images, and
  • The tool interpolates envs[*].name values into Dockerfile RUN directives without robust quoting or sanitization.

In such setups, newline characters and additional shell tokens in environment variable names can escape their intended context and form new Dockerfile instructions.

Exploit preconditions

  • Attack surface: Supply-chain and project import paths (malicious or untrusted bentofile.yaml).
  • Required access: Ability to introduce or modify a bentofile.yaml that will later be processed by bentoml containerize (e.g., via shared repositories, templates, or downloaded examples).
  • Trigger point: Running bentoml containerize to generate and then build a Docker image from the resulting Dockerfile.
  • Why exploitation is possible: The code that renders envs[*].name into the Dockerfile fails to safely quote or validate the value, allowing newline injection that splits or appends Dockerfile RUN directives and embeds arbitrary shell commands.

Why this happens

The underlying flaw is a classic command injection pattern in code generation logic.

BentoML takes user-controlled values from bentofile.yaml (specifically envs[*].name) and interpolates them directly into Dockerfile RUN instructions without enforcing valid identifier formats, stripping control characters, or applying strict quoting.

Because Dockerfile RUN lines are executed by a shell during docker build, any injected newline and subsequent text is interpreted as independent shell commands.

This aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), and is related to CWE-94: Improper Control of Generation of Code ('Code Injection') where untrusted configuration drives generation of executable build scripts.

Potential impact

  • Attackers may execute arbitrary shell commands on the Docker build host during image creation.
  • Malicious commands could install backdoors, exfiltrate secrets, or tamper with build artifacts.
  • Build outputs (container images) may be compromised, embedding malicious binaries or scripts.
  • Continuous Integration (CI) environments running automated container builds could be fully compromised.
  • Downstream deployments may run tampered images, enabling later-stage attacks in production.

General mitigation guidance

Robust mitigation centers on treating configuration-derived values as untrusted and constraining how they influence generated build instructions.

Defensive patterns include:

  • Strictly validating envs[*].name to allow only safe characters (e.g., alphanumerics, underscores, and hyphens) and rejecting or normalizing inputs with newlines or shell metacharacters.
  • Applying consistent quoting and escaping when interpolating configuration values into Dockerfiles or shell commands, ensuring they remain within their intended syntactic context.
  • Separating data from code by avoiding direct string concatenation of untrusted values into executable directives; where possible, generate structured representations and apply templating with automatic escaping.
  • Minimizing privileges of the Docker build environment and isolating build hosts, so that even if a generated RUN command misbehaves, its ability to impact the broader system is reduced.
  • Encouraging workflows where bentofile.yaml files are treated as code and subjected to review, signing, or provenance checks before being used in build pipelines.

How teams detect issues like this

Detection is primarily about identifying unsafe code-generation practices and anomalous build behaviors.

Potential strategies include:

  • Static analysis rules or linters that scan the codebase for patterns where configuration values are directly concatenated into Dockerfile instructions or shell commands without validation or quoting.
  • Code review checklists that flag any templating logic generating Dockerfile RUN lines from user- or configuration-controlled fields, especially if they support arbitrary strings.
  • CI policies that inspect generated Dockerfiles for unexpected line breaks, unusual RUN sequences, or obviously malformed environment variable names.
  • Monitoring build logs for unexpected commands, outbound connections, or package installations that are not part of the expected build recipe.
  • Optional use of automated security tools that model dataflow from configuration files into build scripts and highlight potential injection paths.

Sources

SourceLink
github.comgithub.com/bentoml/BentoML/security/advisories/GHSA-w2pm-x38x-jp44

Frequently asked

questions

Exploitation primarily occurs through supply-chain or collaboration vectors where a developer or CI system runs bentoml containerize against a malicious bento containing a crafted bentofile.yaml; attackers must get their configuration into a workflow that builds images.

An attacker needs the ability to introduce or modify a bentofile.yaml that will be used for containerization—for example, contributing to a repository, compromising a dependency source, or convincing a user to import and containerize an untrusted bento.

The safest pattern is to strictly sanitize and validate all configuration values that influence Dockerfile or shell generation, enforce allowed-character policies for envs[*].name, and ensure those values are always safely quoted or escaped when rendered into RUN directives.

Future prevention involves designing configuration-to-code paths with a strong trust boundary: treat all configuration as untrusted input, avoid direct string concatenation into executable contexts, adopt templating systems with automatic escaping, and incorporate security-focused code review and automated analysis into the development lifecycle.

Find out what's already
exploitable in your codebase.