Skip to content

"Git Bash" Windows Terminal fragment profile uses unquoted commandline path #5100

@DHowett

Description

@DHowett

When the installer generates the git-bash Windows Terminal profile, it does so by constructing a commandline based on the install location:

https://github.com/git-for-windows/build-extra/blob/0cacd22fe04363b5350ea70fb3c884778dfde48e/installer/install.iss#L2854-L2865

For most installs, this will result in a commandline of C:/Program Files/git/bin/bash.exe -i -l

Unquoted commandline strings containing spaces are parsed incrementally, and may lead to unintended execution.

Quotes would tell Windows which part of the text represented the executable's path and which parts were command line arguments, if any. In the absence of quotes, Windows assumes that space characters are delimiters.
It rather involved being on the other side of this airtight hatchway: Unquoted service paths (2014)

first, it parses out C:\Program and looks for C:\Program.com, C:\Program.exe, C:\Program.Bat, etc. When it finds none of those, it assumes that the first space is not in fact a delimiter, treats the characters up to the next space character as part of the file path
ibid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions