← Lab /Security & privacy

Control characters in VS Code run configurations enable command injection

Embedding ASCII control characters in VS Code's node-pty arguments allows arbitrary command execution on macOS and Linux.

Security & privacy PortSwigger Research 30 Apr 2025 Disclosure Prototype evidence

Published as “Drag and Pwnd: Leverage ASCII characters to exploit VS Code”

Why it matters

Applications that forward raw bytes to a terminal must sanitize control characters to prevent command injection.

Summary

The author shows that VS Code forwards raw bytes from run configuration arguments and drag-and-drop filenames directly to a shell via node-pty. By inserting ASCII control characters such as SOH (\x01) or carriage return (\x0d), the shell cursor moves or commands are executed, enabling injection of arbitrary commands like opening the Calculator app. The issue is reproduced on macOS and Ubuntu, while Windows mitigates it due to filesystem restrictions and PowerShell behavior. Evidence consists of proof-of-concept configurations and a Burp Suite extension for testing.

What they found 2

  1. Inserting a SOH (\x01) character into VS Code run configuration arguments causes the shell to split and launch arbitrary applications.

    “inserting a [ \x01 ] SOH character into arguments causes the shell to split and misinterpret them.”

  2. A carriage return (\x0d) in a dragged-and-dropped filename is interpreted as an Enter key, automatically executing the embedded command.

    “Be aware that when a file is dragged and dropped, the carriage return character [\x0d] automatically executes a command.”

Caveats 4

  • Microsoft Security Response Center does not consider the issue a security vulnerability, citing existing mitigations such as workspace trust warnings and required user interaction.
  • On Windows, the filesystem disallows control characters in filenames and VS Code defaults to PowerShell, which does not interpret these characters as cursor movements.
  • The vulnerability requires user interaction (e.g., editing run configurations or dragging files into the terminal).
  • Microsoft's assessment downplays severity due to mitigations.

What’s new here 4

  • Identifies misuse of ASCII control characters (SOH, ETX, etc.) in VS Code's node-pty leading to command injection.
  • Demonstrates injection via custom run configuration arguments and drag-and-drop filenames.
  • Shows that macOS Terminal and Ubuntu terminals interpret these characters, allowing arbitrary application launch.
  • Provides a bypass of a common shell-escaping function and a Burp Suite extension for automated testing.