Cross-site scripting (XSS) in JupyterLab HTML viewer after reloading a trusted file that another user replaced
Description
The HTML viewer in JupyterLab shows HTML files in a sandboxed frame that does not run scripts. When the user presses "Trust HTML" button, the frame may run the file's scripts in the JupyterLab origin. JupyterLab kept that decision on the open viewer tab instead of tying it to the content the user had trusted. When the file was replaced on disk and the user refreshed the tab with the viewer's refresh button or with File > Reload HTML File from Disk, the new content was rendered with the old trust, and its scripts ran without any prompt. Another user who could write to a shared HTML file could therefore run script in the session of a user who had trusted an earlier version of that file.
Users are affected if all of the following conditions are true:
- they run JupyterLab 4.5.0 to 4.6.6, or an application that bundles it such as Notebook 7;
- they pressed "Trust HTML" on an HTML file in a location that someone else can write to, such as a shared project folder or a course directory;
- the viewer tab stayed open while someone else replaced the file; and
- they reloaded the open tab with the viewer's refresh button or with File > Reload HTML File from Disk.
Users who never press "Trust HTML", or who only trust HTML files that nobody else can write to, are not affected.
Impact
The replacement file's scripts ran in the JupyterLab origin. They could use the Jupyter Server REST API as the user: read and write files, and start kernels or terminals that run code on the server. The user never pressed Trust HTML on that content, and no dialog or notice said that the reloaded content would run scripts.
The risk comes from someone who can write to the file only after the user's trust click, for example another account with write access to a shared directory. Closing and reopening the tab drops the trust.
Patches
JupyterLab 4.6.7 and 4.7.0rc0 contain the patch. No 4.5.x release with the fix is planned, so users of JupyterLab 4.5 and earlier should upgrade to 4.6.7. The HTML viewer now withdraws Trust HTML when the file content differs from the content it showed when the user pressed Trust HTML, so the new content needs a new Trust HTML. This also happens when the user edits the file in an editor open next to the viewer. With the Trust HTML by default setting turned on, the viewer keeps its trust.
Notebook bundles its own copy of the affected code, so Notebook users need to update notebook to 7.6.6 (or 7.7.0rc0 for pre-releases) as well as jupyterlab. Users of other applications that depend on JupyterLab should update the jupyterlab package too.
Workarounds
When a trusted HTML file may have changed, close its viewer tab and open the file again from the file browser, instead of using the refresh button or File > Reload HTML File from Disk. Reopening the file resets "Trust HTML": confirm that the button in the viewer toolbar reads "Trust HTML" and no longer Distrust HTML. The cost is one more "Trust HTML" click after you have checked the new content.
Alternatively, do not press "Trust HTML" on files in folders that other people can write to.
To remove the risk entirely, disable the HTML viewer:
jupyter labextension disable @jupyterlab/htmlviewer-extension:pluginConfirm that @jupyterlab/htmlviewer-extension:plugin is disabled by running:
jupyter labextension listHTML files then open as text in the editor, and Trust HTML is gone.
References
- jupyterlab.readthedocs.io/
en/ latest/ user/ file_formats.html#html - github.com/
jupyterlab/ jupyterlab/ commit/ e5b0f15c3fb05303673b80936d2ccfc2cd8c58a8 - the fix in 4.6.7 - github.com/
jupyterlab/ jupyterlab/ commit/ 23f12acededb5b2281bb564090b655bcac96d173 - the fix on main, for 4.7
Published in the same release:
- github.com/
jupyterlab/ jupyterlab/ security/ advisories/ GHSA-3hvx-gjq6-v8qw (ANT-2026-YW6GXQ16, Markdown preview half) - the same flaw in the trust of command links in the Markdown preview - github.com/
jupyterlab/ jupyterlab/ security/ advisories/ GHSA-5ww6-jv8j-qg83 (ANT-2026-BN798KLI) - fixed in the same commit
Acknowledgments
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-YW6GXQ16. Also reported by @rexpository