Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple but annoying bug: PowerShell stops working if there is a = in the path of the Script #6087

Closed
schittli opened this issue Feb 1, 2018 · 1 comment
Labels
Resolution-Answered The question is answered.

Comments

@schittli
Copy link

schittli commented Feb 1, 2018

Steps to reproduce

  1. Create the following useles but valid script in a directory containing an equal sign (=), e.g.
    c:\temp\=PSTest\Test.ps1
Enum State {
	Unknown = 1
	New = 2
}
  1. Start the Script. You'll get:
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
…
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException

Expected behavior

It's obvious: No valid character in the path of a PowerShell Script is allowed to affect the Script execution.

Actual behavior

PowerShell stops working with an exception because characters in the path of a PowerShell script can affect the PowerShell runtime.
I guess that a hacker is able to control powershell just by using special characters in the path of a script because PowerShell probably tries to interpret those characters.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.16299.98
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.98
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
@schittli schittli changed the title Simple but annoying bug: PowerShell stops working if there is a = in the path Simple but annoying bug: PowerShell stops working if there is a = in the path of the Script Feb 1, 2018
@markekraus
Copy link
Contributor

This does not reproduce in 6.0.1. I believe starting with 6.0.0 (#5292) the assembly name for PowerShell generated dynamic Classes and Enums changed which resolved this issue. To be clear, in 5.1 the dynamic class assembly names were generated based on the filename. Creating an Enum from a file with an illegal assembly name character is likely the cause of the issue you see.

This repository is for PowerShell Core 6.0.0 and newer. To file bug reports for Windows PowerShell 5.1 please use UserVoice

@SteveL-MSFT SteveL-MSFT added the Resolution-Answered The question is answered. label Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Answered The question is answered.
Projects
None yet
Development

No branches or pull requests

3 participants