Skip to content
RCE Write-up Intermediate

Expand file tree

The Visual Studio Code Python extension trusted a workspace setting that names the Python interpreter path, so a crafted workspace could point it at a file inside the workspace. Opening such a workspace caused that file to be executed, giving arbitrary code execution, and this could be triggered from a browser via the editor's URI handler.

github.com

Published on github.com

History

The author, 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

The extension treated a workspace-controlled setting as the path to a trusted executable and ran it without any confirmation or trust check.

Impact

An attacker could run arbitrary code on the victim's machine, though on modern macOS browser-based delivery may no longer work, and on Windows the WebDAV route was unreliable in testing.

What the attacker needed

Victim opens a malicious workspace; Python extension installed; browser delivery needs a click or two

How it was found

  1. Create a workspace containing a settings file that sets the Python interpreter path to a file inside the workspace
  2. Place an executable file at that path
  3. Open the workspace in Visual Studio Code
  4. Trigger execution by opening a Python file, or set file associations so it runs on open
  5. For browser delivery, host the workspace on SMB, WebDAV or NFS and send a link using the editor's URI handler

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 code editor can be told, by a settings file inside a project folder, which Python program to use for features like autocomplete. The editor ran whatever file that setting pointed at, so a project folder downloaded from the internet could carry its own program and get it run just by being opened. The attacker only needed the victim to open the folder, or to click a link that makes the editor open a folder hosted on the attacker's machine.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.