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

v2024.2.0: PowerShell Terminal Fails to Load Due to PSES change to non-Windows-trusted Certificate #4974

Open
6 tasks done
cyrkin opened this issue Apr 12, 2024 · 36 comments
Open
6 tasks done
Assignees
Labels
Area-Engine Issue-Enhancement A feature request (enhancement).

Comments

@cyrkin
Copy link

cyrkin commented Apr 12, 2024

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Hello,
Since the extension updated itself to V 2024.2.0, I can't use the integrated Powershell terminal of my VS Code anymore, it won't load.
My ExecutionPolicy is set by GPO to AllSigned : it has always been like that, it worked like that, and it's not planned to change.
It's like the code in PSReadLine.format.ps1xml is now signed using an unapproved certificate on my side, or it tries desperately to force the ExecutionPolicy to change, which it did not do before.

When I finally kill the terminal, here's the output :

[Error - 8:47:47 AM] Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost: Unable to load PSReadLine. Will fall back to legacy readline implementation. - System.Management.Automation.CmdletInvocationException: Des erreurs se sont produites lors du chargement du fichier de données de format : 
C:\Users\XXX\.vscode\extensions\ms-vscode.powershell-2024.2.0\modules\PSReadLine\2.4.0\PSReadLine.format.ps1xml, , C:\Users\XXX\.vscode\extensions\ms-vscode.powershell-2024.2.0\modules\PSReadLine\2.4.0\PSReadLine.format.ps1xml : le fichier a été ignoré en raison de l’exception de validation suivante : Impossible de charger le fichier C:\Users\XXX\.vscode\extensions\ms-vscode.powershell-2024.2.0\modules\PSReadLine\2.4.0\PSReadLine.format.ps1xml. Une chaîne de certificats a été traitée mais s’est terminée par un certificat racine qui n’est pas approuvé par le fournisseur d’approbation..
 ---> System.Management.Automation.RuntimeException: Des erreurs se sont produites lors du chargement du fichier de données de format : 
C:\Users\XXX\.vscode\extensions\ms-vscode.powershell-2024.2.0\modules\PSReadLine\2.4.0\PSReadLine.format.ps1xml, , C:\Users\XXX\.vscode\extensions\ms-vscode.powershell-2024.2.0\modules\PSReadLine\2.4.0\PSReadLine.format.ps1xml : le fichier a été ignoré en raison de l’exception de validation suivante : Impossible de charger le fichier C:\Users\XXX\.vscode\extensions\ms-vscode.powershell-2024.2.0\modules\PSReadLine\2.4.0\PSReadLine.format.ps1xml. Une chaîne de certificats a été traitée mais s’est terminée par un certificat racine qui n’est pas approuvé par le fournisseur d’approbation..

   à System.Management.Automation.Runspaces.InitialSessionState.ThrowTypeOrFormatErrors(String resourceString, String errorMsg, String errorId)
   à System.Management.Automation.Runspaces.InitialSessionState.UpdateFormats(ExecutionContext context, Boolean update)
   à System.Management.Automation.Runspaces.InitialSessionState.Bind_UpdateFormats(ExecutionContext context, Boolean updateOnly)
   à System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local)
   à System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly)
   à Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors)
   --- Fin de la trace de la pile d'exception interne ---
   à System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   à System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   à System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   à System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   à System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   à System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
   à Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear(PowerShell pwsh, PSInvocationSettings invocationSettings)
   à Microsoft.PowerShell.EditorServices.Services.PowerShell.Console.PSReadLineProxy.LoadAndCreate(ILoggerFactory loggerFactory, String bundledModulePath, PowerShell pwsh)
   à Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.TryLoadPSReadLine(PowerShell pwsh, EngineIntrinsics engineIntrinsics, IReadLine& psrlReadLine) | 
