The vulnerable code is twelve lines
CVE-2026-44181 is enterprise_gateway/services/processproxies/k8s.py, at the parent commit of the August 8, 2025 fix:
def _determine_kernel_pod_name(self, **kwargs: dict[str, Any] | None) -> str:
pod_name = kwargs["env"].get("KERNEL_POD_NAME")
if pod_name is None:
pod_name = KernelSessionManager.get_kernel_username(**kwargs) + "-" + self.kernel_id
else:
self.log.debug(f"Processing KERNEL_POD_NAME based on env var => {pod_name}")
if "{{" in pod_name and "}}" in pod_name:
self.log.debug("Processing KERNEL_POD_NAME as jinja template")
# Create Jinja2 environment
keywords = {}
for name, value in kwargs["env"].items():
if name.startswith("KERNEL_"):
keywords[name.lower()] = value
keywords["kernel_id"] = self.kernel_id
self.log.debug("Processing pod_name jinja template")
env = Environment(loader=BaseLoader(), autoescape=True)
pod_name = env.from_string(pod_name).render(**keywords)
pod_name on line one is the value the client sent for the KERNEL_POD_NAME environment variable. The variable arrives through Enterprise Gateway's REST API, which accepts a JSON env dictionary on every kernel-start request and copies every KERNEL_* prefixed entry into the kernel-launch environment. Three nested conditions later, that value is the first argument to env.from_string(...). In Jinja2's API, the argument to from_string is the template source. The remaining call, .render(**keywords), evaluates the template against a namespace.
A request body of {"env": {"KERNEL_POD_NAME": "bdawg-{{7*7}}"}} produces a pod named bdawg-49. A request body of:
{"env": {"KERNEL_POD_NAME": "bdawg-{{cycler.__init__.__globals__.os.popen('hostname').read()}}"}}
renders by reaching for the cycler builtin Jinja2 exposes in its runtime namespace, walking through its __init__ method's __globals__ to find the os module imported in jinja2.utils, calling os.popen('hostname').read(), and interpolating the result into the rendered string. The rendered string becomes the pod name. The string is also the proof of execution; the attacker's command ran inside the Enterprise Gateway process, before any pod existed, with the gateway's service-account token reachable on the local filesystem at /var/run/secrets/kubernetes.io/serviceaccount/token. That token is what the GHSA advisory is describing when it warns that the bug "enables an attacker to steal the gateway's Kubernetes service account token."
The autoescape=True argument to Environment is what makes the choice interesting. Jinja2's autoescape is an HTML-encoding pass applied to expression output before that output is inserted into the rendered string. It does not constrain which expressions evaluate. It does not restrict which builtins the template can reference. It does not stop cycler.__init__.__globals__.os.popen from resolving. jinja2.sandbox.SandboxedEnvironment does that. The pre-patch code imports Environment from jinja2, not SandboxedEnvironment, and passes the attacker's bytes to from_string directly.
The flag belongs in the codebase. On the manifest-rendering path elsewhere in the project, where the template source is the checked-in kernel-pod.yaml.j2 file and the variables are filled from server state, autoescape does useful work encoding < as < inside YAML scalar values. The path that takes a client-supplied string and runs from_string on it is a different path, and autoescape has nothing to say there.
The fix understands the threat
def _safe_template_substitute(self, template_str: str, variables: dict) -> str | None:
"""
Safely substitute variables in Jinja2-style template syntax.
Only supports simple variable substitution: {{ variable_name }}
Logs missing variables and returns None if any are missing.
"""
# Pattern to match {{ variable_name }} with optional whitespace
# Explicitly exclude variables starting with underscore to prevent magic method attacks
pattern = r'\{\{\s*([a-zA-Z][a-zA-Z0-9_]*)\s*\}\}'
missing_vars = []
def replace_var(match):
var_name = match.group(1)
if var_name in variables:
return str(variables[var_name])
else:
missing_vars.append(var_name)
return match.group(0)
result = re.sub(pattern, replace_var, template_str)
if '{{' in result and '}}' in result:
self.log.warning(
"Invalid template syntax detected in KERNEL_POD_NAME: contains unsupported expressions"
)
return None
...
The replacement matches {{ variable_name }} with an identifier-only character class. The character class begins at [a-zA-Z], not [_a-zA-Z]. The comment names "magic method attacks." A second sweep at the end of the function rejects any input that still contains both {{ and }} after substitution, which catches anything the identifier-only regex did not match. The function returns None when it fails, and the caller falls back to the default pod name.
The PR shipped 231 lines of new tests. One test is named test_malicious_template_injection_prevention. Its payload list includes ''.__class__.__mro__[1].__subclasses__()[104].__init__.__globals__['sys'].exit(), {{ kernel_id.__class__ }}, and {{ kernel_id.__globals__ }}. The author of the PR knew what a Python SSTI looks like in 2025. The author of the PR is the same account that introduced the Jinja2 environment in 2024, the same account that authored the YAML-injection fix in 2026, and the same account credited as lresende on the GHSA advisory's remediation byline. The maintainer's commit message on August 8, 2025 was Fix KERNEL_POD_NAME substitution to avoid SSTI. The release that made that commit installable through pip was tagged on June 1, 2026.
v3.2.3 to v3.3.0 was 833 days
git log v3.2.3..v3.3.0 -- enterprise_gateway/services/processproxies/k8s.py:
571c992 2025-08-17 change V1Subject to RbacV1Subject in k8s.py (#1384)
1e6b2f3 2025-08-08 Fix KERNEL_POD_NAME substitution to avoid SSTI (#1412)
Two commits. The first is a Kubernetes API name change. The second is the SSTI fix. Between the v3.2.3 tag on February 19, 2024 and the v3.3.0 tag on June 1, 2026, no version of this file shipped to a release tag other than what was in v3.2.3. The release pipeline was idle. The trunk was not.
The introduction of the Jinja2 environment for KERNEL_POD_NAME was commit dd9e4ba in PR #1368, authored by the same maintainer, with timestamp 2024-02-19 16:16:21 -0800. The v3.2.3 tag, commit 7c3c598, has timestamp 2024-02-19 21:03:27 -0800. Four hours and forty-seven minutes between the bug landing and the bug shipping to pip. The release notes for v3.2.3 list the PR by its title, "Add jinja template support to pod-name config via environment variable."
The release pipeline being idle for 833 days is not unusual for a project at maintenance velocity. Jupyter Enterprise Gateway has one primary maintainer; releases get cut when the maintainer cuts them. The unusual choice is to land a security fix during that window and not cut a patch release for the fix. The commit message is a public statement that the prior released version was vulnerable. Anyone reading the maintainer's commits had a roadmap.
The GHSA advisory credits ben-elttam as the reporter. elttam is an Australian security consultancy. Two readings of the timeline are available. The first is that ben-elttam reported the bug to the maintainer in mid-2025, the maintainer fixed it in August 2025, and the project sat on releasing the fix for nearly ten months. The second is that ben-elttam found the bug by reading the maintainer's August 2025 commit log, filed an advisory against the still-vulnerable release on pip, and the project cut v3.3.0 in response. The advisory's publication date is two days after v3.3.0 shipped. Neither reading lets the release pipeline off. This is release-lag-disclosure in its canonical shape: the fix was a published source artifact for nine-and-a-half months while the package manager kept serving the unpatched binary.
The substrate is one Jinja2 environment
v3.3.0 also fixed GHSA-cfw7-6c5v-2wjq, the YAML structure-injection bug that lets KERNEL_* environment variables decode YAML escape sequences inside the Kubernetes manifest template and inject new resource declarations into the rendered output. That fix landed eight months after the SSTI fix, in commit 2258a41 on April 27, 2026. Same author. Same KERNEL_*-into-Jinja2 surface. Different exploit shape: the SSTI ran env.from_string(value).render(...) on the client string in k8s.py; the YAML injection ran yaml.safe_load(value) on the client string in launch_kubernetes.py, fed the parsed structure into a Jinja2 template that renders into YAML, and let yaml.safe_load_all re-parse the result. The patch for the second bug introduces a yaml_safe Jinja2 filter and adds post-render validation that the rendered manifest contains only expected resource kinds. The patch's commit message names the substrate without using the word: "Attacker-controlled KERNEL_* environment variables were interpolated into Kubernetes manifests via Jinja2 templates."
This is design-debt-driver in compact form. The substrate is the Enterprise Gateway feature that walks os.environ for KERNEL_* prefixed values and feeds them, individually or in batch, into Jinja2 templates that render Kubernetes manifests. The introduction of KERNEL_POD_NAME Jinja2 expansion is dated February 2024. The introduction of the YAML round-trip is older, present in launch_kubernetes.py since the initial Kubernetes process proxy. Two consecutive CVEs against the same substrate were patched in the same release. The catalog's Apache Camel CVE-2026-40858 exhibit is the same shape one component layer up: one substrate, eight separate CVEs, one maintainer cleaning up one component at a time. Enterprise Gateway's substrate produced two and is patched at the substrate level for two specific sinks. The next CVE on this surface, if there is one, will be a third call site reading KERNEL_* env values into a sink with a different parser.
The CVE caught up to the release, not to the fix
CVE-2026-44181 is dated June 3, 2026. The fix commit is dated August 8, 2025. The user-installable release containing the fix is dated June 1, 2026. The advisory's "patched in 3.3.0" field is correct and complete. The advisory's "affected versions" field, >= 2.0.0rc2, < 3.3.0, is also correct and complete; the last release tag in that range is v3.2.3, the release that shipped the unfixed code on February 19, 2024.
The version on pip on November 1, 2025, three months after the SSTI fix was committed to main and titled "to avoid SSTI" in the public git log, was v3.2.3. The version on pip on February 8, 2026, six months after the fix, was v3.2.3. The version on pip on May 31, 2026, the day before v3.3.0 was tagged, was v3.2.3. On each of those days, an operator running pip install --upgrade jupyter_enterprise_gateway against PyPI got the SSTI.
PoC: github.com/advisories/GHSA-f49j-v924-fx9w.
The SSTI fix was a public commit. The CVE was a published release. They are not the same event.