Skip to content

Comments

Remove unneeded Invoke-Expression on unvalidated input#8826

Merged
TravisEz13 merged 3 commits intoPowerShell:masterfrom
TravisEz13:fix_install_powershell
Feb 5, 2019
Merged

Remove unneeded Invoke-Expression on unvalidated input#8826
TravisEz13 merged 3 commits intoPowerShell:masterfrom
TravisEz13:fix_install_powershell

Conversation

@TravisEz13
Copy link
Member

@TravisEz13 TravisEz13 commented Feb 4, 2019

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

@TravisEz13 TravisEz13 force-pushed the fix_install_powershell branch from 091e351 to 50a76ec Compare February 4, 2019 23:11
@TravisEz13 TravisEz13 merged commit ec3bd62 into PowerShell:master Feb 5, 2019
@TravisEz13 TravisEz13 deleted the fix_install_powershell branch February 5, 2019 18:49
@iSazonov iSazonov added the CL-Tools Indicates that a PR should be marked as a tools change in the Change Log label Feb 8, 2019
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