Severity:

CRITICAL RISK

(9.9)

Command Injection in Wrangler pages deploy --commit-hash

CVE-2026-0933

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-20

Impact:

Remote Code Execution on CI/CD or Developer Hosts

Severity:

CRITICAL RISK

(9.9)

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

A command injection flaw in the wrangler pages deploy command allows arbitrary shell command execution when the --commit-hash parameter is attacker-controlled.

In CI/CD or automated deployment pipelines that pass untrusted or indirectly controlled values into --commit-hash, an attacker could execute commands on the system running Wrangler and compromise build or deployment infrastructure.

Affected context

The vulnerability occurs in environments where Cloudflare Wrangler is used to deploy Pages applications via the wrangler pages deploy command and the --commit-hash argument is set dynamically.

It is most relevant in CI/CD pipelines, deployment scripts, or shared tooling where:

  • The --commit-hash value may come from external systems (e.g., webhooks, PR metadata, user-controlled refs, or other automation).
  • The pipeline assumes commit identifiers are safe and does not sanitize them before invoking Wrangler.

Local, manually run deployments are generally less exposed, unless a user copies or passes untrusted values directly into the --commit-hash flag.

Exploit preconditions

  • Attack surface: Systems that execute wrangler pages deploy (CI runners, build agents, deployment servers, or developer machines).
  • Required access: Ability to influence or control the value passed to the --commit-hash parameter (e.g., via manipulated repository state, configuration, environment variables, or pipeline inputs).
  • Trigger point: Execution of wrangler pages deploy --commit-hash "<attacker-controlled value>", where the value is propagated into the vulnerable shell command.
  • Why exploitation is possible: The commitHash variable is interpolated directly into a shell command template (e.g., execSync(\git show -s --format=%B ${commitHash}\)) without validation or escaping.

Shell metacharacters in the commit-hash string are interpreted by the underlying shell, enabling arbitrary command execution.

Why this happens

This issue stems from unsafe construction of shell commands from user-influenced input.

The commitHash value, derived from the --commit-hash CLI argument, is inserted directly into a shell command string executed via execSync (or equivalent).

Because the input is neither validated nor safely escaped, shell metacharacters (such as command separators, redirection operators, or subshell syntax) are treated as part of the command line rather than as data.

Conceptually, this is a case of improper input validation (CWE-20) that manifests as command injection, closely aligned with CWE-78: Improper Neutralization of Special Elements used in an OS Command.

The insecure pattern is: user-controlled or externally sourced text is concatenated into shell commands rather than passed as separate arguments to a non-shell API.

Potential impact

  • Execute arbitrary shell commands on the CI runner or machine running Wrangler.
  • Read and exfiltrate environment variables, including secrets, API tokens, and credentials used in the pipeline.
  • Modify, replace, or backdoor build artifacts before deployment.
  • Install persistent tooling or backdoors on build or deployment hosts.
  • Pivot to other internal resources accessible from the compromised runner.
  • Disrupt deployments, cause denial of service in the pipeline, or corrupt application releases.

General mitigation guidance

Effective mitigation focuses on preventing user-controlled data from being interpreted as shell syntax and tightening trust boundaries around deployment parameters.

Pattern-based mitigations include:

  • Avoiding shell interpretation: Use APIs that execute commands without invoking a shell, passing arguments as arrays rather than interpolated strings.
  • Strict input validation: Treat commit hashes and similar identifiers as opaque tokens and validate them against a strict pattern (e.g., allowed characters and length).
  • Escaping and neutralization: Where shell usage is unavoidable, consistently escape all user-influenced input using well-reviewed escape utilities, and avoid mixing trusted and untrusted segments in a single command line.
  • Configuration hardening: In CI/CD pipelines, ensure variables feeding --commit-hash come only from trusted sources and are not directly derived from user input or unreviewed metadata.
  • Least privilege: Run CI runners and deployment agents with minimal permissions, restricting access to secrets, file systems, and networks so that any command execution has constrained impact.
  • Defensive defaults: Prefer deployment workflows that do not require explicit commit-hash overrides unless strictly necessary, reducing the exposed attack surface.

How teams detect issues like this

Detection is best approached through a mix of code analysis, configuration review, and runtime monitoring.

Potential strategies:

  • Static analysis: Configure rules to flag direct string interpolation of CLI or environment variables into exec, execSync, spawn with shell: true, or comparable APIs.
  • Code review signals: Treat any shell command construction involving user-supplied or externally derived values (CLI arguments, environment variables, configuration fields) as high risk and require explicit validation and escaping.
  • Policy enforcement: Enforce internal guidelines that prohibit shell invocation from deployment tooling unless necessary, and require the use of safer child process APIs with structured arguments.
  • Pipeline configuration scanning: Periodically review CI configuration files (e.g., GitHub Actions, GitLab CI, CircleCI configs) to identify workflows where untrusted inputs are fed into wrangler pages deploy with --commit-hash.
  • Runtime monitoring: Monitor CI runners for anomalous command patterns, unexpected network connections, or access to sensitive files during deploy jobs, using logs and EDR tooling to catch suspicious activity.

Sources

SourceLink
github.comgithub.com/cloudflare/workers-sdk

Frequently asked

questions

Exploitability depends on whether an attacker can influence the value passed into --commit-hash. In tightly controlled pipelines where commit hashes are derived only from local, trusted repository state, the practical risk is reduced. In environments that consume external inputs or user-controlled refs, the exposure is significantly higher.

Not necessarily. The key requirement is control over the --commit-hash value. This might be achieved indirectly, for example by manipulating repository references, configuration, or external systems that feed data into the pipeline, even without shell access to the CI host itself.

The safest approach is to avoid building shell commands from untrusted data entirely. Use non-shell process execution APIs that accept arguments as arrays, perform strict validation of any data that might influence command execution, and ensure that deployment flags like --commit-hash are never populated from untrusted sources.

Adopt a design rule that no user-controlled or external input is ever concatenated into shell commands. Establish secure coding guidelines for deployment tooling, enforce static analysis checks for dangerous command execution patterns, and keep CI/CD configurations simple, with clearly defined trust boundaries for all pipeline inputs.

Find out what's already
exploitable in your codebase.