/

CVE-2026-33744

Severity:

HIGH RISK

(7.8)

Code Injection in BentoML bentofile.yaml

CVE-2026-33744

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Execution during Container Build

Severity:

HIGH RISK

(7.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 versions prior to 1.4.37 allow arbitrary command execution during container image builds through the docker.system_packages field in bentofile.yaml.

Because arbitrary strings from system_packages are interpolated directly into Dockerfile RUN commands without sanitization, a malicious or compromised configuration file can inject shell commands into the build process.

Affected context

This vulnerability appears in BentoML projects that:

  • Use bentofile.yaml to define container build configuration
  • Rely on the docker.system_packages field to declare OS packages
  • Invoke bentoml containerize or otherwise trigger docker build using generated Dockerfiles

The risk is elevated in workflows where bentofile.yaml is obtained from external sources, shared repositories, or automated pipelines where its contents are not reviewed or trusted by operators.

Exploit preconditions

  • Attack surface: The BentoML build pipeline, specifically Docker image creation via bentoml containerize or equivalent docker build commands.
  • Required access: Ability to create, modify, or influence bentofile.yaml in the project being containerized (e.g., via repository write access, pull requests merged without scrutiny, or supply-chain compromise).
  • Trigger point: Execution of the container build process that reads docker.system_packages and interpolates its values into Dockerfile RUN instructions.
  • Why exploitation is possible: The system_packages field is treated as data but is composed into shell command lines without quoting, escaping, or validation, enabling injected tokens to be interpreted as additional shell commands during the build.

Why this happens

The core issue is treating configuration data as executable shell content. The docker.system_packages field is conceptually a list of OS package identifiers, but during Dockerfile generation its entries are concatenated directly into RUN instructions.

Without proper escaping, quoting, or structural separation between data and command syntax, malicious values can break out of the intended package list and introduce arbitrary shell operators and commands. This aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), where untrusted input is incorporated into executable statements—in this case, shell code inside Docker build steps.

Potential impact

  • Execution of arbitrary shell commands during container image build.
  • Installation of backdoors or malicious binaries into generated images.
  • Exfiltration of secrets available to the build environment (e.g., tokens, credentials, build-time environment variables).
  • Compromise or lateral movement within CI/CD infrastructure that performs the build.
  • Tampering with application behavior through modified runtime dependencies in the built container.

General mitigation guidance

Defenses generally focus on treating configuration fields as data only and hardening the build pipeline:

  • Use structured representations for package lists (e.g., arrays) and compose them into commands using robust escaping or parameterization patterns.
  • Avoid direct string interpolation of untrusted configuration into shell commands; instead, use APIs or templating approaches that clearly separate commands from arguments.
  • Apply input validation to configuration fields that ultimately influence build scripts, rejecting values that contain shell metacharacters or unexpected whitespace/control operators.
  • Run build processes and CI/CD workers with least privilege, limiting access to sensitive credentials and host resources so that even if build-time commands are abused, impact is constrained.
  • Prefer secure-by-default templates for Dockerfiles and build scripts that minimize custom shell concatenation and instead rely on well-defined build steps.

How teams detect issues like this

Organizations can identify and monitor for this class of issue through:

  • Static analysis and linting: Rules that flag concatenation of configuration-derived strings into Dockerfile RUN commands or shell statements without escaping.
  • Configuration review: Code review checklists that explicitly require inspection of bentofile.yaml and similar build-time configuration for executable content or suspicious tokens (e.g., ;, &&, |, backticks).
  • Policy enforcement in CI: Pipelines that block builds when configuration fields include disallowed shell metacharacters or when Dockerfile templates deviate from vetted patterns.
  • Image and build auditing: Scanning generated images for unexpected binaries, scripts, or outbound network behavior, and correlating with build logs to detect anomalous commands executed during docker build.

Sources

SourceLink
github.comgithub.com/bentoml/BentoML/security/advisories/GHSA-jfjg-vc52-wqvf

Frequently asked

questions

It is not directly exploitable over the network in a running BentoML service. Exploitation typically occurs when a malicious or tampered bentofile.yaml is built by a developer or CI system, leading to code execution during image creation.

An attacker needs the ability to influence the bentofile.yaml used for containerization—for example, by committing to or compromising the source repository, injecting content via a dependency or template, or having their configuration built by a CI system.

The safest pattern is to ensure that configuration values are never treated as raw shell fragments. Build logic should treat system_packages as data, use structured lists, and construct commands via safe argument passing or well-escaped templating rather than direct string interpolation.

To prevent similar vulnerabilities, design configuration schemas that clearly separate data from executable logic, enforce validation on fields that influence build or runtime commands, and integrate security reviews and automated checks into CI/CD so that new or modified build templates are scrutinized for code-injection patterns.

Find out what's already
exploitable in your codebase.