OVE-20210809-0001 Visual Studio Code .ipynb Jupyter Notebook XSS (Arbitrary File Read)
A crafted Jupyter Notebook file could embed Markdown output containing HTML and JavaScript, which Visual Studio Code rendered immediately on opening without a meaningful Content Security Policy. An attacker could run script inside the editor and use a special file-reading API to read local files such as private SSH keys and send them to a remote server.
Published on github.com
History
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
Root cause
Likely the notebook viewer rendered attacker-supplied Markdown as HTML and JavaScript in an Electron webview without a meaningful Content Security Policy, and the built-in extension opted out of Workspace Trust.
Impact
An attacker could read arbitrary files the editor can access, including private SSH keys, and exfiltrate them, with no further user interaction and even in Restricted mode; the author could not find a path to code execution.
What the attacker needed
Victim opens a crafted .ipynb file; stock VS Code 1.59.0; no kernel extensions needed
The fix
The notebook renderer should apply a meaningful Content Security Policy and should not opt out of Workspace Trust protections.
How it was found
- Create a malicious notebook whose cell output is Markdown containing an image with an error handler.
- Start a local web server to receive the exfiltrated data.
- Open the notebook file in stock Visual Studio Code.
- Observe the file contents shown in the editor and the data arriving at the server.
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.
A notebook file can carry a hidden script that runs as soon as you open it in the editor. That script can ask the editor to read files on your computer, such as your private SSH key, and send them to someone else. You do not have to click anything or trust the folder for this to happen.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.