Incorrect space sanitization for shell creation #6087

Closed
opened 2026-01-31 00:29:28 +00:00 by claunia · 6 comments
Owner

Originally created by @sqlrob on GitHub (Jan 21, 2020).

Environment

> [Environment]::OSVersion

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18363.0 Microsoft Windows NT 10.0.18363.0

Terminal version 0.8.10091.0

Steps to reproduce

  1. Create a file C:\Program, contents irrelevant; this applies to en-us, other languages will have different names.
  2. Open a powershell tab (other shells may have the issue, didn't check)

Expected behavior

Tab opens with a usable Powershell

Actual behavior

Window opens with the message

[error 0x800700c1 when launching `powershell.exe']
Originally created by @sqlrob on GitHub (Jan 21, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none > [Environment]::OSVersion Platform ServicePack Version VersionString -------- ----------- ------- ------------- Win32NT 10.0.18363.0 Microsoft Windows NT 10.0.18363.0 ``` Terminal version 0.8.10091.0 # Steps to reproduce <!-- A description of how to trigger this bug. --> 1. Create a file `C:\Program`, contents irrelevant; this applies to en-us, other languages will have different names. 2. Open a powershell tab (other shells may have the issue, didn't check) # Expected behavior <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> Tab opens with a usable Powershell # Actual behavior <!-- What's actually happening? --> Window opens with the message ```none [error 0x800700c1 when launching `powershell.exe'] ```
claunia added the Resolution-Duplicate label 2026-01-31 00:29:28 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 21, 2020):

(For the shell,)
This is, and always will be, how CreateProcess with search path expansion works. Sorry.

  • We're relying on the system to do PATH resolution
  • If we implement our own heuristics here, we have to expand PATH and PATHEXT to properly populate the first arg to CreateProcess.
  • Even if we fix this, other applications will fail in the same way.
  • You need to be an admin to make a file there; there are far easier ways to break Terminal

(For the console host,)
This was fixed by #4172, which will be in the next servicing update... which may make this a /dup of #4061

@DHowett-MSFT commented on GitHub (Jan 21, 2020): (For the shell,) This is, and always will be, how CreateProcess with search path expansion works. Sorry. * We're relying on the system to do `PATH` resolution * If we implement our own heuristics here, we have to expand `PATH` _and_ `PATHEXT` to properly populate the first arg to `CreateProcess`. * Even if we fix this, other applications will fail in the same way. * You need to be an admin to make a file there; there are far easier ways to break Terminal (For the console host,) This was fixed by #4172, which will be in the next servicing update... which may make this a /dup of #4061
Author
Owner

@ghost commented on GitHub (Jan 21, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Jan 21, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@sqlrob commented on GitHub (Jan 21, 2020):

Shells are in well defined locations. Why is PATH even being used?

@sqlrob commented on GitHub (Jan 21, 2020): Shells are in well defined locations. Why is PATH even being used?
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 21, 2020):

I'm not sure I agree that shells are in well-defined locations- A user's entitled to reorganize PATH such that their preferred instance of pwsh.exe comes first, or so that they can set version priorities for OpenSSH. Shells are wherever the user wants to put them!

@DHowett-MSFT commented on GitHub (Jan 21, 2020): I'm not sure I agree that shells are in well-defined locations- A user's entitled to reorganize `PATH` such that their preferred instance of `pwsh.exe` comes first, or so that they can set version priorities for OpenSSH. Shells are wherever the user wants to put them!
Author
Owner

@eryksun commented on GitHub (Jan 22, 2020):

* If we implement our own heuristics here, we have to expand `PATH` _and_ `PATHEXT` to properly populate the first arg to `CreateProcess`.

CreateProcessW doesn't use PATHEXT. It calls SearchPathW with an optional ".EXE" extension.

@eryksun commented on GitHub (Jan 22, 2020): > * If we implement our own heuristics here, we have to expand `PATH` _and_ `PATHEXT` to properly populate the first arg to `CreateProcess`. `CreateProcessW` doesn't use `PATHEXT`. It calls `SearchPathW` with an optional ".EXE" extension.
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 22, 2020):

Fair enough.

@DHowett-MSFT commented on GitHub (Jan 22, 2020): Fair enough.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6087