Commit 029e01f
committed
fix(package-manager): prevent command injection via shell metacharacters on Windows
On Windows, package manager commands are executed through cmd.exe with
shell:true because npm, yarn, pnpm etc. are installed as .cmd scripts.
Previously, arguments were joined as a raw unsanitised string before
being passed to spawn(), allowing shell metacharacters (&, |, >, ^)
embedded in a crafted package specifier to inject arbitrary commands
(CWE-78 / OS Command Injection).
Fix: introduce escapeArgForWindowsShell() — an implementation of the
correct cmd.exe quoting algorithm — and apply it to every argument
before string-concatenation in the two affected files:
- packages/angular/cli/src/package-managers/host.ts
- packages/angular_devkit/schematics/tasks/package-manager/executor.ts
The safe array-form spawn path used on Linux/macOS is unchanged.
Related: the analogous repo-init/executor.ts path was already patched
in #32678. This PR closes the remaining two locations.
Refs: CWE-78, GHSA (pending), PR #326781 parent 81e4faa commit 029e01f
File tree
2 files changed
+47
-6
lines changed- packages
- angular_devkit/schematics/tasks/package-manager
- angular/cli/src/package-managers
2 files changed
+47
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | | - | |
146 | | - | |
147 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
| |||
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
168 | | - | |
169 | 171 | | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
176 | | - | |
| 178 | + | |
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
11 | 42 | | |
12 | 43 | | |
13 | 44 | | |
| |||
126 | 157 | | |
127 | 158 | | |
128 | 159 | | |
129 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
130 | 169 | | |
131 | 170 | | |
132 | 171 | | |
| |||
0 commit comments