launch-editor: escapeCmdArgs() omits % escaping on Windows
Affected releases · vite
- 8.x8.0.0 – 8.3.2Fixed in 8.3.3
- 7.x7.0.0 – 7.3.6Fixed in 7.3.7
- 6.x6.0.0 – 6.4.3Fixed in 6.4.4
- 5.x and older0.1.0 – 5.4.21No fix, no longer updated
On 8.x, the newest line:
npm install vite@8.3.3Affected
8.0.0 – 8.1.5
23 releases
Fixed
8.1.6
1 release
Affected
8.2.0 – 8.2.2
3 releases
Fixed
8.2.4
1 release
Affected
8.3.0 – 8.3.2
3 releases
Fixed
8.3.3 – 8.3.4
2 releases, latest
Affected
7.0.0 – 7.3.6
35 releases
Fixed
7.3.7
1 release
Affected
6.0.0 – 6.4.3
43 releases
Fixed
6.4.4
1 release
Affected
5.0.0 – 5.4.21
67 releases
Affected
4.0.0 – 4.5.14
53 releases
Affected
3.0.0 – 3.2.11
30 releases
Affected
2.0.0 – 2.9.18
97 releases
Affected
0.1.0 – 0.20.10
78 releases
Affected releases · vite-plus
- 1.x1.0.0Fixed in 1.1.0
- 0.3.x0.3.0 – 0.3.3No fix on this line yet
- 0.2.x0.2.0 – 0.2.9No fix on this line yet
- 0.1.x0.1.0 – 0.1.24No fix on this line yet
- 0.0.x0.0.1No fix on this line yet
On 1.x, the newest line:
npm install vite-plus@1.1.0Affected
1.0.0
1 release
Fixed
1.1.0 – 1.3.0
3 releases, latest
Affected
0.0.1 – 0.3.3
40 releases
Is your project affected?
Paste your package.json, or type the range you declare for vite. It is read in your browser and sent nowhere.
Is your project affected?
Paste your package.json, or type the range you declare for vite-plus. It is read in your browser and sent nowhere.
What happens
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.exeto%ENV%) and calllaunchEditorwithsomething%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 calllaunchEditorwithsomething %CMDCMDLINE:~-38%calc.exe.If the attacker can create a filename containing the
%CD%and the subcommand (e.g.&calc.exe), they can calllaunchEditorwith./%CD%