Cloudanix VulnDB

CVE-2021-31213

High · 7.8

CVSS

7.8

EPSS

52.8%

Published

May 11, 2021

CISA due date

—

Cloudanix analysis

Next patch cycle SSVC: Attend

A malicious project opened in the affected development tool could let an attacker run commands on a developer’s computer and steal sensitive work materials.

Exploitation
Requires User Interaction
Attacker needs
User Interaction
Complexity
Moderate
Impact
Remote Code Execution
Component
Application
Class
RCE
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

This vulnerability affects the Visual Studio Code Remote Containers extension and can allow code execution in the context of the local user when a victim opens or interacts with attacker-controlled content using the extension. The CVSS vector indicates local attack surface with no attacker privileges required, low complexity, and required user interaction. Successful exploitation can compromise confidentiality, integrity, and availability of the workstation because the attacker-controlled workspace or container configuration can cause commands or tooling to execute on the developer system or in a closely integrated container environment with access to project files, credentials, SSH agents, source code, and developer secrets.

Why it matters to the business

A successful exploit can turn a developer workstation into an entry point for broader compromise. This may expose source code, cloud credentials, signing keys, SSH keys, access tokens, and internal development resources, and may allow an attacker to tamper with software builds or pivot into other systems reachable from the developer environment. Although this issue is not listed in CISA KEV and no mature public exploit is indicated in the supplied data, the EPSS score is elevated, so organizations using Visual Studio Code Remote Containers should treat remediation as important, especially where developers open third-party repositories or untrusted project archives.

How an attack unfolds

An attacker prepares a malicious project, repository, or development-container configuration intended to be opened with Visual Studio Code and the Remote Containers extension. The attacker then convinces a developer to clone, download, or open that content. When the developer opens the workspace or triggers the Remote Containers workflow, the extension processes attacker-controlled configuration and may execute attacker-supplied commands. Code then runs with the privileges and access available to the developer environment, potentially enabling theft of repository contents, local secrets, SSH agent material, package-manager credentials, cloud tokens, or further execution through build scripts, shell profiles, container lifecycle hooks, or integrated terminal activity.

How to fix it

Update Visual Studio Code and the Remote Containers extension to a version that includes Microsoft’s fix for CVE-2021-31213. Because no exact fixed version was supplied, use the latest available release of the Remote Containers extension and keep VS Code extensions configured for automatic updates where feasible. Remove or disable the Remote Containers extension on systems that do not require it. Require Workspace Trust or equivalent controls before opening untrusted folders, and instruct developers not to open unknown repositories, archives, or devcontainer configurations without review. Review and restrict container features that mount sensitive host paths, forward SSH agents, expose credentials, or run lifecycle commands automatically. Where possible, open untrusted projects in isolated disposable virtual machines or sandboxes rather than on primary developer workstations.

How to confirm the fix worked

Confirm that the installed Remote Containers extension has been updated beyond the vulnerable release by checking the Extensions view in Visual Studio Code, the extension management CLI, or enterprise software inventory. Verify that VS Code and extensions are receiving updates and that the Remote Containers extension is not installed where unnecessary. Test that Workspace Trust or equivalent prompts are enabled before untrusted workspaces run tasks, lifecycle commands, or extension-driven automation. Review representative developer workstations for risky workspace settings, automatic task execution, container lifecycle hooks, and host mounts in devcontainer configuration. Confirm that endpoint controls can observe VS Code-spawned child processes, Docker or container runtime activity, and unusual network connections from editor-related processes.

Typical attack path

  1. Attacker creates a malicious repository, archive, or workspace containing Remote Containers configuration or supporting build files.
  2. Attacker distributes the content through social engineering, a pull request, a dependency contribution, a sample project, or a shared development artifact.
  3. A developer opens the workspace in Visual Studio Code with the Remote Containers extension installed.
  4. The extension processes the malicious container/workspace configuration during open, rebuild, attach, or initialization workflows.
  5. Attacker-controlled commands execute in the developer context or an integrated container context with access to mounted files and developer tooling.
  6. The attacker collects source code, tokens, SSH credentials, package registry credentials, cloud credentials, or other local secrets.
  7. The attacker may persist through modified project files, shell startup files, editor tasks, container hooks, or build scripts, and may pivot into repositories, CI/CD systems, or cloud resources accessible to the developer.

How to detect it

To determine whether exploitation may already have occurred, review endpoint detection logs, process creation telemetry, VS Code extension logs, shell history, Docker or container runtime logs, and file modification timelines around the time developers opened unfamiliar repositories or Remote Containers workspaces. Focus on child processes spawned by Visual Studio Code or its extension host, such as shells, scripting engines, curl/wget, credential tools, SSH utilities, package managers, Docker commands, or cloud CLIs. Inspect recently opened workspaces for suspicious .devcontainer/devcontainer.json files, Dockerfiles, postCreateCommand, postStartCommand, initializeCommand, onCreateCommand, updateContentCommand, custom features, bind mounts to sensitive host directories, or unexpected scripts. Check for access to credential locations such as SSH keys, cloud credential files, npm/yarn/pip registry tokens, Git credentials, and password-store files shortly after opening a container workspace. Review outbound network connections from Code.exe, the VS Code extension host, shell processes, Docker build steps, or container initialization commands to unknown domains or IPs. Because no specific public exploit artifact was supplied, detection should be behavior-based rather than signature-only.

What your security team should do

  • Inventory systems with Visual Studio Code and the Remote Containers extension installed, prioritizing developer workstations and build engineering systems.
  • Update the Remote Containers extension and Visual Studio Code to the latest available versions across managed endpoints.
  • Disable or remove the extension where it is not required for business workflows.
  • Enforce Workspace Trust or similar controls to prevent automatic execution from untrusted repositories.
  • Create developer guidance for safely reviewing .devcontainer content, Dockerfiles, lifecycle commands, tasks, and mounted host paths before opening external projects.
  • Monitor endpoint telemetry for unusual child processes spawned by Visual Studio Code, the Remote Containers extension, Docker, or container initialization workflows.
  • Hunt for recent openings of untrusted repositories followed by credential access, network beacons, shell execution, package-manager token access, SSH agent use, or unexpected file modifications.
  • Use isolated disposable development environments for third-party, unknown, or externally submitted repositories.

The record

Visual Studio Code Remote Containers Extension Remote Code Execution Vulnerability

Affected packages

Ecosystem Package Introduced Fixed