Skip to content
RCE Write-up Advanced

Securing Developer Tools: Argument Injection in Visual Studio Code

A URL handler in Visual Studio Code passed a user-controlled Git repository URL to the Git command line without sanitising it, so a URL beginning with dashes was treated as an option. An attacker could craft a link that, when clicked and accepted, caused arbitrary commands to run on the victim's computer.

Thomas Chauchefoin Follow

Published on blog.sonarsource.com

Welcome back to our Securing Developer Toolsseries (part 1, part 2), in which we look at the security of software used by millions of developers every day! The safety of these applications is crucial to prevent attackers from compromising the computer on which developers are working, as they could use this access to…

Thomas Chauchefoin (@swapgs), on blog.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

The Git clone URL was concatenated into the external Git command line without validation, so a value starting with dashes was interpreted as a command-line option.

Impact

An attacker could execute arbitrary commands on a developer's computer, but the victim must click the link and accept the clone prompt, and Workspace Trust may not block it if the last focused window is trusted.

What the attacker needed

Visual Studio Code installed; victim clicks a crafted vscode:// link; victim accepts the clone prompt

The fix

Microsoft fixed it by parsing the clone URL with an internal URI parser and validating its scheme against an allow list, so the start of the value can no longer be fully controlled.

How it was found

  1. Craft a vscode:// link that triggers the git.clone command with a URL beginning with a dash.
  2. Include an option that overrides the command Git uses to talk to the remote, plus a suffix that makes Git use the local transport.
  3. Send the link to a developer; when they click it, Visual Studio Code prompts them to clone a Git repository.
  4. If the developer accepts the clone, the injected option causes Git to run the attacker's command.

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.

Visual Studio Code can open special links that start with vscode://, for example to clone a Git repository. The bug was that the repository address in such a link was handed to the Git program without checking whether it looked like an option (a word starting with a dash) rather than an address. By putting a fake option in the link, an attacker could make Git run a command of their choosing when the victim accepted the clone.

What is RCE?

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

More by Thomas Chauchefoin

View all

5 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.

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.