Repository navigation
Fix SignCheck MSI/MSP/CAB/MSU signature verification on .NET Core - #16658
Merged
Merged
Conversation
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]>
Member
Author
|
Copilot verified the fix against checked-in test msi files. |
ViktorHofer
force-pushed
the
fix-signcheck-msi-cab-verification
branch
from
April 1, 2026 12:34
088fd46 to
dab9686
Compare
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
force-pushed
the
fix-signcheck-msi-cab-verification
branch
from
April 1, 2026 12:36
dab9686 to
2528f3f
Compare
ViktorHofer
enabled auto-merge (squash)
April 1, 2026 13:10
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
akoeplinger
approved these changes
Apr 1, 2026
ViktorHofer
enabled auto-merge (squash)
April 1, 2026 13:25
mmitche
reviewed
Apr 1, 2026
mmitche
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When SignCheck was ported to .NET Core,
WinVerifyTrustwas replaced with aPEReader-basedAuthentiCodeSecurityInfoProviderfor extracting Authenticode signatures. This works for PE files (EXE/DLL) but fails for non-PE file types that are also Authenticode-signed:PEReaderfails with "Invalid number of sections declared in PE header"PEReaderfailureFix
Add format-specific
ISecurityInfoProviderimplementations:OleStorageSecurityInfoProvider- reads the\x05DigitalSignaturestream 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 plaincatch (Exception)for resilience against corrupt or non-CAB filesWire them into the respective verifiers (
MsiVerifier,MspVerifier,CabVerifier,MsuVerifier).Platform notes
OleStorageSecurityInfoProvideris Windows-only (usesOle32.StgOpenStorageCOM interop), matching existing MSI verification codeCabSecurityInfoProvideris cross-platform (pure managed binary parsing)To double check: