Settings import in JupyterLab hides key bindings that run code and applies sections the user unticked
Description
The Settings Editor in JupyterLab can import a settings file from disk (Settings Editor > Import). Before it applied the file, JupyterLab showed a screen titled "Select settings sections to import" with one tick box per section. That screen listed only the section names, never their content, and every section started ticked. The tick boxes also had no effect: every section in the file was imported, including the ones the user unticked. A settings file shared as a team configuration or as course material could therefore add keyboard shortcuts that run the attacker's code in a kernel on the Jupyter server. All the screen showed of them was the line @jupyterlab/shortcuts-extension:shortcuts.
Users are affected if all of the following conditions are true:
- they run JupyterLab 4.4.0 to 4.6.6, or an application that bundles it such as Notebook 7;
- they import a settings file written by someone else through Settings Editor > Import; and
- they then press the keys the file binds, or open an HTML file or click a link in a Markdown file from the attacker. The keys can be ordinary ones, such as letters typed in a text file or Shift+Enter in a notebook cell.
Users who never import settings files from other people are not affected.
Impact
A settings file can bind keyboard shortcuts to any JupyterLab command with any arguments. This is by design, and the import screen exists so that the user can see and refuse such changes. The screen showed no commands, arguments or code, and refusing a section had no effect.
Key bindings that run code
The attacker's code ran in a kernel on the server, with the privileges of the user who imported the file. It could read and write the user's files and run programs as the user. The bindings were saved in the user's settings on the server, so they stayed active in new browser sessions until the user removed them. Depending on the bindings, the first sign was a console tab that opened on the first key press, or nothing at all until the code had run, for example on the first Shift+Enter in a notebook cell. No dialog appeared at any point.
Unticked sections
A user who read the list and unticked the sections they did not want still got all of them, and the closing dialog reported only a count. Besides shortcuts, this applied to sections that switch a protection off, such as trustByDefault of the HTML viewer and allowedSchemes of the sanitizer. With those imported, an HTML file from the attacker could later run script in the JupyterLab origin when it was opened (JupyterLab 4.5.0 and later), and a Markdown file from the attacker could do so when a link in it was clicked. That script could use the Jupyter Server REST API as the user.
The attacker needs no account on the server, but nothing happens without the import. The user starts the import and confirms it. The code runs only with the privileges of the user who imported the file.
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 import screen now shows a warning that settings can run code, and each section shows its content when expanded. Every section starts unticked, and only the ticked sections are imported. To import your own exported settings, tick Select all.
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
Do not import settings files from other people until you have upgraded.
Administrators can remove the Import button by disabling the plugin that provides it:
jupyter labextension disable @jupyterlab/settingeditor-extension:pluginConfirm that @jupyterlab/settingeditor-extension:plugin is disabled by running:
jupyter labextension listThis also removes the Export button and the JSON Settings Editor. The form-based Settings Editor keeps working.
Verifying settings from CLI and UI
To audit the shortcuts settings without interacting with the application, print the file that holds the shortcuts:
- On Linux and macOS: ``
bash cat "$(jupyter lab path | awk -F': ' '/User Settings directory/ {print $2}')/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings"`` - On Windows: run
jupyter lab path, then open the file@jupyterlab\shortcuts-extension\shortcuts.jupyterlab-settingswith a text editor, in the User Settings directory that the command prints.
If the file does not exist, your user settings hold no custom shortcuts. Otherwise, remove any entry you did not add, then reload JupyterLab. The same shortcuts are listed in Settings > Settings Editor > Keyboard Shortcuts.
A past import also saved the other sections of the file, ticked or not. In Settings > Settings Editor, check that "Trust HTML by default" under HTML Viewer is off, and that "Allowed URL Scheme" under HTML Sanitizer does not list javascript.
References
- jupyterlab.readthedocs.io/
en/ latest/ user/ interface.html#keyboard-shortcuts - jupyterlab.readthedocs.io/
en/ latest/ user/ interface.html#defining-shortcuts-running-multiple-commands-macros - github.com/
jupyterlab/ jupyterlab/ security/ advisories/ GHSA-pppj-hq3g-57pj - cross-site scripting through a crafted settings file - github.com/
jupyterlab/ jupyterlab/ commit/ 696ff794e54bb31cb9d97747c36883a77aae9494 - the fix in 4.6.7 - github.com/
jupyterlab/ jupyterlab/ commit/ 217e5b5f61497de9585a9a4937cb0a8906bdb58f - the fix on main, for 4.7
Acknowledgments
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-741UBCWX. Also reported by @rexpository, @grainaxiom684 and @maxtli