[Error - 8:47:47 AM] Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost: Error occurred calling 'Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force' - System.Management.Automation.CmdletInvocationException: Windows PowerShell a correctement mis à jour votre stratégie d’exécution, mais ce paramétrage est remplacé par une stratégie définie dans un contexte plus spécifique. Votre environnement va donc conserver sa stratégie d’exécution actuelle, AllSigned. Tapez « Get-ExecutionPolicy -List » pour afficher les paramètres de stratégie d’exécution. Pour plus d’informations, voir « Get-Help Set-ExecutionPolicy ». ---> System.Security.SecurityException: Erreur de sécurité.
   à System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
   --- Fin de la trace de la pile d'exception interne ---
   à System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   à System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   à System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   à System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   à System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   à System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
   à Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear(PowerShell pwsh, PSInvocationSettings invocationSettings)
   à Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.SetCorrectExecutionPolicy(PowerShell pwsh, ILogger logger) | Policy='Unrestricted'
[Warn  - 8:52:46 AM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.JsonRpc.RequestCancelled | @Request='OmniSharp.Extensions.JsonRpc.RequestCancelled'
[Error - 10:48:27 AM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 10:48:27 AM] Connection to PowerShell Editor Services (the Extension Terminal) was closed. See below prompt to restart!
[Error - 10:48:27 AM] PowerShell Editor Services Client client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097

I rolled back to version 2024.0.0 and it works again.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.19041.4170
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.4170
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Name             : ConsoleHost
Version          : 5.1.19041.4170
InstanceId       : 86e284ae-6000-426e-aa83-129c82a8b98b
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : fr-FR
CurrentUICulture : fr-FR
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.88.1
e170252f762678dec6ca2cc69aba1570769a5d39
x64

Extension Version

ms-vscode.powershell@2024.2.0

Steps to Reproduce

  1. Open VS Code and wait for the Integrated Powershell Terminal to load and wait for prompt
  2. It never happens and stays like
PowerShell Extension v2024.2.0
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
  1. Kill the terminal to see the output

Visuals

No response

Logs

No response

@cyrkin cyrkin added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Apr 12, 2024
@SebCT
Copy link

SebCT commented Apr 14, 2024

Since 2024.2.0 some components (DLLs and PS1/PSM1/PSD1) of the module are signed with a untrusted certificate/CA called "ameroot" - here is the output with sigcheck from Sysinternals, also affects AppLocker if you use application allowlisting:

Signers: Microsoft Azure Code Sign
Cert Status: The revocation status of the certificate or one of the certificates in the certificate chain is unknown., Error 65536 (0x10000), The revocation status of the certificate or one of the certificates in the certificate chain is either offline or stale.

Valid Usage: 1.3.6.1.4.1.311.91.1.1, Code Signing
Cert Issuer: AME CS CA 01
Serial Number: 36 00 00 01 DF 73 81 97 16 BE 32 FD 0D 00 02 00 00 01 DF
Thumbprint: 1226440E939A24EB202C2A517CE13F8326EFDE60
Algorithm: sha256RSA
Valid from: 03:33 20.01.2024
Valid to: 03:33 19.01.2025
AME CS CA 01
Cert Status: The certificate or certificate chain is based on an untrusted root., The revocation status of the certificate or one of the certificates in the certificate chain is unknown., The revocation status of the certificate or one of the certificates in the certificate chain is either offline or stale.

Valid Usage: KDC Auth, Server Auth, Client Auth, Enrollment Agent, 1.3.6.1.4.1.311.21.6, Document Signing, 1.3.6.1.4.1.311.21.6, OCSP Signing, IPSEC IKE Intermediate, DNS Server, EFS Recovery, EFS, Private Key Archival, Smartcard Logon, 1.3.6.1.4.1.311.20.2.3, Code Signing, 1.3.6.1.4.1.311.91.1.1, 1.3.6.1.4.1.311.91.2.1, 1.3.6.1.4.1.311.91.3.1, 1.3.6.1.4.1.311.91.5.1, 1.3.6.1.4.1.311.91.4.1, 1.3.6.1.4.1.311.91.4.2
Cert Issuer: ameroot
Serial Number: 1F 00 00 00 51 EA 8F F6 9C 73 0C A8 3B 00 00 00 00 00 51
Thumbprint: E3981E455AAFF0C851FF1D3C4EF41EE6A4C087F5
Algorithm: sha256RSA
Valid from: 20:44 21.05.2021
Valid to: 20:54 21.05.2026
ameroot
Cert Status: The certificate or certificate chain is based on an untrusted root.
Valid Usage: All
Cert Issuer: ameroot
Serial Number: 25 DA CB 55 C9 C6 77 81 40 9E 56 94 82 DE 4D FE
Thumbprint: 413E8AAC6049924B178BA636CBAF3963CCB963CD
Algorithm: sha256RSA
Valid from: 00:52 25.05.2016
Valid to: 00:57 25.05.2026

Please MS fix this asap and sign this components with a trusted root CA - workaround is now to revert to V2024.0.0 - even the newer prerelease version has the problem with untrusted CA

@andyleejordan
Copy link
Member

No certificates are trusted on your machine by default. They are signed with updated certificates, you will need to trust those when running AllSigned.

@andyleejordan andyleejordan added the Resolution-Answered Will close automatically. label Apr 15, 2024
@andyleejordan
Copy link
Member

See more info here: #3741 (comment)

Copy link
Contributor

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added Needs: Fix Verification Please verify the fix for us! and removed Needs: Triage Maintainer attention needed! labels Apr 15, 2024
@SebCT
Copy link

SebCT commented Apr 16, 2024

No certificates are trusted on your machine by default. They are signed with updated certificates, you will need to trust those when running AllSigned.

That's not true - there is a list of Trusted root certificates which gets updated by Microsoft and Windows does download them automatically.

That Root certificate ameroot is not an official root certificate - so you have problems with AppLocker.

Issue is not resolved.

@github-actions github-actions bot removed the Needs: Fix Verification Please verify the fix for us! label Apr 16, 2024
@cyrkin
Copy link
Author

cyrkin commented Apr 16, 2024

No certificates are trusted on your machine by default. They are signed with updated certificates, you will need to trust those when running AllSigned.

That's not true - there is a list of Trusted root certificates which gets updated by Microsoft and Windows does download them automatically.

That Root certificate ameroot is not an official root certificate - so you have problems with AppLocker.

Issue is not resolved.

Couldn't agree more.

Copy link
Contributor

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added the Needs: Fix Verification Please verify the fix for us! label Apr 16, 2024
@SebCT
Copy link

SebCT commented Apr 16, 2024

This issue has been labeled as resolved, please verify the provided fix (or other reason).

Not resolved yet

@github-actions github-actions bot removed the Needs: Fix Verification Please verify the fix for us! label Apr 16, 2024
Copy link
Contributor

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added the Needs: Fix Verification Please verify the fix for us! label Apr 16, 2024
@JustinGrote JustinGrote added Area-Engine and removed Needs: Fix Verification Please verify the fix for us! Resolution-Answered Will close automatically. labels Apr 16, 2024
@JustinGrote
Copy link
Collaborator

JustinGrote commented Apr 16, 2024

@andyleejordan I can reproduce this on a clean Win11 box, though it's just silently failing for me with allsigned on even with all the verbosity turned on. The signing cert for PSES changed with the latest release, and it's not one that's trusted by Windows by default. Does this have to do with the build changes you made perhaps?
image

@JustinGrote JustinGrote changed the title Can't load the integrated Powershell Terminal anymore after Extension updated to v2024.2.0 v2024.2.0: PowerShell Terminal Fails to Load Due to PSES change to non-Windows-trusted Certificate Apr 16, 2024
@andyleejordan
Copy link
Member

Ahh well that was embarassing. There was a typo in our pipeline that lead to a silent failure to use the correct certificate, so it defaulted to "Microsoft Azure Code Sign" instead of what it was supposed to be set to, "Microsoft Corporation." And that only shows up as a problem in particular circumstances (as you all have found). Hotfix release is on its way with this resolved. Thanks @JustinGrote for pointing that out. #4977

@andyleejordan andyleejordan self-assigned this Apr 16, 2024
@andyleejordan andyleejordan added the Resolution-Fixed Will close automatically. label Apr 16, 2024
Copy link
Contributor

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added the Needs: Fix Verification Please verify the fix for us! label Apr 16, 2024
@andyleejordan
Copy link
Member

Ok v2024.2.1 is out and fixes this. Sorry!

@github-actions github-actions bot removed the Needs: Fix Verification Please verify the fix for us! label Apr 17, 2024
@cyrkin
Copy link
Author

cyrkin commented Apr 17, 2024

Confirmed fixed with v2024.2.1 and AllSigned on.
Big thanks to everyone who helped resolve the issue.

@cyrkin cyrkin closed this as completed Apr 17, 2024
@JustinGrote
Copy link
Collaborator

@cyrkin thank you for persisting with additional information beyond our initial recommendation! Otherwise we wouldn't have caught it.

@andyleejordan
Copy link
Member

Exactly. There have been recurring issues with AllSigned in the past, so it took some extra digging to figure out what happened here. The specified key was right...the field was mistyped/copied as signing_environment instead of signing_profile and then just silently defaulted to the wrong key. Oh YAML.

@SebCT
Copy link

SebCT commented Apr 17, 2024

Thanks, working nearly perfect except one DLL: AppLocker is still having a problem with the certificate(s) and counter signing of this file here:

.vscode\extensions\ms-vscode.powershell-2024.2.1\modules\powershelleditorservices\bin\common\System.Reactive.dll

The DLL "System.Reactive.dll" is counter signed from yesterday with a "Microsoft 3rd Party Application Component" certificate, but also still countersigned from the past in 2023 with the signer "Reactive Extensions for .NET (.NET Foundation)", which worked perfect in the previous version 2024.0.0 - could you please investigate this and sign it with only one certificate/counter signing? It's important to allowlist this DLL with publisher rule in AppLocker - thanks in advance.

@andyleejordan
Copy link
Member

I noticed that when setting this up actually, and unfortunately the System.Reactive.dll that's being restored from NuGet (version 6.0.0) is not first-party signed by "Microsoft Corporation" but by "Reactive Extensions for .NET (.NET Foundation)" so I have to dual-sign it as "Microsoft 3rd Party Application Component".

@SebCT
Copy link

SebCT commented Apr 18, 2024

I see, but could the security engineers at Microsoft take a look because of AppLocker Application Allowlisting? Because with this new counter signed DLL a publisher rule doesn't work anymore, with the System.Reactive.dll from V2024.0.0 it works perfect - and all the other DLLs from the new V2024.2.1 work perfect with publisher rules, too. Thanks in advance, would be very happy when this issue could be resolved, security is very important for us ☺️

@JustinGrote
Copy link
Collaborator

JustinGrote commented Apr 18, 2024

@andyleejordan is the Reactive DLL a direct dependency or something transitive from csharp-language-server?

@JustinGrote
Copy link
Collaborator

Also, doing a sigcheck looks like the DLL itself hasn't changed in PSES from 2024.2.0 from 2024.3.2, so was this just a new detection that was a previous mis-signing?
image

@JustinGrote
Copy link
Collaborator

As an aside, I found the reference to System.Reactive which @TylerLeonhardt added 4 years ago
C:\Users\JGrote\Projects\PowerShellEditorServices\test\PowerShellEditorServices.Test.E2E\Processes\ServerProcess.cs

While we could unwind that, It is also referenced in OmniSharp.Extensions.JsonRPC as a transitive dependency

      "OmniSharp.Extensions.JsonRpc": {
        "type": "Transitive",
        "resolved": "0.19.9",
        "contentHash": "utFvrx9OYXhCS5rnfWAVeedJCrucuDLAOrKXjohf/NOjG9FFVbcp+hLqj9Ng+AxoADRD+rSJYHfBOeqGl5zW0A==",
        "dependencies": {
          "MediatR": "8.1.0",
          "Microsoft.Extensions.DependencyInjection": "6.0.1",
          "Microsoft.Extensions.Logging": "6.0.0",
          "Nerdbank.Streams": "2.10.69",
          "Newtonsoft.Json": "13.0.3",
          "OmniSharp.Extensions.JsonRpc.Generators": "0.19.9",
          "System.Collections.Immutable": "5.0.0",
          "System.Reactive": "6.0.0",
          "System.Threading.Channels": "6.0.0"
        }

So we wouldn't be able to remove the assembly due to that entrenched dependency.

@SebCT
Copy link

SebCT commented Apr 20, 2024

Also, doing a sigcheck looks like the DLL itself hasn't changed in PSES from 2024.2.0 from 2024.3.2, so was this just a new detection that was a previous mis-signing? image

As i can confirm, the former version 2024.2.0 and the pre-release version 2024.3.2 have the false and untrusted 'ameroot' certificate.

The DLL's of Hotfix Version 2024.2.1 are signed correctly, except that one DLL "System.Reactive.DLL" - but in version 2024.0.0 the DLL works with publisher rule in AppLocker. So the best would be if the System.Reactive.DLL in 2024.2.1 has the same signing as in 2024.0.0 where it works perfectly - ideally it's the same DLL because of no code change inside the DLL?

@JustinGrote
Copy link
Collaborator

JustinGrote commented Apr 22, 2024

The Reactive DLL hasn't changed but it may have been being incorrectly signed as Microsoft First Party when it is in fact Microsoft Community, that was my main query to @andyleejordan that may have been "fixed" but now breaks the ability for the extension to be wholly "pre-signed" on windows systems.

This is more of a legal issue than a technical one, so I have to defer to Andy as to whether that DLL can continue to be signed as it was before since it hasn't changed, but future versions may still have the problem anyways. I imagine this may be a change in policy as supply-chain attacks such as Solarwinds, xz, etc. have probably made Microsoft extremely sensitive about these sorts of things.

@JustinGrote JustinGrote reopened this Apr 22, 2024
@JustinGrote
Copy link
Collaborator

Reopening the issue to address System.Reactive signing status.

@github-actions github-actions bot added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Fix Verification Please verify the fix for us! labels Apr 22, 2024
@andyleejordan
Copy link
Member

You've written it out exactly Justin. When switching to the new signing system, it detected that System.Reactive.dll is Microsoft Community and signed as such, and wouldn't let me sign it as first-party Microsoft Corporation. It was an error that it was previously, and allowed by a system that I no longer have access to. However, all the OmniSharp DLLs etc. are being signed with the same certificate, so I'm not sure why AppLocker is having an issue with this one and not those? We've never published exclusively first-party DLLs because of those dependencies.

Copy link
Contributor

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added Needs: Fix Verification Please verify the fix for us! and removed Needs: Maintainer Attention Maintainer attention needed! labels Apr 22, 2024
@JustinGrote
Copy link
Collaborator

Maybe it is in fact having a problem with those other DLLs, it just is erroring and exiting first on reactive

@JustinGrote JustinGrote added Issue-Enhancement A feature request (enhancement). and removed Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us! Resolution-Fixed Will close automatically. labels Apr 22, 2024
@SebCT
Copy link

SebCT commented Apr 24, 2024

If i use the React DLL from V2024.0.0, where only ONE CERTIFICATE is in the DLL, it works perfect - with the new one from V2024.2.1 with TWO CERTIFICATES it doesn't work. If i sign it with my own code signer certificate, which is allowlisted in applocker, it works also perfect - and it has only ONE CERTIFCATE after i signed it.

@andyleejordan
Copy link
Member

I have triple checked this, and it's correct as-is, and I am being required to dual-sign it. Please ask your admins to update their AppLocker rules to accept System.Reactive.dll to be signed by Reactive Extensions for .NET (.NET Foundation) and Microsoft 3rd Party Application Component. If I had to hazard a guess, they wrote a wildcard rule for System.*, not expecting a third-party DLL to be prefixed by System. such as this one.

@SebCT
Copy link

SebCT commented May 1, 2024

I have triple checked this, and it's correct as-is, and I am being required to dual-sign it. Please ask your admins to update their AppLocker rules to accept System.Reactive.dll to be signed by Reactive Extensions for .NET (.NET Foundation) and Microsoft 3rd Party Application Component. If I had to hazard a guess, they wrote a wildcard rule for System.*, not expecting a third-party DLL to be prefixed by System. such as this one.

Thanks a lot for your checks and your comment - i'm also in the lucky position to be the admin for AppLocker rules, too :-)

The AppLocker rule is correct and works with V2024.0.0, but the issue, as also mentioned here in the past, is the "dual signing" - AppLocker does only read the first certificate, not the second one if you make publisher rules.

This is a main problem and design issue from the AppLocker mechanism, but this mechanism was designed from Microsoft back in 2007. In WDAC this is not a problem anymore, because WDAC reads all signatures from a PE file and does not rely on the trusted root store from Windows. I can confirm, as i'm also doing WDAC, that it works there without a problem.

Here is the allowlisting publisher rule from AppLocker, it works perfect with V2024.0.0 and "single-signing" - the properties "Binaryname" and "Binaryversion" have a wildcard "*", so it does not rely on the version number of filename, only the Publisher and the productname of the PE File/Header:

image

In the mean time i engineered further and did find out 2 things, which have a security impact for an enterprise environment with strict allowlisting:

1.) If you make a publisher rule that every publisher is allowed (wildcard for every publisher), it works -> not secure for an enterprise solution.

2.) If you make a publisher rule that every Microsoft signed binary is allowed (wildcard for Microsoft), it also works -> that enables also LOLBIN scenarios, that are also not secure enough for an enterprise environment.

