The vulnerability is a stored Cross-Site Scripting (XSS) issue in Jupyter Notebook, identified as GHSA-rch3-82jr-f9w9. The root cause is in the help:open command, located in the @jupyter-notebook/help-extension. The execute function of this command would take a URL from its arguments and open it in a new window without any validation. An attacker could craft a malicious notebook containing a command link that invokes help:open with a javascript: URL. When a user interacts with this link, the malicious script executes, leading to token theft and account takeover.
The analysis of the patches between the vulnerable version 7.5.5 and the patched version 7.5.6 of jupyter/notebook reveals two key changes. The primary fix is in packages/help-extension/src/index.tsx, where a new function isUrlSafe is introduced to validate the protocol of the URL before it is opened. This directly mitigates the XSS vulnerability in the help:open command.
A secondary, but important, change was made in packages/application-extension/src/index.ts within the rendermime plugin. The linkHandler was modified to no longer use app.commandLinker.connectNode, which was the mechanism abused to create the malicious command links. The new implementation uses a standard addEventListener and a trustHandler, providing a more secure way of handling links in rendered output. This change hardens the application against similar attacks in the future.