Skip to content

Fix JavaScript Authenticode verification on MTA threads - #17374

Merged
akoeplinger merged 2 commits into
mainfrom
akoeplinger/signcheck-script-sta
Aug 20, 2026
Merged

akoeplinger merged 2 commits into
mainfrom
akoeplinger/signcheck-script-sta

Conversation

@akoeplinger

Copy link
Copy Markdown
Member

PR #16667 added WinVerifyTrust-based content-integrity validation to SignCheck. Unlike the other Authenticode SIPs, the legacy Windows Script Host SIP cannot locate embedded JavaScript signatures when invoked from an MTA thread and returns TRUST_E_NOSIGNATURE.

Run JavaScript WinVerifyTrust verification on an STA thread so signed scripts are recognized correctly. Add signed, tampered, and unsigned JavaScript coverage.

Fixes regression from #16667

To double check:

PR #16667 added WinVerifyTrust-based content-integrity validation to SignCheck. Unlike the other Authenticode SIPs, the legacy Windows Script Host SIP cannot locate embedded JavaScript signatures when invoked from an MTA thread and returns TRUST_E_NOSIGNATURE.

Run JavaScript WinVerifyTrust verification on an STA thread so signed scripts are recognized correctly. Add signed, tampered, and unsigned JavaScript coverage.

Fixes regression from #16667

Co-authored-by: Copilot <[email protected]>
Copilot AI lite review requested due to automatic review settings August 20, 2026 14:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a regression in SignCheck’s Authenticode content-integrity validation for signed JavaScript files by ensuring WinVerifyTrust runs on an STA thread (required by the legacy Windows Script Host SIP). It also adds test coverage and resources for signed, tampered, and unsigned JavaScript scripts.

Changes:

  • Run WinVerifyTrust-based file integrity verification on an STA thread for JavaScript verification (to avoid TRUST_E_NOSIGNATURE on MTA threads).
  • Add signed and unsigned JavaScript test resources and new unit tests that validate signed vs. tampered behavior.
  • Ensure test resources are copied to the test output directory; normalize .js as text via .gitattributes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Microsoft.DotNet.SignCheckLibrary/Verification/JavaScriptVerifier.cs Flags JavaScript verification as requiring STA when calling WinVerifyTrust.
src/Microsoft.DotNet.SignCheckLibrary/Verification/AuthentiCodeVerifier.cs Adds STA-thread execution path for WinVerifyTrust integrity verification and refactors integrity check into a core method.
src/Microsoft.DotNet.SignCheckLibrary.Tests/Resources/UnsignedJavaScript.js Adds an unsigned JavaScript test input.
src/Microsoft.DotNet.SignCheckLibrary.Tests/Resources/SignedJavaScript.js Adds a signed JavaScript test input for integrity verification.
src/Microsoft.DotNet.SignCheckLibrary.Tests/Microsoft.DotNet.SignCheckLibrary.Tests.csproj Copies test resources to output to support runtime file-based tests.
src/Microsoft.DotNet.SignCheckLibrary.Tests/JavaScriptVerifierTests.cs Adds Windows-only signed/tampered integrity tests and an unsigned-script test.
.gitattributes Treats .js files as text for consistent handling in the repo.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@akoeplinger
akoeplinger enabled auto-merge (squash) August 20, 2026 14:58
ViktorHofer
ViktorHofer previously approved these changes Aug 20, 2026
Re-sign the minimal JavaScript fixture with canonical CRLF content and preserve those checkout line endings across build platforms so Linux-built test payloads verify correctly on Windows Helix.

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

Copilot-Session: e7086909-4349-465e-b159-fd6d0e341aae
Copilot AI review requested due to automatic review settings August 20, 2026 17:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/Microsoft.DotNet.SignCheckLibrary.Tests/JavaScriptVerifierTests.cs:43

  • This test doesn’t currently guarantee it’s exercising the regression scenario (WinVerifyTrust invoked from an MTA thread). If the test runner ever executes this method on an STA thread, it could pass even if the STA-thread switch in production code regresses. Consider running the verification from an explicitly MTA thread to make the coverage deterministic.
                SignatureVerificationResult result = VerifyScript(scriptPath, directory);

@akoeplinger
akoeplinger merged commit 4c3a4cf into main Aug 20, 2026
10 of 13 checks passed
@akoeplinger
akoeplinger deleted the akoeplinger/signcheck-script-sta branch August 20, 2026 18:31
@ViktorHofer

Copy link
Copy Markdown
Member

@akoeplinger backport into 11?

@akoeplinger

Copy link
Copy Markdown
Member Author

yesss

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

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.

3 participants