GHSA-99MG-9X9R-5FJ4
OS command injection via KERNEL_ANACONDA_ENV reaching eval exec in Conductor Spark launch (recomputed PYSPARK_PYTHON)
CVSS:3.1/AV:N/AC:L/PR:L/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-99MG-9X9R-5FJ4 divulgada · CVSS 8.8 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
## Summary
Jupyter Enterprise Gateway allows an authenticated IBM Spectrum Conductor user to achieve OS command execution on the Enterprise Gateway host by injecting shell metacharacters through the client-settable `KERNEL_ANACONDA_ENV` environment variable. The value is concatenated into `KERNEL_PYSPARK_PYTHON`, spliced unquoted into `SPARK_OPTS`, and executed via `eval exec` in the Conductor launch script.
## Root Cause
In the Conductor JWT logon path, `ConductorClusterProcessProxy._performConductorJWTLogonAndRetrieval()` recomputes:
env_dict["KERNEL_PYSPARK_PYTHON"] = (
response["parameters"]["deploy_home"]["value"]
+ "/anaconda/envs/"
+ env["KERNEL_ANACONDA_ENV"] # raw, unquoted client value
+ "/bin/python"
)(`enterprise_gateway/services/processproxies/conductor.py`, ~line 725 on v3.3.0). The sibling URL components (`KERNEL_ANACONDA_INST_UUID`, `KERNEL_IG_UUID`) are passed through `quote()`, but `KERNEL_ANACONDA_ENV` is not. `_update_launch_info()` then splices the recomputed `KERNEL_PYSPARK_PYTHON` into `SPARK_OPTS` as `--conf spark.pyspark.python={pyspark_python}` (unquoted), and `etc/kernelspecs/spark_python_conductor_cluster/bin/run.sh` runs `eval exec "${SPARK_OPTS}" ...` on the gateway host.
On the latest release (v3.3.0) there is no input validation at all for `KERNEL_*` values — neither a character filter nor an eval-reaching allowlist exists in that release. (Both were added only in an unreleased commit for GHSA-j63f-r6hc-x235, and even that allowlist does not cover `KERNEL_ANACONDA_ENV`.)
## Impact
Arbitrary OS command execution on the Enterprise Gateway host as the gateway service account (or as the `sudo -u ${KERNEL_USERNAME}` impersonation user when `EG_IMPERSONATION_ENABLED=True`). This crosses a trust boundary: a legitimate kernel request runs user code on the Spark cluster, whereas this injection runs code as the gateway identity on the gateway host — capabilities beyond what the precondition (requesting a kernel) grants.
Proof of Concept
POST /api/kernels
Header: Jwt-Auth-User-Payload: {"accessToken":"<valid-jwt>"}
Body: {
"name": "spark_python_conductor_cluster",
"env": {
"KERNEL_ANACONDA_ENV": "x|touch /tmp/pwned|y",
"KERNEL_ANACONDA_INST_UUID": "<valid-uuid>",
"KERNEL_IG_UUID": "<valid-uuid>"
}
}The `|` pipe runs `touch /tmp/pwned` in a subshell on the gateway host (the `exec` only applies to the first stage; `;`/`&&` are swallowed by `exec`, but `|` is not).
## Attack Chain
1. Entry: `POST /api/kernels` with `KERNEL_ANACONDA_ENV="x|touch /tmp/pwned|y"` (`handlers.py` `_build_kernel_env` forwards any `KERNEL_*` key). Guard on v3.3.0: none. Guard on HEAD: `PROHIBITED_ENV_VALUE_CHARS = frozenset("$`\n\r\x00")`. Bypass proof: `|` and space are not members — value passes.
2. Check: `RemoteKernelManager._validate_client_env` → `validate_eval_reaching_env` (HEAD only). Guard: scans only vars in `EVAL_REACHING_ENVS` / `*_OPTS` keys / names referenced by a `*_OPTS` kernelspec entry. Bypass proof: Conductor `SPARK_OPTS` references only `KERNEL_ID` and `KERNEL_EXTRA_SPARK_OPTS`; `KERNEL_ANACONDA_ENV` is in none of these sets — reimplemented HEAD validator returns `('PASSED', 'checked=[]')`.
3. Processing: `_performConductorJWTLogonAndRetrieval` recomputes `KERNEL_PYSPARK_PYTHON` from the raw client value AFTER validation (`conductor.py` ~725). The taint is reintroduced into an eval-reaching var post-validation.
4. Sink: `_update_launch_info` → `SPARK_OPTS` unquoted → `run.sh` `eval exec "${SPARK_OPTS}"`. Bypass proof: empirically, `--conf spark.pyspark.python=...x|touch /tmp/pwned|y` under `eval exec` created the marker file.
5. Impact: OS command execution on the gateway host as the gateway service account.
## Bypass Evidence
- Reimplemented HEAD `validate_eval_reaching_env` against the payload → `('PASSED', 'checked=[]')`; control `KERNEL_PYSPARK_PYTHON` with the same payload → `REJECTED`.
- v3.3.0 `git show v3.3.0:.../handlers.py` has no `PROHIBITED_ENV_VALUE_CHARS`; `git show v3.3.0:.../processproxy.py` has no `validate_eval_reaching_env`.
- Bash sink test: `eval exec` with a piped `--conf` value created `/tmp/pwned`.
## Affected Versions
`<= 3.3.0` (latest release). The unreleased 3.4.0 allowlist still omits `KERNEL_ANACONDA_ENV`, so the issue persists on current `main`.
## Suggested Fix
Quote the client value when building `KERNEL_PYSPARK_PYTHON` (e.g. `shlex.quote(env["KERNEL_ANACONDA_ENV"])`), and add `KERNEL_ANACONDA_ENV` to the eval-reaching validation set so recomputed-after-validation variables are re-scanned.
---
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-99mg-9x9r-5fj4Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
