Repository navigation
Fix JavaScript Authenticode verification on MTA threads - #17374
Conversation
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]>
There was a problem hiding this comment.
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
.jsas 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.
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
There was a problem hiding this comment.
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 backport into 11? |
|
yesss /backport to release/11.0 |
|
Started backporting to |
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: