CVE-2026-33744: Bentoml BentoML Has Dockerfile Command Injection Vulnerability

HIGH
Advisory Identifier: GHSA-jfjg-vc52-wqvf
CVSS 7.8
CWE-94
Published
Advisory Summary

CVE-2026-33744 is a HIGH (CVSS 7.8) bentoml has dockerfile command injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Bentoml libraries in the PyPI ecosystem. The issue involves bentoml has dockerfile command injection via system_packages in bentofile.yaml. Remediation is available by upgrading affected packages to version 1.4.37.

CVE-2026-33744 at a Glance

CVE Identifier CVE-2026-33744
GHSA Identifier GHSA-jfjg-vc52-wqvf
Severity HIGH
CVSS v3.1 Base Score 7.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Bentoml
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-33744

To remediate this vulnerability, upgrade all affected Bentoml dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

bentoml fixed: 1.4.37
pip install bentoml>=1.4.37
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show bentoml

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-33744, inspect your installed packages using pip:

pip show bentoml

Analyze the terminal output to locate any version of Bentoml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.37), your application is affected.

Note: The pip show bentoml command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Bentoml, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary The `docker.system_packages` field in `bentofile.yaml` accepts arbitrary strings that are interpolated directly into Dockerfile `RUN` commands without sanitization. Since `system_packages` is semantically a list of OS package names (data), users do not expect values to be interpreted as shell commands. A malicious `bentofile.yaml` achieves arbitrary command execution during `bentoml containerize` / `docker build`. ## Affected Component - `src/_bentoml_sdk/images.py:85-89` — `.format(packages=" ".join(packages))` into shell command - `src/bentoml/_internal/container/frontend/dockerfile/templates/base_debian.j2:13` — `{{ __options__system_packages | join(' ') }}` - `src/bentoml/_internal/bento/build_config.py:174` — No validation on `system_packages` - All distro install commands in `src/bentoml/_internal/container/frontend/dockerfile/__init__.py` ## Affected Versions All versions supporting `docker.system_packages` in `bentofile.yaml`, confirmed on 1.4.36. ## Steps to Reproduce 1. Create a project directory with: **service.py:** ```python import bentoml @bentoml.service class MyService: @bentoml.api def predict(self) -> str: return "hello" ``` **bentofile.yaml:** ```yaml service: "service:MyService" docker: system_packages: - "curl && id > /tmp/bentoml-pwned #" ``` 2. Run: ```bash bentoml build ``` 3. Examine the generated Dockerfile at `~/bentoml/bentos/my_service/<tag>/env/docker/Dockerfile`. Line 41 will contain: ```dockerfile RUN apt-get install -q -y -o Dpkg::Options::=--force-confdef curl && id > /tmp/bentoml-pwned # ``` 4. Running `bentoml containerize my_service:<tag>` will execute `id > /tmp/bentoml-pwned` as root during the Docker build. ## Root Cause The `system_packages` field values are treated as package names (data) by the user but are string-formatted directly into shell commands in the Dockerfile: ```python # images.py:85-89 self.commands.append( CONTAINER_METADATA[self.distro]["install_command"].format( packages=" ".join(packages) # No escaping ) ) ``` Where `install_command` is `"apt-get install -q -y -o Dpkg::Options::=--force-confdef {packages}"`. A `bash_quote` filter (wrapping `shlex.quote`) exists in the codebase and is registered in both Jinja2 environments, but it is only applied to environment variable values, never to `system_packages`. ## Impact 1. **Malicious repositories**: An attacker publishes an ML project with a crafted `bentofile.yaml`. Anyone who clones and builds it gets arbitrary code execution during `docker build`. 2. **CI/CD compromise**: Automated pipelines running `bentoml containerize` on PRs that modify `bentofile.yaml` are vulnerable. 3. **BentoCloud**: If BentoCloud builds images from user-supplied `bentofile.yaml`, this could achieve RCE on cloud infrastructure. 4. **Supply chain**: Shared bentos or model repos in the BentoML ecosystem can contain malicious configs. ## Suggested Fix ### Option 1: Input validation (recommended) Add a regex validator to `system_packages` in `build_config.py`: ```python import re VALID_PACKAGE_NAME = re.compile(r'^[a-zA-Z0-9][a-zA-Z0-9.+\-_:]*$') def _validate_system_packages(instance, attribute, value): if value is None: return for pkg in value: if not VALID_PACKAGE_NAME.match(pkg): raise BentoMLException( f"Invalid system package name: {pkg!r}. " "Package names may only contain alphanumeric characters, " "dots, plus signs, hyphens, underscores, and colons." ) system_packages: t.Optional[t.List[str]] = attr.field( default=None, validator=_validate_system_packages ) ``` ### Option 2: Output escaping Apply `shlex.quote()` to each package name before interpolation in `images.py:system_packages()` and apply the `bash_quote` Jinja2 filter in `base_debian.j2`.

CVE-2026-33744 Affected Bentoml Versions

1 component(s)
Fixed Versions:
1.4.37
Product / Package Ecosystem Affected Versions Fixed Version
bentoml
PyPI
< 1.4.37
1.4.37

References

Frequently Asked Questions

What is CVE-2026-33744?
CVE-2026-33744 is a security vulnerability in Bentoml involving BentoML has Dockerfile Command Injection via system_packages in bentofile.yaml under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Bentoml versions are affected?
Affected versions include releases prior to 1.4.37 across affected packages: bentoml.
What version fixes CVE-2026-33744?
Upgrading to 1.4.37 (or the latest patched release for your respective branch) resolves the vulnerability.
Is bentoml affected?
Yes, bentoml is affected in releases prior to 1.4.37. Upgrade your dependency to 1.4.37 or later.
What is the CVSS score of CVE-2026-33744?
CVE-2026-33744 has a CVSS v3.1 base score of 7.8 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-33744?
CVE-2026-33744 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check PyPI dependencies for CVE-2026-33744?
Run the dependency tree command: 'pip show bentoml'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-jfjg-vc52-wqvf",
  "modified" : "2026-06-08T20:04:21Z",
  "published" : "2026-03-26T07:32:44Z",
  "aliases" : [ "CVE-2026-33744" ],
  "summary" : "BentoML has Dockerfile Command Injection via system_packages in bentofile.yaml",
  "details" : "## Summary\n\nThe `docker.system_packages` field in `bentofile.yaml` accepts arbitrary strings that are interpolated directly into Dockerfile `RUN` commands without sanitization. Since `system_packages` is semantically a list of OS package names (data), users do not expect values to be interpreted as shell commands. A malicious `bentofile.yaml` achieves arbitrary command execution during `bentoml containerize` / `docker build`.\n\n## Affected Component\n\n- `src/_bentoml_sdk/images.py:85-89` — `.format(packages=\" \".join(packages))` into shell command\n- `src/bentoml/_internal/container/frontend/dockerfile/templates/base_debian.j2:13` — `{{ __options__system_packages | join(' ') }}`\n- `src/bentoml/_internal/bento/build_config.py:174` — No validation on `system_packages`\n- All distro install commands in `src/bentoml/_internal/container/frontend/dockerfile/__init__.py`\n\n## Affected Versions\n\nAll versions supporting `docker.system_packages` in `bentofile.yaml`, confirmed on 1.4.36.\n\n## Steps to Reproduce\n\n1. Create a project directory with:\n\n**service.py:**\n```python\nimport bentoml\n\n@bentoml.service\nclass MyService:\n    @bentoml.api\n    def predict(self) -> str:\n        return \"hello\"\n```\n\n**bentofile.yaml:**\n```yaml\nservice: \"service:MyService\"\ndocker:\n  system_packages:\n    - \"curl && id > /tmp/bentoml-pwned #\"\n```\n\n2. Run:\n```bash\nbentoml build\n```\n\n3. Examine the generated Dockerfile at `~/bentoml/bentos/my_service/<tag>/env/docker/Dockerfile`. Line 41 will contain:\n```dockerfile\nRUN apt-get install -q -y -o Dpkg::Options::=--force-confdef curl && id > /tmp/bentoml-pwned #\n```\n\n4. Running `bentoml containerize my_service:<tag>` will execute `id > /tmp/bentoml-pwned` as root during the Docker build.\n\n## Root Cause\n\nThe `system_packages` field values are treated as package names (data) by the user but are string-formatted directly into shell commands in the Dockerfile:\n\n```python\n# images.py:85-89\nself.commands.append(\n    CONTAINER_METADATA[self.distro][\"install_command\"].format(\n        packages=\" \".join(packages)  # No escaping\n    )\n)\n```\n\nWhere `install_command` is `\"apt-get install -q -y -o Dpkg::Options::=--force-confdef {packages}\"`.\n\nA `bash_quote` filter (wrapping `shlex.quote`) exists in the codebase and is registered in both Jinja2 environments, but it is only applied to environment variable values, never to `system_packages`.\n\n## Impact\n\n1. **Malicious repositories**: An attacker publishes an ML project with a crafted `bentofile.yaml`. Anyone who clones and builds it gets arbitrary code execution during `docker build`.\n2. **CI/CD compromise**: Automated pipelines running `bentoml containerize` on PRs that modify `bentofile.yaml` are vulnerable.\n3. **BentoCloud**: If BentoCloud builds images from user-supplied `bentofile.yaml`, this could achieve RCE on cloud infrastructure.\n4. **Supply chain**: Shared bentos or model repos in the BentoML ecosystem can contain malicious configs.\n\n## Suggested Fix\n\n### Option 1: Input validation (recommended)\n\nAdd a regex validator to `system_packages` in `build_config.py`:\n\n```python\nimport re\n\nVALID_PACKAGE_NAME = re.compile(r'^[a-zA-Z0-9][a-zA-Z0-9.+\\-_:]*$')\n\ndef _validate_system_packages(instance, attribute, value):\n    if value is None:\n        return\n    for pkg in value:\n        if not VALID_PACKAGE_NAME.match(pkg):\n            raise BentoMLException(\n                f\"Invalid system package name: {pkg!r}. \"\n                \"Package names may only contain alphanumeric characters, \"\n                \"dots, plus signs, hyphens, underscores, and colons.\"\n            )\n\nsystem_packages: t.Optional[t.List[str]] = attr.field(\n    default=None, validator=_validate_system_packages\n)\n```\n\n### Option 2: Output escaping\n\nApply `shlex.quote()` to each package name before interpolation in `images.py:system_packages()` and apply the `bash_quote` Jinja2 filter in `base_debian.j2`.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "bentoml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4.37"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.4.36"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/bentoml/BentoML/security/advisories/GHSA-jfjg-vc52-wqvf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-33744"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bentoml/BentoML"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/bentoml/PYSEC-2026-157.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-26T07:32:44Z",
    "nvd_published_at" : "2026-03-27T01:16:21Z"
  }
}