/

CVE-2026-35043

Severity:

HIGH RISK

(7.8)

OS Command Injection in BentoML Cloud Deployment Path

CVE-2026-35043

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution on CI/CD Infrastructure

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

BentoML's cloud deployment pipeline previously interpolated the system_packages value directly into a shell command using an f-string without proper quoting or sanitization.

When an attacker can influence system_packages, they may inject arbitrary shell commands into the generated setup.sh script, leading to remote code execution on the CI/CD build infrastructure during cloud deployment.

Affected context

This vulnerability arises in BentoML environments using the cloud deployment path, where deployment configuration values (such as system_packages) are used to generate shell scripts executed in the BentoCloud build environment.

The issue is specifically tied to a code path in src/bentoml/_internal/cloud/deployment.py that constructs a shell command via an f-string and embeds system_packages without quoting or escaping, making any untrusted or user-controlled content in that field risky when deployments are triggered.

Exploit preconditions

  • Attack surface: BentoML cloud deployment pipeline (BentoCloud build infrastructure).
  • Required access: Ability to supply or modify deployment configuration that controls system_packages (e.g., via project configuration, deployment specification, or CI variables).
  • Trigger point: Initiation of a cloud deployment that causes BentoML to generate and upload setup.sh, which is then executed by the cloud build system.
  • Why exploitation is possible: The system_packages value is interpolated directly into a shell command using an f-string without quoting or escaping, allowing shell metacharacters to break out of the intended context and execute attacker-controlled commands.

Why this happens

The core issue is a classic OS command injection, mapped to CWE-78: Improper Neutralization of Special Elements used in an OS Command.

Instead of treating system_packages as data and passing it to the shell via a safe API, the code constructs a shell command string with direct interpolation, leaving any embedded spaces, semicolons, backticks, or other metacharacters unfiltered.

This pattern blurs the boundary between code and data in shell scripts, so user-influenced values can alter the control flow of the command line, enabling arbitrary command execution when the resulting setup.sh script runs in the CI/CD environment.

Potential impact

  • Compromise of the CI/CD build environment running BentoCloud deployments.
  • Execution of arbitrary commands with the privileges of the build agent or container.
  • Theft or modification of sensitive build artifacts, environment variables, or credentials accessible in the pipeline.
  • Lateral movement from the CI/CD tier into connected services or infrastructure.
  • Tampering with deployed AI models or application components, leading to supply-chain risk.

General mitigation guidance

Effective mitigation focuses on separating data from shell execution and reducing trust in deployment configuration values:

  • Prefer high-level process execution APIs (e.g., passing arguments as arrays) rather than constructing shell command strings.
  • If shell usage is unavoidable, quote and escape all interpolated variables and restrict allowed characters for fields like system_packages through validation.
  • Treat deployment configuration as untrusted input by default, even if nominally controlled by internal users, and validate against an allowlist of known-safe package names or patterns.
  • Run CI/CD build steps and deployment preparation in hardened, least-privilege environments with minimized access to secrets and infrastructure.
  • Introduce secure-by-default helper functions for script generation so developers avoid direct f-string shell construction.

How teams detect issues like this

Security teams can look for this pattern using a combination of static analysis and code review:

  • Configure static analysis rules to flag string interpolation or concatenation used to build shell commands, especially where user or configuration input (like system_packages) is involved.
  • Add code review checklists that highlight any usage of os.system, subprocess with shell=True, or generated shell scripts, and require justification and safe handling patterns.
  • Implement policy-based checks in CI that scan for unsafe shell construction patterns (e.g., grep or semgrep rules around deployment-related modules and script generation).
  • Periodically review CI/CD logs for anomalous commands or unexpected behavior during cloud builds, which may indicate attempted command injection.

Sources

SourceLink
github.comgithub.com/bentoml/BentoML/security/advisories/GHSA-fgv4-6jr3-jgfw

Frequently asked

questions

It can be, if an attacker can influence the deployment configuration or fields that map to system_packages through remote interfaces such as APIs, configuration repositories, or CI inputs. Once they control that value and a deployment is triggered, their payload can execute in the cloud build environment.

The attacker must be able to supply or modify the configuration used for BentoML cloud deployments, typically the same access required to define or edit deployment specs or CI/CD variables. They do not need direct shell access to the build infrastructure itself.

The safest general pattern is to avoid passing interpolated strings to a shell. Use structured process execution where arguments are supplied as a list, and validate system_packages against strict allowlists. If shell scripting is unavoidable, ensure all variables are robustly quoted and restricted to safe character sets.

Adopt secure coding standards for CI/CD and deployment code paths, enforce automated checks for shell command construction, and encapsulate script generation behind vetted utilities. Regular security reviews of build and deployment tooling, combined with input validation on configuration parameters, help prevent command injection vulnerabilities from reappearing.

Find out what's already
exploitable in your codebase.