Commit bf1132b
committed
fix(compat): reject quote-bearing args in cmd shims, drop backslash-quote escaping
cmd.exe does not treat backslash as a quote escape: the '"' in an
emitted '\"' toggles the quoted region, exposing any following
metacharacter as command syntax (verified: 'a"&echo x' chained the
second command). No escaping survives both layers:
- '\"' — cmd layer injection, as reviewed.
- '""' doubling — safe at the cmd layer, but ambiguous to the child:
node's argv parser reads '""' as a literal quote while bun's splits
the argument in two (verified), so the sender cannot guarantee
semantics for arbitrary targets.
Arguments containing '"' now throw like '%' and control characters.
Node.js reached the same conclusion more broadly: since the
CVE-2024-27980 hardening it refuses to spawn .cmd/.bat files with any
arguments at all (EINVAL). The retained safe subset (no quotes, no %,
no control chars) covers every current call site; trailing-backslash
doubling for quoted arguments is kept and verified against both node
and bun children.1 parent 47bb347 commit bf1132b
2 files changed
Lines changed: 39 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | 215 | | |
220 | 216 | | |
221 | 217 | | |
| |||
232 | 228 | | |
233 | 229 | | |
234 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
235 | 239 | | |
236 | 240 | | |
237 | 241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
163 | 165 | | |
164 | | - | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
173 | 188 | | |
174 | 189 | | |
175 | | - | |
| 190 | + | |
176 | 191 | | |
177 | 192 | | |
178 | 193 | | |
| |||
182 | 197 | | |
183 | 198 | | |
184 | 199 | | |
185 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
186 | 204 | | |
187 | 205 | | |
188 | | - | |
189 | | - | |
| 206 | + | |
| 207 | + | |
190 | 208 | | |
191 | 209 | | |
192 | 210 | | |
193 | 211 | | |
194 | | - | |
| 212 | + | |
195 | 213 | | |
196 | 214 | | |
197 | 215 | | |
198 | 216 | | |
199 | 217 | | |
200 | | - | |
| 218 | + | |
201 | 219 | | |
202 | 220 | | |
203 | 221 | | |
| |||
0 commit comments