The vulnerability is a command injection flaw in Deno's node:child_process module on Windows. The root cause lies in the escapeShellArg function located in ext/node/polyfills/internal/child_process.ts.
When a Deno application uses spawn or spawnSync with the shell: true option on Windows, the arguments are processed by escapeShellArg to be safely passed to cmd.exe. The analysis of the security patch (8b9d1aa92bdab59b117ce85777e20d443d20e905) reveals that the original implementation of escapeShellArg used an incomplete regular expression to detect special characters that require quoting.
The vulnerable code was:
if (!/[\s"\\]/.test(arg)) {
return arg;
}
This regex only checked for whitespace, double quotes, and backslashes. It missed other critical cmd.exe metacharacters such as &, |, <, >, ^, !, (, and ).
As a result, if an attacker could control an argument passed to spawn or spawnSync, they could include these metacharacters to inject and execute arbitrary commands. For instance, passing an argument like "foo&calc.exe" would result in calc.exe being executed.
The patch fixes this by expanding the regex to include the missing metacharacters:
if (!/[\s"\\&|<>^!()]/.test(arg)) {
return arg;
}
Therefore, escapeShellArg is the core vulnerable function. During an exploit, a runtime profile or stack trace would show spawn or spawnSync calling this vulnerable escapeShellArg function before executing the injected command.