Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2024-29021

CVE-2024-29021: Judge0 Sandbox Escape RCE Vulnerability

CVE-2024-29021 is a sandbox escape RCE vulnerability in Judge0 that exploits SSRF to execute code as root. This article covers the technical details, affected versions, security impact, and mitigation strategies.

Published:

CVE-2024-29021 Overview

Judge0 is an open-source online code execution system widely used for programming education, coding challenges, and technical interviews. A critical vulnerability exists in the default configuration of Judge0 that leaves the service vulnerable to a sandbox escape via Server Side Request Forgery (SSRF). This allows an attacker with sufficient access to the Judge0 API to obtain unsandboxed code execution as root on the target machine. The vulnerability has been addressed in version 1.13.1.

Critical Impact

Attackers can leverage SSRF to escape the sandbox environment and achieve root-level code execution on the underlying host system, potentially compromising the entire infrastructure.

Affected Products

  • Judge0 versions prior to 1.13.1
  • Judge0 instances using default configuration settings
  • Deployments with exposed Judge0 API endpoints

Discovery Timeline

  • April 18, 2024 - CVE-2024-29021 published to NVD
  • November 21, 2024 - Last updated in NVD database

Technical Details for CVE-2024-29021

Vulnerability Analysis

This vulnerability is classified as CWE-918 (Server-Side Request Forgery) and represents a significant security risk due to its ability to enable sandbox escape. The Judge0 system is designed to execute untrusted code in an isolated sandbox environment to prevent malicious code from affecting the host system. However, the default configuration fails to adequately restrict internal network requests, creating a pathway for attackers to bypass these security controls.

The vulnerability can be exploited remotely over the network without requiring user interaction. While the attack complexity is high, successful exploitation does not require any privileges on the target system. Due to the changed scope characteristic, a successful attack impacts resources beyond the vulnerable component, allowing attackers to affect the underlying host system rather than just the sandboxed environment.

Root Cause

The root cause of this vulnerability lies in the default configuration of Judge0, which does not properly restrict Server Side Request Forgery attacks. The isolate_job.rb file, specifically the code handling job isolation between lines 203-230, contains the vulnerable functionality. When the system processes code execution requests, it fails to adequately validate and restrict internal network requests, allowing attackers to craft requests that can reach internal services and ultimately escape the sandbox.

Attack Vector

The attack vector involves exploiting the SSRF vulnerability through the Judge0 API. An attacker with access to the API can submit specially crafted code execution requests that trigger internal network requests to services that should not be accessible from the sandbox. By chaining these internal requests, the attacker can escape the sandbox environment and execute arbitrary commands as root on the host system.

The exploitation flow typically involves:

  1. Identifying an accessible Judge0 API endpoint
  2. Crafting malicious code execution requests that exploit the SSRF vulnerability
  3. Leveraging the SSRF to reach internal services or metadata endpoints
  4. Escalating from the sandboxed environment to obtain root access on the host

For detailed technical analysis and proof-of-concept information, refer to the GitHub Security Advisory and the vulnerable code section in isolate_job.rb.

Detection Methods for CVE-2024-29021

Indicators of Compromise

  • Unusual outbound requests from the Judge0 container targeting internal IP ranges (e.g., 127.0.0.1, 169.254.169.254, 10.x.x.x, 172.16.x.x)
  • Unexpected processes running as root on the Judge0 host system
  • Anomalous network traffic patterns from the code execution sandbox to internal services
  • Evidence of code execution attempts accessing cloud metadata endpoints

Detection Strategies

  • Implement network monitoring to detect SSRF patterns targeting internal resources from Judge0 containers
  • Configure alerting for any root-level process creation outside normal Judge0 operations
  • Monitor Judge0 API access logs for suspicious code submission patterns
  • Deploy web application firewalls (WAF) with SSRF detection rules in front of Judge0 API endpoints

Monitoring Recommendations

  • Enable comprehensive logging for all Judge0 API requests and code execution jobs
  • Implement egress filtering and monitor for attempts to bypass network restrictions
  • Set up alerts for any sandbox escape indicators or privilege escalation attempts
  • Regularly audit Judge0 configuration files for deviations from security best practices

How to Mitigate CVE-2024-29021

Immediate Actions Required

  • Upgrade Judge0 to version 1.13.1 or later immediately
  • Review and restrict network access to the Judge0 API to authorized users only
  • Implement network segmentation to isolate Judge0 instances from sensitive internal resources
  • Audit existing deployments for signs of compromise before and after patching

Patch Information

The vulnerability has been fixed in Judge0 version 1.13.1. Organizations running affected versions should upgrade immediately. The fix addresses the SSRF vulnerability by implementing proper request validation and network restrictions in the sandbox environment.

Review the GitHub Security Advisory GHSA-q7vg-26pg-v5hr for complete patch details and upgrade instructions.

Workarounds

  • Restrict Judge0 API access using firewall rules or reverse proxy authentication until patching is possible
  • Configure network-level egress filtering to block sandbox containers from reaching internal IP ranges
  • Implement a network policy that prevents the Judge0 container from accessing metadata services and internal networks
  • Consider temporarily disabling the Judge0 service if it cannot be immediately patched and is exposed to untrusted users
bash
# Example: Network policy to restrict Judge0 container egress (Kubernetes)
# Apply network policies to prevent SSRF to internal resources
kubectl apply -f - <<EOF
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: judge0-egress-restriction
spec:
  podSelector:
    matchLabels:
      app: judge0
  policyTypes:
  - Egress
  egress:
  - to:
    - ipBlock:
        cidr: 0.0.0.0/0
        except:
        - 10.0.0.0/8
        - 172.16.0.0/12
        - 192.168.0.0/16
        - 169.254.169.254/32
EOF

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.