Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-22420 Overview
CVE-2024-22420 is a stored cross-site scripting (XSS) vulnerability in JupyterLab, the extensible web-based interactive development environment for Jupyter notebooks. The flaw resides in the Markdown preview feature and its table of contents extension, which failed to sanitize rendered content before injection into the DOM. An attacker who convinces a victim to open a malicious Markdown file in JupyterLab can execute arbitrary JavaScript in the victim's browser session. This grants the attacker access to any data the user can reach and the ability to issue arbitrary requests as that user. The issue is tracked under CWE-79 and fixed in JupyterLab 4.0.11.
Critical Impact
Successful exploitation allows session-scoped code execution in the victim's JupyterLab instance, enabling data theft, notebook tampering, and lateral actions performed under the attacked user's identity.
Affected Products
- Jupyter JupyterLab prior to 4.0.11
- Jupyter Notebook (bundled JupyterLab components)
- Fedora Project Fedora 39
Discovery Timeline
- 2024-01-19 - CVE-2024-22420 published to the National Vulnerability Database (NVD)
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-22420
Vulnerability Analysis
The vulnerability is a stored XSS [CWE-79] triggered through JupyterLab's Markdown preview workflow. JupyterLab renders Markdown documents into HTML to produce an in-editor preview and a navigable table of contents (ToC). The rendering path did not consistently apply the application's ISanitizer before inserting generated markup. A crafted Markdown file can therefore embed HTML or script-equivalent constructs that execute when the preview or ToC renders.
Because execution occurs inside the authenticated JupyterLab origin, the injected script inherits the user's session. It can read notebook contents, exfiltrate kernel data, and call JupyterLab REST and WebSocket endpoints as the victim. In multi-user deployments such as JupyterHub, this expands the blast radius to any resource the victim account can reach.
Exploitation requires user interaction: the victim must open the malicious .md file with the preview feature. There is no authentication requirement on the attacker side; delivery can occur through shared repositories, collaborative notebooks, or email attachments.
Root Cause
The root cause is missing sanitization in the Markdown viewer and table of contents extension. The patched code introduces the ISanitizer dependency into packages/markdownviewer-extension/src/index.ts and the IRenderMime interface into packages/markdownviewer/src/toc.ts, ensuring rendered Markdown passes through JupyterLab's shared sanitization layer before DOM insertion.
Attack Vector
An attacker crafts a Markdown document containing active HTML content and delivers it to a target JupyterLab user. When the user previews the file or opens the table of contents, the embedded payload executes within the JupyterLab origin and acts under the user's session.
// Patch excerpt: packages/markdownviewer-extension/src/index.ts
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
-import { WidgetTracker } from '@jupyterlab/apputils';
+import { ISanitizer, WidgetTracker } from '@jupyterlab/apputils';
import { PathExt } from '@jupyterlab/coreutils';
import {
IMarkdownViewerTracker,
// Patch excerpt: packages/markdownviewer/src/toc.ts
// Distributed under the terms of the Modified BSD License.
import { IWidgetTracker } from '@jupyterlab/apputils';
-import { IMarkdownParser } from '@jupyterlab/rendermime';
+import { IMarkdownParser, IRenderMime } from '@jupyterlab/rendermime';
import {
TableOfContents,
TableOfContentsFactory,
Source: JupyterLab commit e1b3aab. The fix wires the sanitizer into both the Markdown viewer plugin and the ToC rendering path so untrusted Markdown is scrubbed before HTML insertion.
Detection Methods for CVE-2024-22420
Indicators of Compromise
- Markdown files in shared notebook directories containing inline <script>, onerror, or javascript: constructs intended to execute on render.
- Unexpected outbound HTTP requests from browsers to attacker-controlled hosts shortly after a user opens a .md file in JupyterLab.
- JupyterLab server logs showing REST or WebSocket API calls from a user session that do not correspond to normal interactive activity.
Detection Strategies
- Scan user and shared notebook storage for Markdown files containing HTML event handlers, <script> tags, or encoded JavaScript URIs.
- Inspect browser Content Security Policy (CSP) violation reports from JupyterLab origins for inline-script blocks.
- Monitor the installed JupyterLab version across hosts and flag any instance below 4.0.11.
Monitoring Recommendations
- Enable JupyterHub and JupyterLab access logging and forward events to a centralized analytics platform for correlation with user activity.
- Alert on anomalous spikes in notebook or file API calls originating from a single user session following a Markdown file open.
- Track package manifests (pip, conda, OS packages) to confirm jupyterlab>=4.0.11 is deployed across managed environments.
How to Mitigate CVE-2024-22420
Immediate Actions Required
- Upgrade JupyterLab to version 4.0.11 or later on all user and server installations.
- For Fedora 39, apply the updated jupyterlab package distributed through the Fedora package announcement.
- Audit shared notebook storage and remove untrusted Markdown files pending remediation.
- Instruct users not to open Markdown files from untrusted sources using the preview feature until patched.
Patch Information
The fix is delivered in JupyterLab 4.0.11 and is described in GitHub Security Advisory GHSA-4m77-cmpx-vjc4. The code change in commit e1b3aab introduces the ISanitizer into the Markdown viewer extension and threads IRenderMime through the table of contents, enforcing sanitization on rendered Markdown. Downstream distributions should install the vendor update, for example the Fedora package announcement.
Workarounds
- Disable the table of contents extension on JupyterLab versions earlier than 4.0.11 to remove the vulnerable rendering path.
- Restrict Markdown file sharing to trusted collaborators and review .md content before opening with the preview feature.
- Enforce a restrictive browser Content Security Policy on the JupyterLab origin to block inline script execution.
# Upgrade JupyterLab to the patched release
pip install --upgrade "jupyterlab>=4.0.11"
# Verify installed version
jupyter lab --version
# Workaround: disable the table of contents extension if upgrade is not possible
jupyter labextension disable @jupyterlab/toc-extension
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

