Skip to content

Loading Kernels from insecure directories

Ian Huff edited this page Oct 11, 2022 · 1 revision

VS Code loads Jupyter Kernels located in a number different directories, as documented here.

One such directory where kernels are loaded from is %PROGRAMDATA%\jupyter (on Windows). Launching Kernels defined in such directories pose a security threat to the user as this directory does not require elevated permissions. Hence it is possible that the user could be launching a malicious Kernel from such location.

As a security measure VS Code does not load such kernels.

It is advised that users create kernels in other directories as defined here which do not have such relaxed permission, or create a folder %PROGRAMDATA%\jupyter\kernels\ and configure it to be writable only by the current user.
Optionally, users could continue to use such kernels by updating the setting jupyter.kernels.trusted to include the path to such kernelspecs.

Updating the setting jupyter.kernels.trusted:

  • Copy the fully qualified path to the kernelspec, e.g. C:\ProgramData\Jupyter\kernels\Python3\kernel.json
  • Open the VS User Settings UI using the command Preferences: Open User Settings from the Command Palette.
  • Search for the setting jupyter.kernels.trusted
  • Add a new value into the list using the Add button
  • Re-load VS Code

At any point it is possible to remove the above kernel from the setting there by disallowing this kernel to run in VS Code.

Clone this wiki locally