Skip to content
XSS Write-up Intermediate

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.

Justin Steven Follow

Published on github.com

History

Justin Steven (@justinsteven), on github.com

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

  1. Create a malicious notebook whose cell output is Markdown containing an image with an error handler.
  2. Start a local web server to receive the exfiltrated data.
  3. Open the notebook file in stock Visual Studio Code.
  4. 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.

More by Justin Steven

View all

4 more disclosed reports, best first.

More from Microsoft

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.