Skip to content

Set-AuthenticodeSignature's HashAlgorithm should default to SHA256 #17559

@potatoqualitee

Description

@potatoqualitee

Prerequisites

Steps to reproduce

  1. Obtain a code signing cert and assign it to $Certificate
  2. Sign a file using that certificate Get-ChildItem dbatools.dll -Recurse | Set-AuthenticodeSignature -Certificate $certificate

That file is signed as SHA1

image

The docs say:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-authenticodesignature?view=powershell-7.2

-HashAlgorithm
Specifies the hashing algorithm that Windows uses to compute the digital signature for the file.

For PowerShell 3.0, the default is SHA256, which is the Windows default hashing algorithm. For PowerShell 2.0, the default is SHA1. Files that are signed with a different hashing algorithm might not be recognized on other systems. Which algorithms are supported depends on the version of the operating system.

Please please please also update the Microsoft.PowerShell.Security module that 5.1 uses, too. The world would appreciate this more secure default.

Expected behavior

Considering SHA1 is deprecated, insecure and not the expected algorithm per the docs, the `HashAlgorithm` should default to SHA256 instead of SHA1

Actual behavior

The default is SHA1

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.4
PSEdition                      Core
GitCommitId                    7.2.4
OS                             Microsoft Windows 10.0.22000
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

    Backport-5.1-ConsiderConsider to backport to Windows PowerShell 5.1 due to impactDocumentation Needed in this repoDocumentation is needed in this repoIssue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions