Skip to content

Fix SignCheck PowerShell script verification on .NET Core#16657

Merged
ViktorHofer merged 1 commit intomainfrom
fix-signcheck-ps1-verification
Apr 1, 2026
Merged

Fix SignCheck PowerShell script verification on .NET Core#16657
ViktorHofer merged 1 commit intomainfrom
fix-signcheck-ps1-verification

Conversation

@ViktorHofer
Copy link
Copy Markdown
Member

Summary

The \AuthentiCodeVerifier\ uses \PEReader\ which only works for PE files (.exe/.dll), not text-based script files. When SignCheck encounters .ps1/.psd1/.psm1/.ps1xml files inside NuGet packages, \PEReader\ throws an \Unknown file format\ error:

\
[File] ...ps1, Signed: False, Virtual path: MSTest.Analyzers.4.2.1-preview.26181.4.nupkg/tools/install.ps1, Full Name: tools/install.ps1 [Error] Unknown file format.
\\

This was introduced in dotnet/dotnet@4e09105 which replaced #if NETFRAMEWORK\ P/Invoke-based AuthentiCode verification with a \PEReader-based approach.

Changes

  • *New \PowerShellScriptVerifier* — Modeled after \JavaScriptVerifier: extends \AuthentiCodeVerifier\ with a custom \ISecurityInfoProvider\ that reads [# SIG # Begin/End signature block](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-authenticodesignature) comment-embedded signatures from PowerShell scripts.
  • Cross-platform support — Moved PowerShell file verifier registration out of the Windows-only block since signature parsing is now managed code.
  • Removed dead .vsix\ header-detection branch — \VsixVerifier\ was deleted in the original commit but the header-detection branch still referenced it.
  • README updates — Updated platform support and removed .vsix\ entries.

The AuthentiCodeVerifier uses PEReader which only works for PE files
(.exe/.dll), not text-based script files. When SignCheck encounters
.ps1/.psd1/.psm1/.ps1xml files, PEReader throws 'Unknown file format'.

Add PowerShellScriptVerifier (modeled after JavaScriptVerifier) with a
custom ISecurityInfoProvider that reads '# SIG # Begin/End signature
block' comment-embedded signatures from PowerShell scripts.

This also makes PowerShell file verification cross-platform (previously
Windows-only) and removes the dead .vsix header-detection branch since
VsixVerifier was deleted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ViktorHofer ViktorHofer force-pushed the fix-signcheck-ps1-verification branch from 73c18d8 to 2fe4293 Compare April 1, 2026 10:48
ViktorHofer added a commit to dotnet/dotnet that referenced this pull request Apr 1, 2026
Port of dotnet/arcade#16657.

The AuthentiCodeVerifier uses PEReader which only works for PE files
(.exe/.dll), not text-based script files. When SignCheck encounters
.ps1/.psd1/.psm1/.ps1xml files, PEReader throws 'Unknown file format'.

Add PowerShellScriptVerifier (modeled after JavaScriptVerifier) with a
custom ISecurityInfoProvider that reads '# SIG # Begin/End signature
block' comment-embedded signatures from PowerShell scripts.

This also makes PowerShell file verification cross-platform (previously
Windows-only) and removes the dead .vsix header-detection branch since
VsixVerifier was deleted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ViktorHofer ViktorHofer merged commit 09ff317 into main Apr 1, 2026
9 checks passed
@ViktorHofer ViktorHofer deleted the fix-signcheck-ps1-verification branch April 1, 2026 12:10
ViktorHofer added a commit to dotnet/dotnet that referenced this pull request Apr 1, 2026
…form PS script signing (#5829)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants