Summary
A command injection issue in Deno's Windows process spawning logic allows batch or shell files to be executed when their extensions use alternate casing (for example .BAT or .Bat), bypassing a case-sensitive block that only checked for lowercase .bat and .cmd.
In environments that rely on Deno's restriction to prevent spawning batch/shell files, an attacker who can influence the path or executable name may be able to execute unintended commands on Windows systems.
Affected context
This vulnerability affects Deno applications running on Windows that:
- Depend on Deno APIs for spawning child processes (for example utilities, CLIs, or server-side scripts), and
- Rely on Deno's built-in protection to block
.bat/.cmdexecution instead of enforcing their own validation or restrictions.
The issue arises specifically when the spawned program is a Windows batch or command file whose extension is not strictly lowercase .bat or .cmd, allowing the intended restriction to be bypassed.
Exploit preconditions
- Attack surface: Windows systems running Deno where untrusted or partially trusted input influences which executable or script is spawned.
- Required access: Ability to provide or control the path/command passed to Deno's process-spawning functionality (e.g., user-supplied arguments, configuration, environment variables).
- Trigger point: Invocation of a Deno API (such as process spawning) that attempts to block
.bat/.cmdbut performs a case-sensitive comparison against only lowercase extensions. - Why exploitation is possible: The extension check is case-sensitive and only matches
.batand.cmd, so Windows batch files using alternate casing (e.g.,script.BAT) are not blocked and can be executed, despite the intended restriction.
Why this happens
The underlying bug is an incomplete validation of command execution targets, mapped to CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Deno's security control to prevent spawning Windows batch/shell files relies on string comparison of file extensions against lowercase .bat and .cmd. Because the comparison is case-sensitive and Windows filesystems and command resolution treat .BAT, .Bat, etc. as equivalent, the protection fails for alternate casings. This mismatch between validation logic and the operating system's case-insensitive behavior creates a gap where attacker-controlled paths with differently cased extensions can bypass the intended command execution restriction.
Potential impact
- Bypass of application-level or platform-level restrictions intended to prevent batch/shell execution.
- Execution of unintended Windows batch or command scripts with the privileges of the Deno process.
- Potential command injection when user-controlled input selects or influences which script is spawned.
- Escalation of impact of other vulnerabilities that rely on Deno's spawning behavior for containment.
General mitigation guidance
Effective mitigation centers on robust, OS-consistent validation of spawned commands and defense-in-depth around process creation:
- Normalize extensions and paths before validation (e.g., convert to a canonical case) so checks align with Windows' case-insensitive behavior.
- Apply allowlist-based execution policies, restricting process spawning to a small set of trusted executables and disallowing script-like targets by default.
- Avoid delegating untrusted or partially trusted input directly into process-spawning APIs; introduce explicit mapping layers instead of passing user-specified commands.
- Run Deno applications with least-privilege accounts and minimize the ability of the process to access or create executable script files in untrusted locations.
- Combine application-level restrictions with OS-level policies (such as AppLocker or similar) to limit script execution across the system.
How teams detect issues like this
Security teams can look for this class of issue using a combination of static, code review, and policy-based approaches:
- Static analysis/code scanning: Flag code that passes user-controlled input or file paths directly into Deno process-spawning APIs without normalization and strict allowlisting.
- Manual code review: Examine security controls around process spawning, checking for case-sensitive extension comparisons on Windows and ensuring logic matches OS semantics.
- Configuration and policy enforcement: Use CI/CD checks or linters to enforce patterns such as canonicalizing file extensions and applying explicit allowlists before spawning processes.
- Runtime monitoring: Observe process creation logs on Windows for unexpected batch or command invocations originating from Deno-managed processes, focusing on unusual casing or paths.

