Skip to content

Fix SignCheck MSI/MSP/CAB/MSU signature verification on .NET Core - #16658

Merged
ViktorHofer merged 3 commits into
mainfrom
fix-signcheck-msi-cab-verification
Apr 1, 2026
Merged

ViktorHofer merged 3 commits into
mainfrom
fix-signcheck-msi-cab-verification

Conversation

@ViktorHofer

@ViktorHofer ViktorHofer commented Apr 1, 2026 •

Copy link
Copy Markdown
Member

Summary

When SignCheck was ported to .NET Core, WinVerifyTrust was replaced with a PEReader-based AuthentiCodeSecurityInfoProvider for extracting Authenticode signatures. This works for PE files (EXE/DLL) but fails for non-PE file types that are also Authenticode-signed:

  • MSI/MSP files are OLE Compound Documents - PEReader fails with "Invalid number of sections declared in PE header"
  • CAB/MSU files use the cabinet format - same PEReader failure

Fix

Add format-specific ISecurityInfoProvider implementations:

  • OleStorageSecurityInfoProvider - reads the \x05DigitalSignature stream from OLE structured storage (MSI/MSP)
  • CabSecurityInfoProvider - reads the PKCS#7 signature from the cabinet header's per-cabinet reserved area (CAB/MSU); uses a plain catch (Exception) for resilience against corrupt or non-CAB files

Wire them into the respective verifiers (MsiVerifier, MspVerifier, CabVerifier, MsuVerifier).

Platform notes

  • OleStorageSecurityInfoProvider is Windows-only (uses Ole32.StgOpenStorage COM interop), matching existing MSI verification code
  • CabSecurityInfoProvider is cross-platform (pure managed binary parsing)

To double check:

The AuthentiCodeSecurityInfoProvider uses PEReader to extract signature
data, which only works for PE files (EXE/DLL). MSI and MSP files are
OLE Compound Documents that store their Authenticode signature in a
'\x05DigitalSignature' stream.

Add OleStorageSecurityInfoProvider that reads the digital signature from
OLE structured storage, and wire it into MsiVerifier and MspVerifier.

This fixes 'Invalid number of sections declared in PE header' errors
when SignCheck validates signed MSI/MSP files.

Co-authored-by: Copilot <[email protected]>
@ViktorHofer

Copy link
Copy Markdown
Member Author

Copilot verified the fix against checked-in test msi files.

Same issue as MSI/MSP: the default AuthentiCodeSecurityInfoProvider
uses PEReader, which fails for non-PE file formats.

CAB files store their Authenticode signature at an offset specified in
the per-cabinet reserved area of the cabinet header. MSU files are
CAB-format files and use the same mechanism.

Add CabSecurityInfoProvider that reads the PKCS#7 signature from the
cabinet header's reserved area, and wire it into CabVerifier and
MsuVerifier.

Co-authored-by: Copilot <[email protected]>
@ViktorHofer
ViktorHofer force-pushed the fix-signcheck-msi-cab-verification branch from dab9686 to 2528f3f Compare April 1, 2026 12:36
@ViktorHofer
ViktorHofer enabled auto-merge (squash) April 1, 2026 13:10
akoeplinger
akoeplinger previously approved these changes Apr 1, 2026
auto-merge was automatically disabled April 1, 2026 13:22

Head branch was pushed to by a user without write access

@ViktorHofer
ViktorHofer enabled auto-merge (squash) April 1, 2026 13:25
@ViktorHofer
ViktorHofer merged commit 64e83a8 into main Apr 1, 2026
8 of 9 checks passed
@ViktorHofer
ViktorHofer deleted the fix-signcheck-msi-cab-verification branch April 1, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants