/

CVE-2026-29783

Severity:

HIGH RISK

(7.8)

Command Injection in GitHub Copilot CLI Shell Tool

CVE-2026-29783

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-78

Impact:

Arbitrary Code Execution on Developer Workstations

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The shell tool in GitHub Copilot CLI up to version 0.0.422 contains a command injection weakness where crafted bash parameter expansion patterns can hide executable code inside commands classified as "read-only."

An attacker who can influence the command text sent to the shell tool—via prompt injection in repository content, MCP responses, or user instructions—may achieve arbitrary code execution on the user's workstation despite safety checks that appear to allow only non-destructive operations.

Affected context

This vulnerability arises when the Copilot CLI shell tool is used to generate and execute shell commands within interactive workflows, particularly in environments where developers rely on the tool's safety assessment to distinguish read-only from write-capable commands.

It is most relevant when:

  • The CLI is run in bash or bash-compatible shells where advanced parameter expansion is available
  • The shell tool is allowed to execute suggested commands automatically or with minimal review
  • Command text is influenced by untrusted or semi-trusted inputs, such as repository files, MCP server output, or shared prompts

Exploit preconditions

  • Attack surface: The GitHub Copilot CLI shell tool running in a terminal on the developer's machine.
  • Required access: Ability to influence the text of commands sent to the shell tool (e.g., via malicious repository content, compromised or malicious MCP server responses, or crafted user instructions containing encoded shell patterns).
  • Trigger point: Execution of a command that the safety layer incorrectly classifies as read-only but that contains dangerous bash parameter expansions such as ${var@P}, ${var=value} / ${var:=value}, ${!var}, or nested $(cmd) / <(cmd) inside ${...}.
  • Why exploitation is possible: The safety assessment performs static classification of commands focused on obvious write operations and utilities. It does not fully model how bash parameter expansion can execute code or alter environment variables, allowing attackers to embed side-effectful logic inside arguments to seemingly benign commands.

Why this happens

The bug stems from an incomplete understanding and modeling of bash's expressive parameter expansion features within the CLI's shell safety layer.

The safety mechanism attempts to categorize commands as read-only or write-capable based on their surface structure and the apparent utilities involved. However, bash constructs like ${var@P}, ${var=value}, ${var:=value}, ${!var}, and nested command substitutions within ${...} can:

  • Trigger evaluation of additional commands
  • Modify environment variables or shell state
  • Indirectly cause file writes and other side effects

Because these expansions are embedded in argument positions that visually resemble harmless variable usage, the classifier treats them as safe, leading to CWE-78: Improper Neutralization of Special Elements used in an OS Command (OS Command Injection). At an abstract level, user-influenced command templates are executed without robust normalization and semantic validation of all shell metacharacters and expansion semantics.

Potential impact

  • Execution of arbitrary shell commands on the developer's workstation under the developer's user privileges
  • Silent file modification, creation, or deletion despite apparent "read-only" commands
  • Exfiltration of sensitive data such as SSH keys, API tokens, or local source code
  • Installation or execution of additional malware or persistence mechanisms
  • Lateral movement within the developer's environment using existing credentials or tooling

General mitigation guidance

From a defensive design perspective, mitigation focuses on constraining shell semantics and treating all command text as potentially hostile:

  • Prefer structured, non-shell execution APIs (e.g., execve-style calls with explicit argument vectors, or high-level file/query APIs) instead of handing raw command strings to an interactive shell.
  • When a shell must be used, disable or tightly constrain advanced features such as parameter expansion, command substitution, and process substitution—either by using a restricted shell mode or by rejecting commands containing these metacharacters.
  • Implement a semantic allowlist of operations for "read-only" mode, checking not just command names but also arguments for expansions like ${...}, $(), backticks, <(), and indirect expansion patterns.
  • Normalize and canonicalize commands before classification, collapsing or rejecting constructs that can change meaning at execution time.
  • Apply principle of least privilege for the environment in which commands run: limit accessible directories, environment variables, and credentials, and avoid running with elevated privileges.
  • Encourage users to visually review and understand commands prior to execution, especially when they originate from untrusted repositories, MCP servers, or shared prompts.

How teams detect issues like this

Detection is best approached by a combination of static analysis, configuration review, and behavioral monitoring:

  • Static analysis / linting of tooling code that generates or executes shell commands:
  • Flag uses of general-purpose shells (/bin/bash, /bin/sh) with dynamically constructed command strings.
  • Detect and warn when safety logic relies on naive pattern matching without accounting for ${...}, $(), backticks, <(), or indirect expansion.
  • Code review signals:
  • Logic that classifies commands as "safe" or "read-only" based on partial parsing or allowlists that ignore shell semantics.
  • Any layer that inspects command strings before execution but does not re-validate the exact text that is ultimately passed to the shell.
  • Policy enforcement:
  • CI policies that disallow direct use of complex shell expansions in auto-generated commands or that require explicit approval for such patterns.
  • Integration of automated review tools that search for shell execution with untrusted input and highlight complex expansion usage.
  • Runtime monitoring (where feasible):
  • Auditing of developer workstations or controlled environments for unexpected shell activity originating from assistant or CLI tooling processes.

Sources

SourceLink
github.comgithub.com/github/copilot-cli/releases/tag/v0.0.423
github.comgithub.com/github/copilot-cli/security/advisories/GHSA-g8r9-g2v8-jv6f

Frequently asked

questions

Exploitability depends on whether an attacker can influence the command text sent to the Copilot CLI shell tool. In environments where developers frequently run shell suggestions based on repository content or MCP responses, a malicious repository or compromised server can make exploitation relatively straightforward.

No direct system access is required. The attacker needs a path to influence commands—such as contributing malicious files to a repository, controlling or spoofing an MCP server, or persuading a user to paste or follow crafted instructions that the shell tool processes.

The most robust fix is to avoid passing dynamically constructed strings to a general-purpose shell whenever possible and instead use structured execution APIs. If a shell must be used, enforce strict normalization and semantic validation, and reject or sandbox advanced features like parameter expansion and command substitution, particularly in "safe" or "read-only" modes.

Treat all command text as untrusted, especially when derived from AI-generated content, repository files, or remote services. Design safety layers that reason about full shell semantics rather than just command names, employ allowlists of permissible operations, and incorporate security review and testing (including fuzzing and adversarial prompts) for any feature that generates or auto-executes shell commands.

Find out what's already
exploitable in your codebase.