Summary
launch-editor did not escape % on Windows when passing an argument to cmd. When an environment variable contained a malicious value, it was possible that that content to be executed.
Impact
Only apps that match all of the following conditions are affected:
- The user uses Windows
- An attacker can place a file with the malicious filename containing
& or %
- Either of
- An attacker can inject an environment variable with a malicious value
- An attacker can add a NTFS alternate data stream to the file placed
Details
Unlike .sh files, .bat / .cmd files on Windows cannot be called directly using child_process.spawn and requires passing them as an argument of cmd.exe. To do so, launch-editor escapes the arguments passed to cmd.exe. But launch-editor did not escape % which is used for environment variables.
Because launch-editor checks if the argument matches an existing filename, the attack requires the attacker to be able to place a file.
- If the attacker can inject an environment variable as well, they can include the subcommand in the env variable (e.g. set
&calc.exe to %ENV%) and call launchEditor with something%ENV%.
- If the attacker can place a NTFS alternate data stream to the file (e.g. a NTFS alternate data stream named
~-38%calc.exe), they can call launchEditor with something %CMDCMDLINE:~-38%calc.exe.
- If the attacker can create a filename containing the
%CD% and the subcommand (e.g. &calc.exe ), they can call launchEditor with ./%CD%
References
Summary
launch-editordid not escape%on Windows when passing an argument tocmd. When an environment variable contained a malicious value, it was possible that that content to be executed.Impact
Only apps that match all of the following conditions are affected:
&or%Details
Unlike
.shfiles,.bat/.cmdfiles on Windows cannot be called directly usingchild_process.spawnand requires passing them as an argument ofcmd.exe. To do so, launch-editor escapes the arguments passed tocmd.exe. Butlaunch-editordid not escape%which is used for environment variables.Because
launch-editorchecks if the argument matches an existing filename, the attack requires the attacker to be able to place a file.&calc.exeto%ENV%) and calllaunchEditorwithsomething%ENV%.~-38%calc.exe), they can calllaunchEditorwithsomething %CMDCMDLINE:~-38%calc.exe.%CD%and the subcommand (e.g.&calc.exe), they can calllaunchEditorwith./%CD%References