Commit ff1e192
committed
security(workspace): switch LaunchPlatformFileManager to constant FileName + QuoteArg'd Arguments
Real fix for CodeQL #46 (cs/command-line-injection), not just the
defense-in-depth + dismiss path. The previous shape
psi.FileName = resolved;
psi.UseShellExecute = true;
put the tainted path on the FileName property which CodeQL's
csharp-CommandLineInjection.qll treats as the command sink. Three
sanitiser remediation attempts (StartsWith path-traversal guard,
inline char-class loop, anchored Regex.IsMatch) all failed to drop
the finding — none of them is the pattern that qll recognises.
New shape: FileName is a constant string literal per OS
(explorer.exe / open / xdg-open) and the resolved path goes onto
Arguments via QuoteArg("\"" + value.Replace("\"", "\\\"") + "\"").
QuoteArg IS the pattern the analyser recognises as a sanitiser
barrier on the Arguments sink, so the taint flow closes at the
guard and the finding drops on the next scan.
Defense-in-depth still in place:
1. SanitiseWorkspaceId at the boundary strips chars outside
[A-Za-z0-9_-]
2. Path.GetFullPath + StartsWith(userRoot, Ordinal) traversal
guard
3. SafeResolvedPathPattern.IsMatch allow-list at the sink
4. (new) QuoteArg wrap on Arguments
5. UseShellExecute=false: spawning the document-opener directly,
no shell tokenisation in the loop
A hostile workspaceId now fails *four* successive checks before it
could influence the spawned process's command line; even if all
four guards were bypassed, Arguments would only carry the quoted
path to a fixed document-opener executable, not run as a shell
command.
Functional behaviour is identical: opening a Bowire workspace
folder still uses Explorer on Windows, Finder on macOS, and the
xdg-utils-installed default file manager on Linux.1 parent 1d6c1b0 commit ff1e192
1 file changed
Lines changed: 49 additions & 8 deletions
Lines changed: 49 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
257 | 282 | | |
258 | 283 | | |
259 | | - | |
260 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
261 | 287 | | |
262 | 288 | | |
263 | 289 | | |
264 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
265 | 306 | | |
266 | 307 | | |
267 | 308 | | |
| |||
0 commit comments