Summary
Jupyter Enterprise Gateway contains an input validation flaw in its prohibited UID/GID feature that can be bypassed using specially crafted KERNEL_UID or KERNEL_GID values.
Under certain configurations, this allows kernels to run as root inside containers, significantly increasing attack surface and enabling potential container escapes and cluster compromise.
Affected context
This vulnerability affects Jupyter Enterprise Gateway deployments that:
- Use versions 2.0.0rc1 and above prior to 3.3.0
- Rely on the "prohibited UID/GID" feature to prevent root execution (UID/GID 0)
- Launch kernels on distributed backends such as Kubernetes, Apache Spark, or Docker-based clusters
- Allow user-controlled or externally influenced KERNEL_UID or KERNEL_GID environment variables or configuration
The issue is most impactful where kernel containers can mount host volumes (for example, hostPath mounts in Kubernetes) or access sensitive cluster resources.
Exploit preconditions
- Attack surface: Remote interaction with Jupyter Enterprise Gateway's kernel launch mechanism (e.g., via Jupyter clients or gateway APIs).
- Required access: Ability to create or configure kernels such that KERNEL_UID and/or KERNEL_GID values can be influenced or directly set.
- Trigger point: Submission of a specially crafted KERNEL_UID or KERNEL_GID value that bypasses the prohibited UID/GID check during kernel startup.
- Why exploitation is possible: The input validation logic that enforces forbidden UIDs/GIDs (notably 0 for root) can be circumvented, allowing the underlying container runtime or orchestrator to run kernels with elevated privileges contrary to policy.
Why this happens
The root cause is insufficient input validation and enforcement around security-sensitive identifiers (user and group IDs) used during kernel launch.
The "prohibited UID/GID" feature is intended to block execution as root by rejecting UID/GID 0, but the validation logic fails to normalize, constrain, or robustly interpret the incoming KERNEL_UID and KERNEL_GID values.
This aligns with CWE-20: Improper Input Validation, where the system accepts malformed or specially crafted input that bypasses intended security checks, resulting in execution under a more privileged identity than intended.
Potential impact
- Kernels may run as root within their containers instead of as non-privileged users.
- Attackers could perform container escapes when combined with permissive volume mounts (for example, hostPath read/write mounts).
- Code execution on the underlying worker node can be achieved by modifying files on the host filesystem (such as crontab entries).
- Compromise of other workloads running on the same worker node through host-level persistence or lateral movement.
- Repeated exploitation across nodes could lead to compromise of the entire Kubernetes or distributed compute cluster.
General mitigation guidance
Effective mitigation typically focuses on enforcing strict, defense-in-depth controls around identity, privilege, and configuration handling:
- Normalize and strictly validate all user and group ID inputs, constraining them to approved numeric ranges and rejecting any ambiguous or transformed representations.
- Enforce run-as-non-root policies at the container orchestration layer (e.g., Kubernetes securityContext, PodSecurity or similar policies) so that privileged execution cannot be enabled solely by application logic.
- Minimize or avoid hostPath and other broad host-mounted volumes for kernels; where host mounts are unavoidable, apply read-only constraints and limit paths to non-sensitive directories.
- Apply least-privilege principles for kernel containers, including dropping unnecessary Linux capabilities and disabling privilege escalation.
- Treat UID/GID configuration as security-critical data and avoid exposing it directly to end-user control where possible, preferring centrally managed templates or profiles.
How teams detect issues like this
Detection can leverage both code-level and runtime-level approaches:
- Static analysis and code review: Look for UID/GID handling that:
- Accepts raw KERNEL_UID/KERNEL_GID values without normalization.
- Compares or filters IDs in a way that can be bypassed via alternate formats or edge cases.
- Implements security checks only at the application layer without orchestration-level enforcement.
- Configuration review: Audit Kubernetes manifests, Spark cluster configurations, and Docker settings for:
- Kernels allowed to run as root.
- hostPath or other host-mounted volumes used with kernel containers.
- Absence of PodSecurity, Pod Security Policy equivalents, or admission controls enforcing non-root execution.
- Runtime monitoring: Use container security tools and audit logs to:
- Flag containers started with UID/GID 0 where policies specify non-root.
- Detect write operations from kernel containers to host-mounted system directories (e.g., /etc, /var/spool/cron).
- Automated policy-as-code tools (such as admission controllers or CI/CD policy checks) can be configured to block workloads that violate non-root or host mount policies.

