The vulnerability is a command injection in Deno's implementation of the node:child_process module, specifically affecting functions like spawn and spawnSync when used with the shell: true option. The root cause is the improper handling of arguments passed to these functions.
The analysis of the patch commit 9132ad958c83a0d0b199de12b69b877f63edab4c reveals two key functions involved in the vulnerability:
-
normalizeSpawnArguments: This internal function constructs the final command string to be executed by the shell. The vulnerable version of this function directly concatenated arguments into the command string without escaping them. This allowed malicious input containing shell metacharacters (e.g., newlines) to be interpreted as separate commands by the shell.
-
transformDenoShellCommand: This function was intended to act as a security check by scanning for shell metacharacters. However, its detection regex was incomplete and failed to account for newline and carriage return characters, which are valid command separators in shell environments. This allowed the injection to succeed.
An attacker exploiting this vulnerability would cause these functions to process a malicious argument, leading to the execution of arbitrary commands on the underlying system. Therefore, normalizeSpawnArguments and transformDenoShellCommand are the primary functions that would appear in a runtime profile during exploitation.