The security vulnerability is a command injection flaw within the launch-editor package, specifically affecting its operation on the Windows platform. The root cause lies in the launchEditor function located in packages/launch-editor/index.js. This function failed to adequately sanitize the file argument before using it to construct a command that would be executed by the Windows command shell (cmd.exe).
The initial implementation attempted to mitigate this by using a regular expression to validate the file name. However, this approach was flawed and could be bypassed. An attacker could provide a malicious file path containing shell metacharacters (e.g., &, |, ;). When the launchEditor function concatenated this path into the command string, cmd.exe would interpret these characters as command separators, leading to the execution of arbitrary commands supplied by the attacker.
The patch rectifies this vulnerability by replacing the inadequate regex validation with a robust escaping mechanism. It introduces helper functions (escapeCmdArgs, doubleQuoteIfNeeded) that properly sanitize and quote the arguments, neutralizing any special characters before they are passed to the shell via childProcess.exec. This ensures that even if a file path contains metacharacters, they are treated as literal parts of the path and not as executable commands.