Summary
A path traversal issue in BentoML's bentofile.yaml configuration allows attacker-controlled file path fields to reference arbitrary locations on the builder's filesystem.
If a victim builds a malicious BentoML project, sensitive files can be silently bundled into the resulting bento artifact, potentially exposing secrets via registries or downstream deployments.
Affected context
This vulnerability impacts workflows where:
- Developers or CI systems consume untrusted or shared BentoML projects.
- The
bentofile.yamlfile is accepted without strict validation or sanitization. - Build processes run with access to sensitive files (e.g., SSH keys, cloud credentials, environment configuration).
- Generated bento artifacts are later stored in registries, shared with other teams, or deployed to production.
The issue is triggered when the BentoML tooling processes certain file path fields in bentofile.yaml and includes referenced files into the bento archive without enforcing safe path constraints.
Exploit preconditions
- Attack surface: The build pipeline that consumes and builds BentoML projects using
bentofile.yaml. - Required access: Ability to provide or modify a
bentofile.yamlconsumed by a victim (e.g., via a repository contribution, shared template, or downloaded example). - Trigger point: Execution of
bentoml buildor equivalent build command that processes: descriptiondocker.setup_scriptdocker.dockerfile_templateconda.environment_yml- Why exploitation is possible: The build logic treats these path fields as trusted and follows paths that can traverse directories (e.g.,
../segments), allowing access to files outside the intended project root, which are then embedded into the bento archive.
Why this happens
The underlying bug aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
In abstract terms, the build system:
- Accepts user-controlled file path values from a configuration file (
bentofile.yaml). - Resolves and reads those paths on the host filesystem without enforcing a confined root, canonicalization checks, or normalization safeguards.
- Uses the referenced files as build inputs or metadata and packages them into the final artifact.
This pattern allows configuration authors to escape the intended project directory and reference arbitrary files, which is a classic path traversal scenario arising from missing or incomplete validation on filesystem access patterns.
Potential impact
- Exfiltration of sensitive files (SSH private keys, API keys, cloud credentials,
.envfiles, configuration secrets). - Leakage of proprietary source code or internal documentation into publicly shared bento images.
- Silent inclusion of environment-specific details that aid lateral movement or targeted attacks.
- Supply-chain compromise, where downstream consumers deploy bento artifacts unknowingly containing embedded secrets.
- Regulatory or compliance exposure if confidential or regulated data is inadvertently distributed.
General mitigation guidance
Effective mitigation focuses on constraining file access and reducing implicit trust in configuration-controlled paths:
- Restrict file resolution for configuration-driven paths to a well-defined project root or allowed subdirectories, rejecting any path that attempts to traverse upwards or use absolute locations.
- Normalize and canonicalize paths before use, and perform checks against an allowlist of directories or file patterns.
- Treat
bentofile.yamlas untrusted input in shared or multi-tenant environments, and introduce schema validation that enforces safe path formats. - Run build pipelines with the principle of least privilege:
- Limit the filesystem view (e.g., chroot, containerized builds with minimal mounts).
- Avoid mounting sensitive directories into build containers unless strictly necessary.
- Encourage internal policies that disallow building artifacts directly from unreviewed external templates or examples.
How teams detect issues like this
Organizations can look for this class of exposure using several approaches:
- Static analysis / configuration linting:
- Rules that flag relative paths with
../segments or absolute paths inbentofile.yaml. - Policy checks that enforce all referenced files to reside under a project-specific directory.
- Code review signals:
- Configuration that references system paths (e.g.,
/home/,/root/,/etc/,.ssh/). - Suspicious additions or modifications to
docker.*orconda.*path fields in pull requests. - Build-time enforcement:
- Instrument build tooling to log and audit every external file included in bento artifacts.
- Fail builds when unexpected directories or sensitive path patterns are referenced.
- Artifact inspection:
- Post-build scanning of bento archives for known sensitive file names or patterns.
- Integration of secret-scanning tools in CI pipelines for artifacts, not just source code.

