/

CVE-2026-42557

Severity:

CRITICAL RISK

(9.6)

Cross-Site Scripting via HTML Command Injection (CWE-79) in JupyterLab CommandLinker

CVE-2026-42557

Modified

Vulnerability type

Category:

Cross-Site Scripting (XSS) / UI-Triggered Code Execution

CWE:

CWE-79

Impact:

Arbitrary Code Execution in JupyterLab Session

Severity:

CRITICAL RISK

(9.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

JupyterLab's HTML sanitizer previously allowed specific data attributes on button elements that could be abused to invoke internal commands through the global CommandLinker click handler.

A crafted notebook with deceptive HTML output can cause arbitrary JupyterLab commands to execute, including arbitrary code execution, when a user clicks a malicious button once, without explicitly running any code themselves.

Affected context

This vulnerability appears in JupyterLab environments where:

  • Users open or interact with notebooks that render rich HTML outputs
  • The HTML sanitizer permits data-commandlinker-command and data-commandlinker-args on <button> elements
  • CommandLinker is globally wired to listen for click events on document.body

It is most relevant in multi-user or shared-notebook settings, or where users open notebooks from untrusted sources (e.g., shared repositories, course materials, or downloaded files).

Exploit preconditions

  • Attack surface: JupyterLab frontend UI via rendered notebook outputs (HTML cells / rich display).
  • Required access: Ability to supply or modify notebook content that another user will open (e.g., sharing a notebook file, pushing to a shared repo, or dropping a file into a shared workspace).
  • User interaction: A single click on a deceptive HTML button rendered in a cell output; no explicit "Run" action on visible code is needed.
  • Trigger point: When a user views the notebook in JupyterLab and clicks the malicious button, CommandLinker receives the click event and executes the named command.
  • Why exploitation is possible: The sanitizer allowlists powerful data attributes, and CommandLinker executes commands based solely on those attributes and the click event, without verifying that the clicked element originated from trusted JupyterLab UI components.

Why this happens

The core issue is an insufficient separation between trusted UI elements and untrusted, notebook-controlled HTML content, combined with permissive sanitization.

JupyterLab's HTML sanitizer explicitly allowed data-commandlinker-command and data-commandlinker-args on <button> elements. At the same time, the CommandLinker subsystem globally listened for click events on document.body and interpreted these attributes as instructions to run arbitrary registered commands. Because the sanitizer did not strip these attributes from untrusted output and CommandLinker did not validate the origin or trust level of the clicked element, notebook content could define buttons that directly invoked sensitive operations, including those that execute user code. This aligns with CWE-79 (Improper Neutralization of Input During Web Page Generation) where attacker-controlled HTML/attributes are rendered and then interpreted in a way that alters application behavior and leads to code execution.

Potential impact

  • Execution of arbitrary JupyterLab commands when a victim clicks a crafted button.
  • Arbitrary code execution in the victim's kernel or environment through command invocations.
  • Theft or modification of data accessible from the victim's notebook session (files, environment variables, secrets loaded in memory).
  • Unauthorized notebook manipulation, such as editing, deleting, or re-running cells without explicit user intent.
  • Lateral movement in shared environments where additional commands enable access to other workspaces or services.

General mitigation guidance

Effective mitigation centers on tightening the trust boundary between notebook content and core UI command mechanisms:

  • Harden HTML sanitization: Remove or strictly restrict attributes that can trigger powerful internal actions (such as data-commandlinker-command and similar hooks) from untrusted output.
  • Enforce trust levels for interactive elements: Require that only UI components created by trusted JupyterLab code can carry command-triggering attributes; disregard such attributes on generic rendered content.
  • Constrain command exposure: Limit which commands can be bound to generic click handlers and require explicit user consent or additional prompts before executing sensitive operations (e.g., those that run code or modify the filesystem).
  • Adopt a least-privilege UI design: Avoid global event listeners that apply to all document content; instead, scope command listeners to trusted containers and components.
  • Encourage safe notebook sharing practices: Treat notebooks from external or unverified sources as untrusted, and clearly surface trust indicators before enabling interactive content that can invoke powerful actions.

How teams detect issues like this

Detection can focus on both code patterns and runtime behavior:

  • Static analysis & code scanning:
  • Search for global event listeners on document or document.body that dispatch high-privilege actions based solely on DOM attributes.
  • Flag sanitization rules that allow special command, action, or handler attributes in untrusted HTML (e.g., data-* attributes tied to internal command systems).
  • Identify components where untrusted notebook output shares a DOM tree or event pipeline with privileged UI elements.
  • Code review signals:
  • Any feature that binds internal command execution to attributes present in untrusted content.
  • Use of generic "command link" patterns that do not clearly differentiate trusted UI markup from rendered notebook output.
  • Sanitizer configurations that explicitly allow attributes whose semantic meaning is "run a command" or "invoke an action."
  • Policy and tooling:
  • Establish frontend security guidelines that prohibit executing sensitive actions based purely on DOM attributes from rendered content.
  • Use automated review tools or linters that enforce restrictions on sanitization allowlists and global event handlers.

Sources

SourceLink
github.comgithub.com/jupyterlab/jupyterlab/security/advisories/GHSA-mqcg-5x36-vfcg
access.redhat.comaccess.redhat.com/errata/RHSA-2026:43038
access.redhat.comaccess.redhat.com/errata/RHSA-2026:60520
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-42557
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2477086
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-42557.json

Frequently asked

questions

Yes, in the sense that an attacker can supply a malicious notebook file (for example via email, a shared repository, or a collaborative environment) that, when opened in JupyterLab and clicked once by the victim, triggers arbitrary commands. The attacker does not need direct access to the victim's Jupyter server, only a way to get the victim to open and interact with the notebook.

An attacker must be able to provide or modify a notebook that the victim will open in JupyterLab. No prior authentication to the victim's JupyterLab instance is strictly required if the attacker can deliver the notebook through other channels; however, existing users in a shared environment could also weaponize notebooks visible to others.

The safest pattern is to ensure that untrusted notebook output cannot directly invoke privileged UI commands. This typically involves tightening the sanitizer to strip command-related attributes from rendered HTML and modifying the command dispatch mechanism so that it only trusts elements created by the core UI, not arbitrary content in notebook cells.

Future prevention should combine secure frontend design with explicit trust boundaries: never let untrusted content share global event handlers with privileged UI, avoid executing sensitive actions based solely on HTML attributes, and continuously review sanitization rules for dangerous exceptions. Incorporating these checks into code review, automated testing, and security guidelines helps catch similar issues before release.

Find out what's already
exploitable in your codebase.