The vulnerability is a Server-Side Template Injection (SSTI) within the Jupyter Enterprise Gateway. The root cause lies in the _determine_kernel_pod_name function of the KubernetesProcessProxy class, located in enterprise_gateway/services/processproxies/k8s.py. This function processes the KERNEL_POD_NAME environment variable, which can be controlled by a user making an API request to start a new kernel. The vulnerable version of the code directly used the Jinja2 template engine to render this variable without any sanitization. An attacker could provide a malicious payload like {{ cycler.__init__.__globals__.os.popen("hostname").read() }} as the value for KERNEL_POD_NAME. The render method would execute this payload, allowing for remote code execution in the context of the Enterprise Gateway pod. The security patch (commit 1e6b2f35497682e6581c48cc6d273644d32ab89e) addresses this by removing the direct use of the Jinja2 rendering engine and replacing it with a custom, safer function (_safe_template_substitute) that uses a regular expression to perform simple variable substitution, explicitly preventing the evaluation of complex expressions, function calls, or attribute access, thus mitigating the SSTI vulnerability.