Skip to content

Remove unneeded Invoke-Expression on unvalidated input - #8826

Merged
Travis Plunk (TravisEz13) merged 3 commits into
PowerShell:masterfrom
TravisEz13:fix_install_powershell
Feb 5, 2019
Merged

Remove unneeded Invoke-Expression on unvalidated input#8826
Travis Plunk (TravisEz13) merged 3 commits into
PowerShell:masterfrom
TravisEz13:fix_install_powershell

Conversation

@TravisEz13

@TravisEz13 Travis Plunk (TravisEz13) commented Feb 4, 2019

Copy link
Copy Markdown
Member

PR Summary

Remove unneeded Invoke-Expression on unvalidated input

PR Context

Reviewing the script for security issue that might prevent signing as requested in #8814

I didn't validate that this could actually be exploited but I ran this.

$tp=join-path "./;Write-Host 'pwnd';" -ChildPath 'child'
Invoke-Expression -command "ls $tp"

With this output

CHANGELOG.md Dockerfile Library bin manpages
CODE_OF_CONDUCT.md Dockerfile.test.yml README.md completions
CONTRIBUTING.md LICENSE.txt azure-pipelines.yml docs
pwnd
/child : The term '/child' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:25
+ ls ./;Write-Host 'pwnd';/child
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (/child:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

While the equivalent new syntax:

&ls $tp

results in:

ls: ./;Write-Host 'pwnd';/child: No such file or directory

PR Checklist

Comment thread tools/install-powershell.ps1 Outdated
@TravisEz13
Travis Plunk (TravisEz13) merged commit ec3bd62 into PowerShell:master Feb 5, 2019
@TravisEz13
Travis Plunk (TravisEz13) deleted the fix_install_powershell branch February 5, 2019 18:49
@iSazonov Ilya (iSazonov) added the CL-Tools Indicates that a PR should be marked as a tools change in the Change Log label Feb 8, 2019
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
…8826)

Remove unneeded `Invoke-Expression` on unvalidated input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Tools Indicates that a PR should be marked as a tools change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants