Skip to content
XSS Write-up Advanced

Visual Studio Code Security: Markdown Vulnerabilities in Third-Party Extensions (2/3)

Two VS Code extensions, GitLens and GitHub Pull Requests and Issues, built Markdown UI strings from attacker-controlled data without proper sanitisation, allowing injection of command links. An attacker could craft a malicious repository or GitHub issue so that a victim clicking a link would install and run an arbitrary extension, leading to code execution.

Thomas Chauchefoin Follow

Published on sonarsource.com

Bounty$100total stated by author View original

Last week's blog post summarized our DEF CON talk "Visual Studio Code Is Why I Have (Workspace) Trust Issues". We presented common attack surfaces of the popular code editor Visual Studio Code (VSCode) and showed examples for each of them, either found by us or by other researchers.

Thomas Chauchefoin (@swapgs), Paul Gerste, on sonarsource.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 extensions failed to sanitise or escape attacker-controlled data before embedding it in Markdown strings marked as trusted, allowing injection of command links.

Impact

An attacker could execute arbitrary code on the victim's machine by tricking them into clicking a link, bypassing Workspace Trust in some cases; the attacks require user interaction and the vulnerabilities have been fixed.

What the attacker needed

Victim uses vulnerable extension version; Victim opens a malicious repository or issue; Victim clicks a crafted link

The fix

The vulnerabilities were fixed by disabling Git integration in untrusted workspaces for GitLens and by not setting the isTrusted property on Markdown strings for the GitHub extension; developers should sanitise or escape data before building Markdown.

How it was found

  1. Create a malicious Git repository with a crafted line containing a carriage return and a closing code fence followed by a Markdown link to a command URL.
  2. Open the repository in VS Code with GitLens installed and hover over the inline blame to trigger the popup.
  3. Click the injected link, which triggers the installation of an attacker-controlled extension from the marketplace.
  4. Alternatively, create a GitHub issue containing a Markdown code block with a command link inside.
  5. View the issue in the GitHub Pull Requests and Issues extension and click the rendered link to install the malicious extension.

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.

VS Code extensions often show information using Markdown, a simple formatting language. If an extension inserts untrusted text into Markdown without cleaning it, an attacker can sneak in a special link that, when clicked, makes VS Code install and run a malicious extension. This gives the attacker control over the victim's computer.

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 Thomas Chauchefoin

View all

3 more disclosed reports, best first.

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.