JupyterLab: Cross-site scripting (XSS) in JupyterLab via notebook cells pasted from the system clipboard
What fixes it
- 4.6.4jupyterlab, pipGitHub
- 4.5.11jupyterlab, pipGitHub
- 7.6.3notebook, pipGitHub
- 0.8.4jupyterlite, pipGitHub
- 0.8.4jupyterlite-core, pipGitHub
- 4.6.4jupyterlab, PyPIOSV
pip install "jupyterlab>=4.6.4"
Show all 10 fixed versions
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Description
JupyterLab 4.5.0 enabled copying and pasing cells through the system clipboard. The paste path parses clipboard text as cell JSON and inserts the cells without clearing metadata.trusted, so a payload can declare its own output as trusted. JupyterLab does not sanitize a trusted output and evaluates the <script> elements it contains, so pasting the cell runs attacker's JavaScript in the JupyterLab origin. The same payload with "trusted": false is sanitized.
[
{
"cell_type": "code",
"execution_count": null,
"source": "",
"metadata": { "trusted": true },
"outputs": [
{
"output_type": "display_data",
"metadata": {},
"data": { "text/html": "<script>/* runs on paste */</script>" }
}
]
}
]Users are affected if all of the following are true:
- they run JupyterLab 4.5.0 through 4.6.3, or an application that bundles it such as Notebook 7.5+;
- if running 4.5.2 or newer,
useSystemClipboardForCellsis enabled - it is off by default in 4.5.2+, and always enabled on 4.5.0 and 4.5.1 with no opt-out - they run a Paste Cells command (e.g. from context menu, command palette, shortcut) while attacker-controlled text is in the clipboard; and
pasteCodeCellsWithoutOutputis off, the default, so the pasted cell keeps its outputs
Impact
The script runs in the JupyterLab page, in the same origin and session as the authenticated user, so it can call the Jupyter Server REST API as that user: read and write any file under the server root, start a kernel and run code in it, and open a terminal where terminals are enabled. It runs on paste, without the user executing anything.
Only the output of a code cell can run a script this way. Markdown and raw cells are always sanitized, as the trust documentation states.
The attacker needs no JupyterLab account and no access to the server, only the user's clipboard at the moment of the paste. A web page can replace the text you copy from it, or write the clipboard directly once you have given it permission. Both need you to click or press a key on that page first.
Patches
JupyterLab [v4.6.4](https://github.com/jupyterlab/jupyterlab/releases/tag/v4.6.4) and [v4.5.11](https://github.com/jupyterlab/jupyterlab/releases/tag/v4.5.11) contain the patch. Cells read from the system clipboard that cannot be traced to the current window no longer carry metadata.trusted into the notebook, so their outputs are sanitized like any other content of unknown origin.
Users of applications that depend on JupyterLab, such as Notebook v7+, should update jupyterlab package too.
Workarounds
On 4.5.2 and later, confirm that the system clipboard is not in use for cells. The setting is off by default; check Settings, Notebook, or the raw value:
{
"@jupyterlab/notebook-extension:tracker": {
"useSystemClipboardForCells": false
}
}With that setting off, cell copy and paste use JupyterLab's in-application clipboard, which never leaves the page. The cost is that cells can no longer be copied between browser tabs or windows.
On 4.5.0 and 4.5.1 there is no such setting, and every paste reads the system clipboard and upgrade is highly recommended.
Pasting cells without their outputs also stops the script from running, at the cost of discarding outputs on every paste:
{
"@jupyterlab/notebook-extension:tracker": {
"pasteCodeCellsWithoutOutput": true
}
}Text from GitHub Advisory Database
Affected versions 84
- jupyterlab, pip>= 4.6.0, <= 4.6.3GitHub
- jupyterlab, pip>= 4.5.0, <= 4.5.10GitHub
- notebook, pip>= 7.5.0, <= 7.6.2GitHub
- jupyterlite, pip>= 0.7.0, <= 0.8.3GitHub
- jupyterlite-core, pip>= 0.7.0, <= 0.8.3GitHub
- jupyterlabaffected: >= 4.5.0, < 4.5.11CVE List
- jupyterlabaffected: >= 4.6.0, < 4.6.4CVE List
- notebookaffected: >= 7.5.0, < 7.6.3CVE List
- jupyterlite-coreaffected: >= 0.7.0, < 0.8.4CVE List
- jupyterlab, PyPIfrom 4.6.0, fixed in 4.6.4OSV
- jupyterlab, PyPI4.6.0OSV
- jupyterlab, PyPI4.6.1OSV
- jupyterlab, PyPI4.6.2OSV
- jupyterlab, PyPI4.6.3OSV
- jupyterlab, PyPIfrom 4.5.0, fixed in 4.5.11OSV
- jupyterlab, PyPI4.5.0OSV
- jupyterlab, PyPI4.5.1OSV
- jupyterlab, PyPI4.5.10OSV
- jupyterlab, PyPI4.5.2OSV
- jupyterlab, PyPI4.5.3OSV
- jupyterlab, PyPI4.5.4OSV
- jupyterlab, PyPI4.5.5OSV
- jupyterlab, PyPI4.5.6OSV
- jupyterlab, PyPI4.5.7OSV
- jupyterlab, PyPI4.5.8OSV
- jupyterlab, PyPI4.5.9OSV
- notebook, PyPIfrom 7.5.0, fixed in 7.6.3OSV
- notebook, PyPI7.5.0OSV
- notebook, PyPI7.5.1OSV
- notebook, PyPI7.5.2OSV
- notebook, PyPI7.5.3OSV
- notebook, PyPI7.5.4OSV
- notebook, PyPI7.5.5OSV
- notebook, PyPI7.5.6OSV
- notebook, PyPI7.5.7OSV
- notebook, PyPI7.6.0OSV
- notebook, PyPI7.6.0a0OSV
- notebook, PyPI7.6.0a1OSV
- notebook, PyPI7.6.0a2OSV
- notebook, PyPI7.6.0a3OSV
- notebook, PyPI7.6.0a4OSV
- notebook, PyPI7.6.0a5OSV
- notebook, PyPI7.6.0b0OSV
- notebook, PyPI7.6.0b1OSV
- notebook, PyPI7.6.0rc0OSV
- notebook, PyPI7.6.0rc1OSV
- notebook, PyPI7.6.1OSV
- notebook, PyPI7.6.2OSV
- jupyterlite, PyPIfrom 0.7.0, fixed in 0.8.4OSV
- jupyterlite, PyPI0.7.0OSV
- jupyterlite, PyPI0.7.1OSV
- jupyterlite, PyPI0.7.2OSV
- jupyterlite, PyPI0.7.3OSV
- jupyterlite, PyPI0.7.4OSV
- jupyterlite, PyPI0.7.5OSV
- jupyterlite, PyPI0.7.6OSV
- jupyterlite, PyPI0.8.0OSV
- jupyterlite, PyPI0.8.0a0OSV
- jupyterlite, PyPI0.8.0a1OSV
- jupyterlite, PyPI0.8.0a2OSV
- jupyterlite, PyPI0.8.0b0OSV
- jupyterlite, PyPI0.8.0b1OSV
- jupyterlite, PyPI0.8.0rc0OSV
- jupyterlite, PyPI0.8.1OSV
- jupyterlite, PyPI0.8.2OSV
- jupyterlite, PyPI0.8.3OSV
- jupyterlite-core, PyPIfrom 0.7.0, fixed in 0.8.4OSV
- jupyterlite-core, PyPI0.7.0OSV
- jupyterlite-core, PyPI0.7.1OSV
- jupyterlite-core, PyPI0.7.2OSV
- jupyterlite-core, PyPI0.7.3OSV
- jupyterlite-core, PyPI0.7.4OSV
- jupyterlite-core, PyPI0.7.5OSV
- jupyterlite-core, PyPI0.7.6OSV
- jupyterlite-core, PyPI0.8.0OSV
- jupyterlite-core, PyPI0.8.0a0OSV
- jupyterlite-core, PyPI0.8.0a1OSV
- jupyterlite-core, PyPI0.8.0a2OSV
- jupyterlite-core, PyPI0.8.0b0OSV
- jupyterlite-core, PyPI0.8.0b1OSV
- jupyterlite-core, PyPI0.8.0rc0OSV
- jupyterlite-core, PyPI0.8.1OSV
- jupyterlite-core, PyPI0.8.2OSV
- jupyterlite-core, PyPI0.8.3OSV
References 8
- github.com/jupyterlab/jupyterlab/commit/1a10a7da5ff655849b21581c2633b46483ae0be9Fixvia CVE List
- github.com/jupyterlab/jupyterlab/commit/7f9f29e29e0c83fb17b0f11da57d06b3c6a40d96Fixvia CVE List
- github.com/jupyterlab/jupyterlab/commit/cf6e89a8d315c4134cefa50c220bca296da466a7Fixvia CVE List
- github.com/jupyterlab/jupyterlab/releases/tag/v4.5.11Fixvia CVE List
- github.com/jupyterlab/jupyterlab/releases/tag/v4.6.4Fixvia CVE List
- github.com/jupyterlab/jupyterlab/security/advisories/GHSA-6966-vjj6-99xvAdvisoryvia CVE List
- github.com/advisories/GHSA-6966-vjj6-99xvAdvisoryvia GitHub
- nvd.nist.gov/vuln/detail/CVE-2026-102831Referencevia GitHub