Skip to content
RCE Write-up Intermediate

Don't Clone That Repo: Visual Studio Code^2 Execution

The Visual Studio Code Python extension automatically activated a virtual environment found inside a cloned project folder and trusted a settings file from that folder without asking the user. An attacker could place a malicious virtual environment in a repository so that opening a Python file in it ran attacker-controlled code.

blog.doyensec.com

Published on blog.doyensec.com

This is the story of how I stumbled upon a code execution vulnerability in the Visual Studio Code Python extension. It currently has 16.5M+ installs reported in the extension marketplace.

Filippo Cremonese, on blog.doyensec.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 extension loaded a workspace settings file and activated a virtual environment path from it without user confirmation, so a repository could supply both the setting and the environment.

Impact

Opening a Python file in a cloned repository could execute arbitrary code on the user's machine; the text notes the issue was still unpatched at the time of writing.

What the attacker needed

Victim clones a malicious repo; victim adds it to the workspace; victim opens a Python file

The fix

The extension should ask the user before activating a virtual environment or trusting a workspace settings file from a cloned repository; the text says the issue was not yet patched.

How it was found

  1. Clone the proof-of-concept repository.
  2. Add the cloned repository to the editor workspace.
  3. Open the Python file in the editor, which triggers the malicious virtual environment.

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 virtual environment is a private folder of Python tools that a project uses. The editor was picking up such a folder from a downloaded project and running its contents without checking with the user, so a booby-trapped project could run code on the victim's machine just by being opened.

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.