Skip to content
RCE Write-up Intermediate

Remote Command Execution in Visual Studio Code Remote Development Extension

The Visual Studio Code Remote Development Extension failed to sanitize the host field before passing it to the ssh command, allowing an attacker to inject a ProxyCommand option. An attacker could force a victim to open a malicious vscode:// link and execute arbitrary commands on the victim's system.

Abdel Adim Oisfi Follow

Published on shielder.it

Visual Studio Code Remote Development Extension 1.50 failed to sanitize the host field before using it as an argument of the ssh command, allowing to inject a ProxyCommand option which could be used to run arbitray commands.

Abdel Adim `smaury` Oisfi (@smaury92), on shielder.it

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 passed user-controlled input from a vscode:// URI directly as an argument to the ssh command without sanitization, enabling argument injection.

Impact

An attacker could execute arbitrary commands on the victim's system if the victim is forced to open a malicious link.

What the attacker needed

Visual Studio Code installed; Remote Development extension installed; Victim clicks a malicious link; Victim confirms opening VSCode

The fix

The vulnerability was fixed by upgrading the Visual Studio Code Remote Development Extension to version 1.51 or higher.

How it was found

  1. Install Visual Studio Code and the Remote Development extension.
  2. Open a browser and visit a crafted vscode:// link that includes a malicious host value.
  3. Confirm to open Visual Studio Code.
  4. Select a random operating system (Linux, Windows, or macOS).
  5. Observe the command execution, such as a PowerShell pop-up.

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.

When you click a special link, Visual Studio Code can open and try to connect to a remote computer using the ssh program. The link includes the address of that remote computer, but the program did not check that address carefully. An attacker could put extra instructions in the address, and ssh would run them as commands on your computer.

What is RCE?

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

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.