One-click command execution in JupyterLab Markdown preview after reloading a trusted file that another user replaced
Description
A Markdown file can carry buttons that run JupyterLab commands. In the Markdown preview, the first click on such a button opens the "Run Command?" prompt, and choosing Trust marks the preview so that its later buttons run without a prompt. JupyterLab never removed that mark when the preview loaded new content. When the file was replaced on disk and the user reloaded it in the open preview, for example with File > Reload Markdown File from Disk, the buttons of the new content ran their commands on one click with no prompt. Another user who could write to a shared Markdown file could therefore run a command of their choice, such as opening a terminal, 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.7 to 4.6.6, or an application that bundles it such as Notebook 7;
- they chose Trust in the "Run Command?" prompt of a Markdown preview, for a file in a location that someone else can write to, such as a shared project folder or a course directory;
- the preview stayed open while someone else replaced the file;
- they reloaded the file in the open preview, for example with File > Reload Markdown File from Disk; and
- they clicked a button in the new content.
Users who choose Run Once or Cancel in the "Run Command?" prompt, or who never trust Markdown files that other people can write to, are not affected. Releases before 4.5.7 had no prompt at all: any command link in untrusted content ran on one click. GHSA-mqcg-5x36-vfcg covers those releases, so their users already have a reason to upgrade.
Impact
A button in the replacement file ran a JupyterLab command with arguments of the attacker's choice, and the "Run Command?" prompt did not appear. One button could start a kernel and run code from the file in it. That code ran on the server with the privileges of the user. Nothing in the interface showed that the preview was trusted, and no command withdrew the trust.
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 preview 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 Markdown preview now withdraws its trust each time it renders the file again and when the file is renamed, so a button in the new content shows the "Run Command?" prompt again. The preview therefore also asks again after the user edits the file in an editor next to it, and after a reload of unchanged content. A link to a heading of the file, such as notes.md#usage, renders the file again too.
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
In the "Run Command?" prompt, choose Run Once instead of Trust. The command runs once and the preview is not marked, so later buttons ask again.
When a trusted Markdown file may have changed, close its preview and open the file again, instead of reloading it in place.
To remove the risk entirely, disable the Markdown preview:
jupyter labextension disable @jupyterlab/markdownviewer-extension:pluginConfirm that @jupyterlab/markdownviewer-extension:plugin is disabled by running:
jupyter labextension listMarkdown files then open only in the text editor, without a rendered preview. Markdown cells in notebooks are not affected.
Alternatively, turn off command links, for example in overrides.json:
{
"@jupyterlab/apputils-extension:sanitizer": {
"allowCommandLinker": false
}
}Confirm in Settings > Settings Editor > HTML Sanitizer that "Allow command linker" is unticked. Buttons in Markdown files and Markdown cells then do nothing, even in trusted notebooks, and so do buttons in the outputs of untrusted notebooks. Documentation and extensions that use command links for navigation stop working.
References
- jupyterlab.readthedocs.io/
en/ latest/ user/ commands.html#commands-in-markdown-output-and-files - jupyterlab.readthedocs.io/
en/ latest/ user/ directories.html#overrides-json - github.com/
jupyterlab/ jupyterlab/ security/ advisories/ GHSA-mqcg-5x36-vfcg - the advisory that introduced the "Run Command?" prompt - github.com/
jupyterlab/ jupyterlab/ security/ advisories/ GHSA-jwrc-gm9j-263p - an earlier flaw in the same prompt: Trust could apply to a document other than the one whose link the user clicked - 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-mrp8-89fh-4g5j (ANT-2026-YW6GXQ16, HTML viewer half) - the same flaw in Trust HTML - github.com/
jupyterlab/ jupyterlab/ security/ advisories/ GHSA-5ww6-jv8j-qg83 (ANT-2026-BN798KLI) - another way Markdown buttons skipped the same prompt, fixed in the same commit
Acknowledgments
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-YW6GXQ16. Also reported by @rexpository