CVE-2026-21518
Visual Studio Code vulnerability analysis and mitigation

Overview

CVE-2026-21518 is a command injection vulnerability in Microsoft Visual Studio Code and the Visual Studio Code Copilot Chat extension that allows remote attackers to execute arbitrary code on affected installations. The flaw exists in the handling of mcp.json files, where user-supplied strings are not properly validated before being passed to system calls. It was disclosed and patched on February 10, 2026, as part of Microsoft's February 2026 Patch Tuesday. Affected versions include Visual Studio Code prior to 1.109.2. The vulnerability carries a CVSS v3.1 base score of 8.8 (High) (Microsoft MSRC, ZDI Advisory).

Technical details

The root cause is classified as CWE-77 (Improper Neutralization of Special Elements used in a Command — 'Command Injection'). The vulnerability arises because Visual Studio Code fails to sanitize user-supplied strings within mcp.json project configuration files before passing them to system calls. An attacker can craft a malicious project containing a weaponized mcp.json file; when a victim opens this project in VS Code, the injected command executes in the context of the current user. Exploitation requires user interaction (opening a malicious project) but no authentication or elevated privileges, making it a realistic social engineering or supply chain attack vector. A proof-of-concept was published by Zero Day Initiative on April 2, 2026 (ZDI Advisory, Feedly).

Impact

Successful exploitation grants an attacker arbitrary code execution in the context of the logged-in developer user, resulting in high confidentiality, integrity, and availability impact. Because developers typically have broad access to source code repositories, credentials, CI/CD pipelines, and internal infrastructure, compromise of a developer workstation poses a significant supply chain risk — an attacker could exfiltrate source code, inject malicious code into projects, or pivot to organizational systems. The Visual Studio Code Copilot Chat extension is also listed as an affected product (Microsoft MSRC, ZDI Advisory).

Exploitation steps

  1. Craft a malicious project: Create a Visual Studio Code project directory containing a weaponized mcp.json file with command injection payloads embedded in fields that are passed unsanitized to system calls (e.g., server command arguments or configuration strings).
  2. Distribute the malicious project: Deliver the project to the target via a public repository (e.g., GitHub), phishing email, or supply chain compromise — enticing the victim to clone or download and open it in VS Code.
  3. Trigger victim interaction: Instruct or socially engineer the target to open the project folder in Visual Studio Code. The MCP (Model Context Protocol) configuration in mcp.json is parsed automatically upon project load.
  4. Command injection executes: VS Code processes the malicious mcp.json without proper input validation, causing the injected OS command to be executed as a system call in the context of the current user.
  5. Achieve post-exploitation objectives: With code execution on the developer machine, the attacker can establish persistence, exfiltrate credentials or source code, deploy additional payloads, or pivot to connected infrastructure (ZDI Advisory, SystemTek).

Indicators of compromise

  • File System: Presence of a suspicious or externally sourced mcp.json file in a VS Code project directory containing unusual command strings, shell metacharacters, or encoded payloads in server/command fields.
  • Process: Unexpected child processes spawned by the VS Code process (e.g., cmd.exe, powershell.exe, /bin/bash, curl, wget, python) that are not typical for normal IDE operation.
  • Network: Outbound connections from the VS Code process or its child processes to unknown or suspicious external IP addresses or domains, particularly shortly after opening a project.
  • Logs: OS-level audit logs (e.g., Windows Event ID 4688 or Linux auditd) showing unusual process creation events with VS Code as the parent process; shell history entries showing commands not initiated by the user.

Mitigation and workarounds

Microsoft released a patch on February 10, 2026; users should update Visual Studio Code to version 1.109.2 or later to remediate this vulnerability (Microsoft MSRC). As an interim workaround, users should avoid opening VS Code projects from untrusted or unknown sources, particularly those received via email, public repositories, or third-party channels. Organizations should enforce policies restricting the opening of unvetted external projects on developer machines until systems are fully patched. Monitoring for anomalous child process activity from VS Code can help detect exploitation attempts.

Community reactions

The vulnerability was covered as part of broader February 2026 Patch Tuesday reporting by outlets including BleepingComputer, GBHackers, CyberSecurityNews, and The Cyber Express, which noted it among 54–58 vulnerabilities fixed that month (BleepingComputer). Sophos and Rapid7 also included it in their Patch Tuesday analysis blogs (Sophos Blog, Rapid7 Blog). Security researchers highlighted the supply chain risk angle, noting that targeting developer environments via malicious project files is a particularly impactful attack vector. A community write-up on Dev.to characterized it as a security feature bypass affecting GitHub Copilot and VS Code (Dev.to).

Additional resources


SourceThis report was generated using AI

Related Visual Studio Code vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-57102HIGH8.8
  • Visual Studio Code logoVisual Studio Code
  • cpe:2.3:a:microsoft:visual_studio_code
NoYesJul 14, 2026
CVE-2026-50520HIGH8.4
  • Visual Studio Code logoVisual Studio Code
  • cpe:2.3:a:microsoft:visual_studio_code
NoYesJul 14, 2026
CVE-2026-47282MEDIUM6.5
  • Visual Studio Code logoVisual Studio Code
  • cpe:2.3:a:microsoft:visual_studio_code
NoYesJul 14, 2026
CVE-2026-57101MEDIUM6.1
  • Visual Studio Code logoVisual Studio Code
  • cpe:2.3:a:microsoft:visual_studio_code
NoYesJul 14, 2026
CVE-2026-45496MEDIUM5.5
  • Visual Studio Code logoVisual Studio Code
  • cpe:2.3:a:microsoft:visual_studio_code
NoYesJul 14, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management