3.) A file hash rule would work, but these are a problem if the DLL will be changed in a future release of the PowerShell Module, so it has an impact in the production environment and does not work for us.

So it is a design problem from AppLocker, maybe Microsoft can repair this issue for Dual signed PE files, but i'm not sure if Microsoft will do enhancements for AppLocker, as WDAC is the future allowlisting mechanism for them.

One final question because i'm curious: what is the reason for dual-signing a file, which hasn't changed from 2024.0.0 to 2024.2.1? Could it be single-signed with a new, fresh certificate?

Thanks for the help :-)

Update: i did resolve it with a "hack" - hope this will help some other AppLocker admins, too :-)

Now you have to manually create 2 publisher rules with 2 different Publishers:

1st rule:

Publisher: O=REACTIVE EXTENSIONS FOR .NET (.NET FOUNDATION), L=REDMOND, S=WASHINGTON, C=US
Productname: SYSTEM.REACTIVE (NETSTANDARD2.0)

image

2nd rule:

Publisher: O=MICROSOFT CORPORATION, L=REDMOND, S=WASHINGTON, C=US
Productname: SYSTEM.REACTIVE (NETSTANDARD2.0)

image

Of course you can tighten it with filename and version if someone want. These rules can be made manually in the GUI with custom editing of the Publisher string or with the PowerShell AppLocker module/commandlets with a prepared AppLocker XML rules file and i confirm it works now. The GUI (mmc.exe) cannot read the 2nd certificate, it's still a design flaw from AppLocker, but won't be repaired anymore i guess.

@andyleejordan
Copy link
Member

That lines up with what I heard internally about AppLocker (that while it still exists, it's mostly been deprecated in favor of WDAC due to better security boundaries, and hence its lack of support for dual-signing). Essentially, with the migration to an internal build/sign/release system called OneBranch, I am required to sign all the libraries I ship. When those are signed with a third-party certificate already, I must counter-sign it with that Microsoft 3rdparty Application Component certificate. I don't really have a way around this, the pipeline fails otherwise.

@SebCT
Copy link

SebCT commented May 1, 2024

Thanks for the confirmation concerning depreciation of AppLocker, very useful information 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Engine Issue-Enhancement A feature request (enhancement).
Projects
Status: Done
Development

No branches or pull requests

4 participants