Commit f4e367b
committed
security(workspace): swap Arguments-string for ArgumentList — canonical CodeQL-recognised pattern (#47)
The previous QuoteArg-on-Arguments-string shape (commit ff1e192)
landed alert #47 in the next CodeQL scan: the analyser treats
`ProcessStartInfo.Arguments = …` as a single sink that can carry
shell metacharacters regardless of how the value was sanitised
upstream. `ArgumentList.Add` is the canonical fix per CodeQL's
csharp-CommandLineInjection.qll — each entry goes into argv as
a discrete element, so the OS process loader never tokenises
through any shell parser. No quoting, no escaping, no
concatenation concerns.
// Before:
psi.Arguments = QuoteArg(resolved);
// After:
psi.ArgumentList.Add(resolved);
Functional behaviour identical (Explorer / Finder / xdg-open
receives the resolved path as its argv[1]), but the data flow
CodeQL traces from user input now terminates at a recognised
sanitiser barrier instead of pretending Arguments-string-quoting
is enough.
The QuoteArg helper is removed — no caller left.
Defense-in-depth still in place:
1. SanitiseWorkspaceId allow-lists alnum+_- at the boundary
2. StartsWith(userRoot, Ordinal) path-traversal guard
3. SafeResolvedPathPattern.IsMatch sink-adjacent allow-list
4. UseShellExecute=false + ArgumentList.Add — argv-level handoff
#46's dismiss stays — it referenced the pre-refactor shape. #47
should drop on the next CodeQL scan now that the canonical
pattern is in place.1 parent 66f66cb commit f4e367b
1 file changed
Lines changed: 13 additions & 16 deletions
Lines changed: 13 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
282 | 294 | | |
283 | 295 | | |
284 | 296 | | |
285 | | - | |
286 | 297 | | |
287 | 298 | | |
| 299 | + | |
288 | 300 | | |
289 | 301 | | |
290 | 302 | | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | 303 | | |
307 | 304 | | |
308 | 305 | | |
| |||
0 commit comments