/

CVE-2026-11572

Severity:

HIGH RISK

(8.8)

Command Injection (CWE-78) in degit Git Repository Handling

CVE-2026-11572

Deferred

Vulnerability type

Category:

Command Injection

CWE:

CWE-78, CWE-77

Impact:

Remote Code Execution

Severity:

HIGH RISK

(8.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

Degit contains a command injection vulnerability where unsanitized user input is passed into git shell commands that are executed via exec().

By providing a specially crafted git repository name, an attacker can cause arbitrary operating system commands to run with the privileges of the degit process, especially in workflows that clone untrusted repositories.

Affected context

This vulnerability affects environments where degit is used to clone git repositories based on user-controlled or partially untrusted input.

It is most relevant in CLI tools, scaffolding generators, CI/CD pipelines, or web services that accept repository identifiers and forward them directly to degit without strict validation.

The problem arises when the repository name is interpolated into git shell commands constructed as strings and executed via exec(), without robust escaping or restriction to a safe subset of characters and formats.

Exploit preconditions

  • Attack surface: Any interface (CLI, API, web form, CI job configuration, or script) that passes user-supplied repository names into degit.
  • Required access: Ability to influence or control the git repository argument consumed by degit, either directly (user input) or indirectly (config files, environment variables, templates).
  • Trigger point: Invocation of _cloneWithGit() or fetchRefs() where the crafted repository name is concatenated into a shell command that is executed using exec().
  • Why exploitation is possible: The repository name is treated as trusted data and embedded into a shell command line without proper quoting, escaping, or parameterization, allowing shell metacharacters to break out of the intended git command and inject additional commands.

Why this happens

The underlying issue is classic command injection: dynamic shell commands are constructed by concatenating untrusted input and then executed with a generic shell API.

Instead of invoking git with a parameterized, argument-based process spawn, degit uses exec() with a single command string that includes the repository name.

This pattern corresponds to CWE-78 (Improper Neutralization of Special Elements used in an OS Command) and CWE-77 (Improper Neutralization of Special Elements used in a Command), where shell metacharacters are not neutralized, allowing injected tokens to be interpreted as separate commands or arguments.

Conceptually, the code fails to enforce a strict separation between data (user repository identifiers) and control (the shell command being executed), enabling arbitrary command execution in the context of the running process.

Potential impact

  • Arbitrary command execution with the privileges of the process running degit
  • Unauthorized access to sensitive files and environment variables on the host system
  • Compromise of CI/CD runners, build agents, or developer workstations that rely on degit
  • Installation of malware, backdoors, or persistence mechanisms in development environments
  • Lateral movement within the network if credentials or tokens are accessible to the compromised process

General mitigation guidance

Mitigation focuses on eliminating unsafe command construction patterns and reducing trust in repository identifiers:

  • Prefer APIs that spawn subprocesses with argument arrays (e.g., spawn/execFile equivalents) instead of building shell command strings.
  • Treat repository names as opaque data and strictly validate them against a whitelist of allowed patterns (e.g., specific URL schemes, hostnames, and character sets).
  • Avoid passing user input through the shell; when shell usage is unavoidable, apply rigorous escaping and avoid interpreting metacharacters.
  • Run tools that interact with untrusted repositories under least-privilege service accounts with limited filesystem and network access.
  • Isolate high-risk cloning workflows (e.g., in CI pipelines) inside containers or sandboxes to contain potential compromise.

How teams detect issues like this

Effective detection usually combines static analysis, code review, and runtime controls:

  • Use static analysis rules to flag usages of generic shell execution functions (like exec, execSync, or similar APIs) where user input, configuration strings, or environment variables influence the command string.
  • In code review, look for string concatenation or template literals that assemble git commands, and verify that any user-controllable values are either disallowed or rigorously validated.
  • Enforce internal policies that prohibit shell-based command construction for VCS operations, preferring library APIs or argument-based subprocess execution.
  • Integrate security-focused linters or SAST tools in CI to automatically detect OS command injection patterns across the codebase.

Sources

SourceLink
gist.github.comgist.github.com/badp3te/cf22a939eedbd3d8ade9123827d61639
github.comgithub.com/Rich-Harris/degit/commit/4ac99e4a4c3f53ca3b5c997bcd7542742ad0c443
github.comgithub.com/Rich-Harris/degit/commit/d55bfd7cea79c0b387f69ec8477b6c34abf9f226
security.snyk.iosecurity.snyk.io/vuln/SNYK-JS-DEGIT-17116207

Frequently asked

questions

It can be, depending on how degit is exposed. If a web service, API, or other remotely accessible interface passes user-supplied repository names to degit, an attacker can exploit the issue remotely. In purely local CLI usage, exploitation is limited to users running crafted commands themselves.

The attacker needs control over the repository identifier that degit processes. This could be direct user input (e.g., a parameter in a tooling command), a configuration entry, or a value in a CI job definition they can modify.

The safest approach is to stop constructing shell command strings with untrusted data and instead invoke git using safe, argument-based process APIs. Combine this with strict validation of repository identifiers to only allow well-formed, expected formats.

Adopt a development practice that treats all external input as untrusted, forbids shell execution with concatenated strings, and relies on security reviews and automated analysis to flag injection patterns. Encapsulate interactions with external tools (like git) behind well-defined, parameterized interfaces that cannot be influenced by raw user input.

Find out what's already
exploitable in your codebase.