-
Notifications
You must be signed in to change notification settings - Fork 223
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
PowerShell Extension v2020.3.0 breaks with AppLocker #1221
Comments
The PowerShell extension doesn't yet support constrained language mode. There's a fair amount more work to be done to make it possible. Duplicate of #754. |
Just to be clear, the prior version did work and have worked in our corporate environment. This just broke in the latest release. But understand that this is part in a larger issue as you mentioned. |
Ah, sorry to hear that. That's certainly unexpected that it worked. |
We made exceptions for a very limited number of dev workstations for PowerShell development. On those we are allowing scripts and executables in the extension folder to be run in |
The error comes from a C# invocation like this: PowerShell.Create().AddScript("$PSVersionTable").Invoke() I imagine the dot sourcing is implicit, but in some cases I think we need the execution results to happen in the invoking context. We currently use similar invocations throughout the codebase. @daxian-dbw @PaulHigin is there any way to allow running inline scripts from C# in constrained language mode? Like being able to specify the language mode of the script being invoked? |
I don't believe anything has changed with PowerShell running under AppLocker. It should continue to run in FullLanguage mode for approved directory locations. Is it possible that the AppLocker policy changed? @TravisEz13 is more familiar with AppLocker than I, and may be able to help. |
Well this is for Windows PowerShell, so I suspect it's our usage that's changed. The question is though, is it possible to invoke PowerShell from C# in a trusted way? This is inline PowerShell script, so it doesn't live anywhere on the file system. |
No, we currently don't support signed script blocks, so any inline script is considered untrusted and will run in ConstrainedLanguage mode if AppLocker is enforcing system lock down. |
We're experiencing this same error (with Applocker enabled on our network). Downgrading to 2010.1.0 and disabling extension updates works for now. It does still come up with the warning regarding dot-sourcing/language mode but doesn't cause the Terminal window to crash/close, like 2020.3.0 does. |
Looks like i am also affected by this Problem. Applocker is essential for our Client and Server security concept. So we need to solve this in a secure way. |
I have the same/simular issue: |
Just to get you folks unblocked here are some steps on how to rollback to the last version: We want to do more work here to support Constrained Language Mode which will allow us to support App Locker as well. Apologies for this interruption in your dev process and thanks for your understanding! |
Can those of you who are unblocked by reverting to an old version please run this in the PowerShell Integrated Console and tell me what you see: $Host.Runspace.SessionStateProxy.LanguageMode It will be incredibly helpful. |
The result is “FullLanguage” with mine. |
Yep, same for me, "FullLanguage". |
Follow up, what does the ISE give for the same result? |
My ISE says "ConstrainedLanguage" |
|
Can you give this a go in the PowerShell Preview extension? A fix just went out with support for ConstrainedLanguage mode. |
The extension starts without throwing, but I cannot debug a script. Running the following script (F5) throws an error. This does work in the previous extension. We are using Windows PowerShell 5.1 if that makes any difference.
Throws:
Also, as a side note (might be a different issue). The preview extension asks to replace the PackageManagement module which throws an error too. But probably does not affect this issue.
|
@johlju can you open a separate issue about PackageManagement |
@johlju Now about debugging... Can you share what language mode the PowerShell Integrated Console is? Can you also attach the logs here so we can get a better idea of what's going on? |
I have sent the logs through the provided e-mail so I didn't have to redact anything to might be necessary to help resolve this. |
@johlju if you remove your policy |
We untrusted the path but the result is the same (took a while to verify since I myself are not an local admin so needed help from a colleague). This shows that AppLocker is enabled (path is untrusted) on the path
And this is what outputs when running the test script in the previous comment from within VS Code. The same error as in the issue description.
Also the following error is shown in the AppLocker event log when the path is untrusted:
|
I have I PR in that I think will help... I'll be doing another release next week of PowerShell Preview. For now, if you want to rebind F5 to This is also called "Run Active File in Active Terminal" in the command pallet. |
Doing that runs the script successfully, but I cannot start script in the debugger. The breakpoints are not hit. 😕 |
I'm curious... @johlju can you debug in the ISE? My understanding is that debugging was not allowed in CLM |
I published an update to the PowerShell Preview extension... this should allow F5 to run your code. Can you confirm? Also I've very curious if you can debug in the ISE when under CLM. |
I'm going to close this for now since the extension starts up again... but we can continue the active discussion. |
@TylerLeonhardt I will get back to you regarding the ISE tomorrow, been a busy week. |
We are allowing scripts and executables in the extension folder to be run in
%OSDRIVE%\USERS\%USER%\.VSCODE\EXTENSIONS
. The below error happens with the new version, but this does work with the previous version. As a workaround we have reverted back to the previous version for now.If you need more debug information let us know.
The text was updated successfully, but these errors were encountered: