Skip to content

ArgumentNullException thrown viewing Authenticode signed assembly in NuGet package #1633

Closed

Description

@martincostello

Type (choose one):

  • Bug

NPE version: 6.0.64+c118e46e01

OS version: Windows 11, Version 22H2 (OS Build 22621.2428)

Installed from: Microsoft Store

In case of a BUG:

While trying to publish a new release of Polly today, we encountered a failure when trying to validate the Authenticode signatures of the binaries in our NuGet packages. We do this by compiling AuthenticodeLint from source as the .NET 6 version is not available from NuGet.org (see vcsjones/AuthenticodeLint#34). There was no apparent feedback on what was wrong, just that the tool was failing to verify the signatures. See App-vNext/Polly#1760 for more context.

As part of investigating the issue, attempting to view the binaries inside the NuGet packages that were signed, NuGet Package Explorer fails to load the details for the DLLs, and instead shows this modal:

image

This error seems to correlate with the same exception I uncovered in AuthenticodeLint/AuthenticodeExaminer: vcsjones/AuthenticodeExaminer#19

Unpacking the NuGet package files shows the Authenticode signatures as valid in Windows Explorer, and rebuilding AuthenticodeLint as described in the issue above also then successfully validates the files (successful validation workflow).

I'm not aware of any workarounds to this issue - I expect that a dependency of some kind needs updating and the application recompiled and published for a new version to resolve the underlying code that has an issue with the signatures.

Activity

  1. martincostello commented on Oct 31, 2023

    @martincostello
    ContributorAuthor

    I didn't realise that you depended on AuthenticodeExaminer, so I guess this is just the exact same issue as vcsjones/AuthenticodeExaminer#19:

    <PackageReference Include="AuthenticodeExaminer" Version="0.3.0" />

    I'm going to see if I can force a package update locally that updates the transient dependency and fixes the issue here.

  2. martincostello commented on Oct 31, 2023

    @martincostello
    ContributorAuthor

    Looking at the diff, it's not a dependency update that fixes it, but what looks like a bunch of code changes that have happened since v0.3.0 was released.

  3. bgrainger commented on Feb 6, 2025

    @bgrainger

    I just encountered the same problem. Call stack of NuGet Package Explorer:

     	System.Private.CoreLib.dll!System.ArgumentNullException.Throw(string paramName)	Unknown
     	System.Private.CoreLib.dll!System.Runtime.InteropServices.Marshal.CopyToManaged<byte>(nint source, byte[] destination, int startIndex, int length)	Unknown
     	AuthenticodeExaminer.dll!AuthenticodeExaminer.CmsSignatureBase.ReadBlob(AuthenticodeExaminer.Interop.CRYPTOAPI_BLOB blob)	Unknown
     	AuthenticodeExaminer.dll!AuthenticodeExaminer.CmsSignatureBase.ReadAttributes(AuthenticodeExaminer.Interop.CRYPT_ATTRIBUTES attributes)	Unknown
     	AuthenticodeExaminer.dll!AuthenticodeExaminer.CmsSignature.InitFromHandles(AuthenticodeExaminer.Interop.CryptMsgSafeHandle messageHandle, AuthenticodeExaminer.Interop.LocalBufferSafeHandle signerHandle)	Unknown
     	AuthenticodeExaminer.dll!AuthenticodeExaminer.CmsSignature.CmsSignature(System.Security.Cryptography.AsnEncodedData data, AuthenticodeExaminer.SignatureKind kind)	Unknown
     	AuthenticodeExaminer.dll!AuthenticodeExaminer.CmsSignature.GetNestedSignatures()	Unknown
     	AuthenticodeExaminer.dll!AuthenticodeExaminer.SignatureExtensions.VisitAll(AuthenticodeExaminer.ICmsSignature signature, AuthenticodeExaminer.SignatureKind kind, bool deep)	Unknown
     	AuthenticodeExaminer.dll!AuthenticodeExaminer.SignatureExtensions.VisitAll(System.Collections.Generic.IReadOnlyList<AuthenticodeExaminer.ICmsSignature> signatures, AuthenticodeExaminer.SignatureKind kind, bool deep)	Unknown
     	AuthenticodeExaminer.dll!AuthenticodeExaminer.FileInspector.GetSignatures()	Unknown
     	System.Private.CoreLib.dll!System.Collections.Generic.List<AuthenticodeExaminer.AuthenticodeSignature>.List(System.Collections.Generic.IEnumerable<AuthenticodeExaminer.AuthenticodeSignature> collection)	Unknown
     	System.Linq.dll!System.Linq.Enumerable.ToList<AuthenticodeExaminer.AuthenticodeSignature>(System.Collections.Generic.IEnumerable<AuthenticodeExaminer.AuthenticodeSignature> source)	Unknown
    >	NuGetPackageExplorer.PackageViewModel.dll!PackageExplorerViewModel.ViewContentCommand.ShowFile(PackageExplorerViewModel.PackageFile file) Line 143	C#
     	NuGetPackageExplorer.PackageViewModel.dll!PackageExplorerViewModel.ViewContentCommand.Execute(object parameter) Line 59	C#
     	NuGetPackageExplorer.dll!PackageExplorer.PackageViewer.OnTreeViewItemDoubleClick(object sender, System.Windows.RoutedEventArgs args) Line 319	C#
    

    If @vcsjones isn't publishing any new versions of AuthenticodeExaminer, would NPE update its dependency to a forked version (if one were published to NuGet)?

  4. vcsjones commented on Feb 7, 2025

    @vcsjones

    Sorry for forgetting about this. I will get a fixed version out over the weekend.

  5. clairernovotny commented on Mar 5, 2025

    @clairernovotny
    Member

    @vcsjones any update on this?

  6. vcsjones commented on Mar 14, 2025

    @vcsjones
  7. martincostello commented on Mar 14, 2025

    @martincostello
    ContributorAuthor

    @vcsjones Thanks! Means one step closer towards removing my fork of AuthenticodeLint 😃 vcsjones/AuthenticodeLint#36

  8. vcsjones commented on Mar 14, 2025

    @vcsjones

    @vcsjones Thanks! Means one step closer towards removing my fork of AuthenticodeLint 😃 vcsjones/AuthenticodeLint#36

    New release is pending https://www.nuget.org/packages/AuthenticodeLint/0.13.0. I also started publishing some NativeAOT binaries on the GitHub release, if you prefer to use those instead of a nuget tool.

  9. martincostello commented on Mar 14, 2025

    @martincostello
    ContributorAuthor

    @vcsjones Works great - thanks! 🙇

  10. added a commit that references this issue on Apr 2, 2025
    5d51d5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions