GHSA-M434-R2PF-QR3G
Unauthenticated OS command injection via KERNEL_LAUNCHERS_DIR reaching eval exec in Spark-on-Kubernetes launch (gateway host)
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-M434-R2PF-QR3G divulgada · CVSS 9.8 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
## Summary
Jupyter Enterprise Gateway allows OS command execution on the Enterprise Gateway host through the client-settable `KERNEL_LAUNCHERS_DIR` environment variable. On a default install (no auth token) this is unauthenticated. The value is used to build `PROG_HOME` in the Spark-on-Kubernetes `run.sh`, which is executed via `eval exec` as a local subprocess on the gateway host (the spark-submit driver launcher, not inside the kernel pod).
## Root Cause
`KERNEL_LAUNCHERS_DIR` is forwarded like any `KERNEL_*` variable and is never validated in any Python code (`grep -rn LAUNCHERS_DIR --include=*.py` = zero hits). In `etc/kernelspecs/spark_python_kubernetes/bin/run.sh`:
KERNEL_LAUNCHERS_DIR=${KERNEL_LAUNCHERS_DIR:-/usr/local/bin/kernel-launchers}
PROG_HOME=${KERNEL_LAUNCHERS_DIR}/python
...
eval exec \
... \
"local://${PROG_HOME}/scripts/launch_ipykernel.py" \
...This script runs on the gateway host: `KubernetesProcessProxy.launch_process` → `ContainerProcessProxy.launch_process` → `self.launch_kernel(kernel_cmd)` (module-level `launch_kernel` = local `Popen`). It is the spark-submit driver launcher, not in-pod execution.
On the latest release (v3.3.0) there is no input validation for `KERNEL_*` values at all. On current `main` the GHSA-j63f allowlist does not cover `KERNEL_LAUNCHERS_DIR`.
## Impact
Arbitrary OS command execution in the Enterprise Gateway server process on the gateway host, with the gateway's identity and cluster credentials (the Kubernetes service-account token, which the project documents as broadly privileged). Unauthenticated by default.
Proof of Concept
POST /api/kernels
Body: {
"name": "spark_python_kubernetes",
"env": {"KERNEL_LAUNCHERS_DIR": "/x|touch /tmp/pwned|y"}
}`PROG_HOME` becomes `/x|touch /tmp/pwned|y/python`; the pipe stage runs `touch /tmp/pwned` in a subshell on the gateway host when `eval exec` evaluates the `local://${PROG_HOME}/...` argument.
## Attack Chain
1. Entry: `POST /api/kernels` with `KERNEL_LAUNCHERS_DIR="/x|touch /tmp/pwned|y"`. Guard on v3.3.0: none (no char filter, no allowlist). Guard on HEAD: `PROHIBITED_ENV_VALUE_CHARS`. Bypass proof: `|`/space not in the frozenset; passes string-type + 4096-length checks.
2. Check: `validate_eval_reaching_env` (HEAD only). Bypass proof: `KERNEL_LAUNCHERS_DIR` not in `EVAL_REACHING_ENVS`, not `*_OPTS`, not referenced by any `*_OPTS` kernelspec entry — reimplemented HEAD validator returns `('PASSED', 'checked=[]')`.
3. Check: `KubernetesProcessProxy.validate_client_env` / `ContainerProcessProxy.validate_client_env`. Guard: inspects only images, volumes, namespace, service-account, extra-spark-opts. Bypass proof: variable never referenced in those checks.
4. Sink: `run.sh` `PROG_HOME=${KERNEL_LAUNCHERS_DIR}/python` → `eval exec ... "local://${PROG_HOME}/..."`, run via local `Popen` on the gateway host. Bypass proof: empirically, `PROG_HOME=/x|touch /tmp/pwned|y/python` under `eval exec` created the marker file.
5. Impact: OS command execution in the gateway server process as the gateway service account.
## Bypass Evidence
- `grep -rn LAUNCHERS_DIR --include=*.py` → zero hits (no Python validation on any version).
- Reimplemented HEAD `validate_eval_reaching_env` → `('PASSED', 'checked=[]')`.
- Default auth: `eg_auth_token = os.getenv("EG_AUTH_TOKEN", os.getenv("KG_AUTH_TOKEN", ""))` = empty; `TokenAuthorizationMixin.prepare` is a no-op when the token is empty → unauthenticated.
- Bash sink test: `eval exec ... local://${PROG_HOME}/...` with a piped value created `/tmp/pwned`.
## Affected Versions
`<= 3.3.0` (latest release). The unreleased 3.4.0 allowlist still omits `KERNEL_LAUNCHERS_DIR`, so the issue persists on current `main`. Equivalent sinks exist in `spark_R_kubernetes` and `spark_scala_kubernetes` `run.sh`.
## Suggested Fix
Validate `KERNEL_LAUNCHERS_DIR` against an allowlist / reject shell metacharacters, or quote `PROG_HOME` usage, and add the variable to the eval-reaching validation set.
---
Reported by zx (Jace) — GitHub: @manus-use
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypijupyter_enterprise_gateway |
Sin parche | — | — | 3.4.0 afectada |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/jupyter-server/enterprise_gateway/security/advisories/GHSA-m434-r2pf-qr3gLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
