Skip to content

FileSignatureInfo.GetFromFileStream fails for .ps1 files when ran from Windows Service under gMSA account #24877

@ysiivan

Description

@ysiivan

Prerequisites

Steps to reproduce

Execute FileSignatureInfo.GetFromFileStream on a signed .ps1 file from a Windows service (.NET Framework 4.8, compiled with "Prefer 32-bit") running under a gMSA account. This works for .exe and .dll files. It also works for .ps1 too if the service is running under a "normal" (non gMSA) account.

The NuGet Microsoft.Security.Extensions package's listed website goes to Get-AuthenticodeSignature hence opening a ticket here.
For reference - same is observed when calling Get-AuthenticodeSignature from the same service using PowerShellStandard.Library.
Not a surprise, since:

fileSigInfo = FileSignatureInfo.GetFromFileStream(fileStream);

Expected behavior

FileSignatureInfo.GetFromFileStream and Get-AuthenticodeSignature should correctly work for .ps1 files when called from a Windows service running under a gMSA account

Actual behavior

FileSignatureInfo.GetFromFileStream and Get-AuthenticodeSignature  do not work correctly for .ps1 files when called from a Windows service running under a gMSA account

Error details

Neither FileSignatureInfo.GetFromFileStream nor Get-AuthenticodeSignature throw errors. They just fail to read the signature.

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions