Summary
Deno's node:child_process implementation prior to 2.7.10 incorrectly escaped command-line arguments when shell: true was used, leaving Windows cmd.exe metacharacters and % expansion unneutralized.
If an attacker can influence any portion of arguments passed to spawn, spawnSync, exec, or similar calls with shell: true, they could inject arbitrary commands into the resulting cmd.exe invocation.
Affected context
This vulnerability occurs in applications built on Deno that rely on the node:child_process API with shell: true on Windows systems.
It becomes relevant when user-controlled or environment-derived data is incorporated into command arguments that are passed through escapeShellArg() to cmd.exe.
The issue is limited to contexts where Deno code constructs shell commands dynamically and depends on the runtime to safely escape arguments, rather than using safer non-shell invocation patterns.
Exploit preconditions
- Attack surface: Deno applications that invoke node:child_process with
shell: trueon Windows. - Required access: Ability to control or influence any part of the arguments passed to spawn/spawnSync/exec or similar functions (e.g., via HTTP input, CLI parameters, configuration, or environment variables).
- Trigger point: Execution of a child_process call that builds a command line using escapeShellArg() and launches cmd.exe.
- Why exploitation is possible: The escaping helper does not properly quote cmd.exe metacharacters and fails to neutralize
%, allowing cmd.exe to treat attacker-controlled input as additional command syntax or variable expansion rather than a literal argument.
Why this happens
The underlying bug is an OS command injection pattern where untrusted data is combined into a shell command without adequate neutralization of shell control characters.
Specifically, the escapeShellArg() helper used by Deno's node:child_process implementation on Windows incorrectly assumes that double-quoting is sufficient, overlooking cmd.exe-specific metacharacters and % expansion semantics.
This aligns with CWE-78: OS Command Injection, in which application code delegates untrusted input directly into shell parsing logic, allowing the shell to interpret it as executable commands instead of inert data.
Potential impact
- An attacker may execute arbitrary commands under the privileges of the Deno process.
- Application data and configuration could be read, modified, or deleted via injected commands.
- The host system could be further compromised, enabling lateral movement or persistence.
- Logging, audit records, or other security controls can be tampered with through malicious command execution.
General mitigation guidance
Effective mitigation focuses on eliminating unsafe shell composition and reducing trust in external input.
Common defensive patterns include:
- Prefer non-shell invocation (e.g., passing arguments as structured arrays to subprocess APIs) instead of
shell: true, especially on Windows. - Avoid constructing command strings from user or environment input; treat such data as parameters, not command fragments.
- Introduce strict validation and normalization on any data that must influence command-line arguments, rejecting unexpected characters and patterns.
- Run applications and child processes with least privilege to limit the impact of any command execution.
- Separate responsibilities so that code performing system-level operations has narrowly defined, audited entry points and minimized exposure to untrusted inputs.
How teams detect issues like this
Detection typically relies on identifying insecure command construction and shell usage patterns in code.
Useful approaches include:
- Static analysis rules that flag child_process calls using
shell: true, especially when arguments derive from request data, configuration files, or environment variables. - Code review practices that scrutinize any string concatenation or interpolation used to build commands, looking for cmd.exe metacharacters and
%in user-influenced data flows. - Policy enforcement in CI pipelines that disallow or require justification for shell-based subprocess calls and encourage parameterized, non-shell process spawning.
- Optional use of automated security scanners that understand OS command injection patterns and can highlight risky escaping logic in cross-platform runtimes like Deno.

