Summary
Visual Studio Code Code Runner extension v0.12.2 contains a code injection vulnerability in its code-runner.executorMap setting, where crafted workspace configuration can cause arbitrary commands to be executed.
If a user opens a malicious workspace and triggers Code Runner, an attacker-controlled executor configuration may lead to arbitrary code execution under the user's privileges.
Affected context
The vulnerability arises when developers use the Code Runner extension in Visual Studio Code and open workspaces that provide or influence the code-runner.executorMap configuration.
Risk is elevated in scenarios where:
- Workspaces are cloned from untrusted repositories, or
- Users accept workspace settings without carefully reviewing them, and
- The extension is used to run code through its configured executors.
In these contexts, the executor configuration can be abused as an execution vector instead of a simple tooling setting.
Exploit preconditions
- Attack surface: Visual Studio Code environment using the Code Runner extension.
- Required access: Ability for an attacker to supply or modify a workspace (e.g., repository, project folder) that the victim opens, including its VS Code settings.
- Trigger point: The user opens the crafted workspace and invokes Code Runner (e.g., via run commands, buttons, or keybindings) that rely on
code-runner.executorMap. - Why exploitation is possible: The extension treats workspace-provided executor definitions as trusted, and uses them to construct command lines, enabling attacker-controlled values to be executed as system commands.
Why this happens
This issue stems from treating configuration values as implicitly trusted executable command templates.
The code-runner.executorMap setting allows defining how different languages are executed, but the extension does not sufficiently constrain or validate workspace-provided values and uses them to build shell commands.
This aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), where untrusted input is incorporated into executable instructions without enforcing strict separation between configuration data and code.
Potential impact
- Execution of arbitrary system commands under the context of the developer's user account
- Installation of malware or backdoors on developer machines
- Theft or exfiltration of source code, credentials, or secrets present on the workstation
- Manipulation of local development environments and build artifacts
- Use of compromised developer machines as a pivot point into wider internal networks
General mitigation guidance
Effective mitigation focuses on tightening the trust boundary around configuration-driven execution:
- Treat workspace-level execution settings as untrusted when sourced from external or shared projects, and consider disabling them by default.
- Prefer static, user-level executor definitions that are not overridden by workspace configuration from arbitrary repositories.
- Apply strict validation and normalization to any configuration used to construct commands, avoiding direct interpolation of uncontrolled values into shell invocations.
- Reduce the privileges of the processes invoked by the extension, and avoid running them in high-privilege terminals or shells.
- Encourage workflows where developers review and approve workspace settings before enabling extensions that execute commands based on those settings.
How teams detect issues like this
Detection can focus on configuration and behavior analysis:
- Use static checks or linters to examine
.vscode/settings.jsonand similar configuration files for suspicious or untrustedcode-runner.executorMapentries. - Incorporate code review practices that flag changes to executor or tooling settings that introduce shell constructs, chaining operators, or unexpected binaries.
- Apply security policies within development environments to restrict or alert on extensions that execute arbitrary commands derived from workspace configuration.
- Monitor endpoint telemetry on developer machines for unusual processes spawned by the editor, correlating them with workspace activity and extension usage.

