GHSA-VJJC-H367-2GX3
Root-impersonation denylist bypass via trailing whitespace in KERNEL_USERNAME (authorization check not normalized)
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-VJJC-H367-2GX3 divulgada · CVSS 9.9 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
## Summary
Jupyter Enterprise Gateway authorizes impersonated kernel launches by testing the client-supplied `KERNEL_USERNAME` against the `unauthorized_users` denylist (default `{"root"}`) using a raw, un-normalized Python string-membership test. Submitting `KERNEL_USERNAME="root "` (trailing space) evades the denylist (`"root " != "root"`), passes both character-validation frozensets (which intentionally allow whitespace), and is then collapsed back to the token `root` by `eval`/word-splitting in the bundled impersonation launch scripts — causing the kernel to run as the prohibited `root` identity on the host (`sudo -u`) or as the Hadoop superuser (`--proxy-user`). This is the username analogue of CVE-2026-44180, whose `int()` normalization fix covered only `KERNEL_UID`/`KERNEL_GID`, never the username authorization path.
## Root Cause
- `enterprise_gateway/services/processproxies/processproxy.py:984` — `if kernel_username in self.unauthorized_users:` performs an exact, un-normalized string-membership test. `unauthorized_users` defaults to `{"root"}`; `authorized_users` defaults to empty (allow-all branch at line 988 is skipped).
- `enterprise_gateway/services/sessions/kernelsessionmanager.py:322` — `get_kernel_username` returns `env_dict.get("KERNEL_USERNAME")` verbatim; no `.strip()`/`.lower()`/normalize anywhere in the chain.
- `enterprise_gateway/services/kernels/handlers.py:32` — `PROHIBITED_ENV_VALUE_CHARS = frozenset("$`\n\r\x00")` — space/tab absent.
- `enterprise_gateway/services/processproxies/processproxy.py:120` — `EVAL_PROHIBITED_CHARS = frozenset(";&|<>()$`\\\"'\n\r\x00")` — space/tab absent (comment states whitespace is intentionally allowed so multi-option values like `KERNEL_EXTRA_SPARK_OPTS` keep working).
## Impact
Code execution (a Jupyter kernel runs arbitrary client-submitted code) as root on the gateway host via `sudo -u root` (yarn_client / conductor specs) or as the prohibited Hadoop superuser via `--proxy-user root` (yarn_cluster / conductor_cluster specs). The `EG_UNAUTHORIZED_USERS=root` control — whose sole purpose is blocking root impersonation — is fully defeated. Scope is Changed: impact escapes the gateway component onto the host OS / Hadoop cluster.
Proof of Concept
curl -X POST http://<EG_HOST>:8888/api/kernels \
-H "Content-Type: application/json" \
-d '{"name":"spark_python_yarn_client","env":{"KERNEL_USERNAME":"root "}}'On a gateway with `EG_IMPERSONATION_ENABLED=True`, the launch passes the denylist and the kernel is started as `sudo -u root`.
## Attack Chain
1. Entry: `POST /api/kernels` body `{"name":"spark_python_yarn_client","env":{"KERNEL_USERNAME":"root "}}`.
- Guard: `TokenAuthorizationMixin` (default `eg_auth_token=""` → no-op). Bypass: unauthenticated on default posture.
2. Char guard (handlers.py:66): `PROHIBITED_ENV_VALUE_CHARS.intersection("root ")`.
- Bypass proof: `' '` ∉ `frozenset("$`\n\r\x00")` → passes.
3. Eval-reaching guard (processproxy.py:191): `EVAL_PROHIBITED_CHARS.intersection("root ")` + comment regex.
- Bypass proof: `' '`/`'\t'` ∉ `frozenset(";&|<>()$`\\\"'\n\r\x00")`; no `#` present → passes (whitespace allowed by design).
4. Resolution (kernelsessionmanager.py:322): `get_kernel_username` returns `"root "` verbatim.
- Guard: (expected) normalization/strip. Bypass proof: grep over `services/` + `mixins.py` for `KERNEL_USERNAME` with strip/lower/normalize/split → no match.
5. Authorization gate (processproxy.py:984): `"root " in self.unauthorized_users`.
- Guard: `unauthorized_users={"root"}` (mixins.py:651); allowlist empty. Bypass proof: `"root " in {"root"}` → False → not denied.
6. Sink (etc/kernelspecs/spark_python_yarn_client/bin/run.sh:4,23): `IMPERSONATION_OPTS="sudo PATH=${PATH} -H -E -u ${KERNEL_USERNAME:-UNSPECIFIED}"` then `eval exec "${IMPERSONATION_OPTS}" ...`.
- Guard: none remain. Bypass proof: `eval` word-splitting collapses `root ` → token `root`; the double-quotes do not survive the `eval` re-parse (empirically reproduced: token[5]='root').
7. Impact: kernel runs as `root` on the host (`sudo -u`) or as the Hadoop superuser (`--proxy-user`) → RCE as root/superuser; the root-impersonation denylist is defeated.
## Bypass Evidence
- Python, on code byte-identical to release v3.4.0: `' ' in frozenset("$`\n\r\x00")` → False; `' '`/`'\t'` in `EVAL_PROHIBITED_CHARS` → False; `"root " in {"root"}` → False (passes authorization).
- Bash: `eval set -- "sudo PATH=/x -H -E -u root " extra` → positional token = `root` (trailing space collapsed by word-splitting; quotes consumed by `eval`).
- Live sinks confirmed non-commented on v3.4.0 in `spark_python_yarn_client`, `spark_R_yarn_client`, `spark_python_conductor_cluster` (`sudo -u`) and `spark_*_yarn_cluster`, `spark_*_conductor_cluster` (`--proxy-user`). Kubernetes specs ship `IMPERSONATION_OPTS` commented out (no sink there).
## Affected Versions
`<= 3.4.0` (vulnerable code present on latest release tag v3.4.0 and on HEAD `3.5.0.dev0`). Long-standing — the username authorization path was never normalized.
## Suggested Fix
Normalize `KERNEL_USERNAME` before the authorization comparison — e.g. `kernel_username = env_dict["KERNEL_USERNAME"].strip()` — and write the canonical value back into `env` so the shell sink resolves the same identity (mirroring CVE-2026-44180's `int()` coercion + write-back for `KERNEL_UID`/`KERNEL_GID`). Preferably also reject internal whitespace in `KERNEL_USERNAME` outright.
---
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-vjjc-h367-2gx3Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
