VDB
Sign up
HIGH8.4

GHSA-wrvw-254r-wpmv

CliInvoke.Specializations has command injection in PowerShell and Cmd shell wrappers

Quick fix

GHSA-wrvw-254r-wpmv — CliInvoke.Specializations: upgrade to the fixed version with the command below.

dotnet add package CliInvoke.Specializations --version 2.8.5

Details

### Impact An OS command injection vulnerability exists in the PowerShell and Cmd shell wrappers provided by the `CliInvoke.Specializations` package (the `PowershellProcessInvoker`/`CmdProcessInvoker` invokers, and the `UsePowerShell`/`UseCmd` middleware in v3 pre-release versions).

The wrappers re-run a caller-supplied target and arguments inside a shell command (`pwsh -Command ...` / `cmd /c ...`). In affected versions the wrapped command was delivered to the operating system as a single `ProcessStartInfo.Arguments` string. The OS command-line parser re-tokenizes that string before the shell parses it, so a double quote (`"`) in the target or arguments breaks OS-level quoting and lets the wrapped shell reassemble a second, unintended command.

An attacker could exploit this to execute arbitrary commands with the privileges of the host process.

### Patches The Specializations Packages now deliver the command via `ProcessStartInfo.ArgumentList` (natively where supported, and polyfilled in older TFMs), so that the operating system passes argv verbatim and only the shell parses the command once.

Upgrade to: - **2.8.5** (2.8.x line) - **2.9.4** (2.9.x line) - **2.10.5** (2.10.x line) - **3.0.0-beta.1** (3.x pre-release line)

### Workarounds No complete workaround is available. Until upgraded:

- Reject or strip `"` from any target path or argument passed to the PowerShell/Cmd wrappers. On 2.2.0 – 2.9.2 and 3.0.0-alpha.1 – alpha.4, also reject shell metacharacters (`;`, `|`, `&`, `$`, backtick, parentheses). - Alternatively, bypass the wrappers for untrusted input and invoke the target process directly so that no second shell parse of the data occurs.

Are you affected?

Enter the version of the package you're using.

Affected packages

NuGet/CliInvoke.Specializations
Introduced in: 2.2.0Fixed in: 2.8.5
Fixdotnet add package CliInvoke.Specializations --version 2.8.5
NuGet/CliInvoke.Specializations
Introduced in: 2.9.0Fixed in: 2.9.4
Fixdotnet add package CliInvoke.Specializations --version 2.9.4
NuGet/CliInvoke.Specializations
Introduced in: 2.10.0Fixed in: 2.10.5
Fixdotnet add package CliInvoke.Specializations --version 2.10.5
NuGet/CliInvoke.Specializations
Introduced in: 3.0.0-alpha.1Fixed in: 3.0.0-beta.1
Fixdotnet add package CliInvoke.Specializations --version 3.0.0-beta.1
NuGet/CliInvoke.Specializations
Introduced in: 3.0.0-alpha.8Fixed in: 3.0.0-beta.1
Fixdotnet add package CliInvoke.Specializations --version 3.0.0-beta.1
NuGet/AlastairLundy.CliInvoke.Specializations
Introduced in: 1.0.0-rc.1Fixed in: 2.0.2
Fixdotnet add package AlastairLundy.CliInvoke.Specializations --version 2.0.2

References