Breaking Out of Restricted Mode: XSS to RCE in Visual Studio Code
A cross-site scripting flaw in the minimal error rendering mode for Jupyter notebooks allowed arbitrary JavaScript to run inside the notebook renderer WebView. An attacker could trigger it by getting a victim to open a crafted notebook file, even with Restricted Mode enabled, and this could lead to remote code execution.
starlabs.sg
Published on starlabs.sg
In April 2024, I discovered a high-severity vulnerability in Visual Studio Code (VS Code <= 1.89.1) that allows attackers to escalate a Cross-Site Scripting (XSS) bug into full Remote Code Execution (RCE)—even in Restricted Mode.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could execute arbitrary JavaScript in the notebook renderer and potentially escalate to remote code execution, even when Restricted Mode is enabled.
What the attacker needed
Victim opens a crafted .ipynb file; minimal error rendering setting enabled or crafted…
How it was found
- Enable the minimal error rendering setting for Jupyter notebooks, or place a crafted settings.json in a folder.
- Open a crafted .ipynb notebook file in VS Code.
- The malicious notebook triggers the XSS in the notebook renderer WebView.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Visual Studio Code is a popular code editor built on Electron, which is like a web browser bundled into a desktop app. A cross-site scripting (XSS) bug lets an attacker sneak JavaScript code into a page that the app trusts, so the code runs with the app's permissions. Here, opening a malicious notebook file could run the attacker's code inside the editor, and because the editor can run commands on the computer, that could escalate to full remote code execution.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.