From 6701c821b925af7153f4f9261da62b81549a35d2 Mon Sep 17 00:00:00 2001 From: Ralf Juengling Date: Tue, 10 Nov 2026 15:00:04 -0800 Subject: [PATCH 1/2] CI: verify the Authenticode signature of vc_redist.x64.exe The nightly PyTorch rows in test-wheel-windows.yml downloaded and silently ran vc_redist.x64.exe without checking its signature or the installer's exit code. Require a valid Microsoft Authenticode signature before running it, fail on installer errors (allowing 1638 and 3010), and download into RUNNER_TEMP. This matches the existing vc_redist.arm64.exe check. Refs #3195 --- .github/workflows/test-wheel-windows.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-wheel-windows.yml b/.github/workflows/test-wheel-windows.yml index f564667f771..071cf099ea3 100644 --- a/.github/workflows/test-wheel-windows.yml +++ b/.github/workflows/test-wheel-windows.yml @@ -413,9 +413,15 @@ jobs: - name: Install Visual C++ Redistributable (required by PyTorch on Windows) if: ${{ inputs.test-mode == 'nightly-pytorch' }} run: | - Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe" - Start-Process -FilePath ".\vc_redist.x64.exe" -ArgumentList "/install", "/quiet", "/norestart" -Wait - Remove-Item "vc_redist.x64.exe" + $redist = Join-Path $env:RUNNER_TEMP "vc_redist.x64.exe" + Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile $redist + $signature = Get-AuthenticodeSignature $redist + if ($signature.Status -ne "Valid" -or $signature.SignerCertificate.Subject -notmatch "O=Microsoft Corporation") { + throw "VC++ runtime is not validly signed by Microsoft: $($signature.Status)" + } + $process = Start-Process $redist -ArgumentList "/install", "/quiet", "/norestart" -Wait -PassThru + if ($process.ExitCode -notin 0, 1638, 3010) { throw "VC++ runtime installer failed: $($process.ExitCode)" } + Remove-Item $redist - name: Install cuda-python wheels + PyTorch if: ${{ inputs.test-mode == 'nightly-pytorch' }} From 408221194df0034f716e54e449219e7150b5e38c Mon Sep 17 00:00:00 2001 From: Ralf Juengling Date: Tue, 10 Nov 2026 15:13:05 -0800 Subject: [PATCH 2/2] CI: match the vc_redist signer organization exactly The substring check on SignerCertificate.Subject also accepted an organization such as "Microsoft Corporation Services Ltd" or a CN that embeds "O=Microsoft Corporation". Compare the parsed organization attribute (OID 2.5.4.10) instead, and check the signature status first so an unsigned file gets a clear error. Refs #3195 --- .github/workflows/test-wheel-windows.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-wheel-windows.yml b/.github/workflows/test-wheel-windows.yml index 071cf099ea3..1f90a445b13 100644 --- a/.github/workflows/test-wheel-windows.yml +++ b/.github/workflows/test-wheel-windows.yml @@ -416,8 +416,14 @@ jobs: $redist = Join-Path $env:RUNNER_TEMP "vc_redist.x64.exe" Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile $redist $signature = Get-AuthenticodeSignature $redist - if ($signature.Status -ne "Valid" -or $signature.SignerCertificate.Subject -notmatch "O=Microsoft Corporation") { - throw "VC++ runtime is not validly signed by Microsoft: $($signature.Status)" + if ($signature.Status -ne "Valid") { throw "VC++ runtime signature is not valid: $($signature.Status)" } + # Compare the parsed organization (OID 2.5.4.10); a substring match on Subject also accepts + # e.g. "O=Microsoft Corporation Services Ltd" or a CN containing "O=Microsoft Corporation". + $org = @($signature.SignerCertificate.SubjectName.EnumerateRelativeDistinguishedNames() | + Where-Object { $_.GetSingleElementType().Value -eq "2.5.4.10" } | + ForEach-Object { $_.GetSingleElementValue() }) + if ($org.Count -ne 1 -or $org[0] -cne "Microsoft Corporation") { + throw "VC++ runtime is not signed by Microsoft Corporation: O=$($org -join '|')" } $process = Start-Process $redist -ArgumentList "/install", "/quiet", "/norestart" -Wait -PassThru if ($process.ExitCode -notin 0, 1638, 3010) { throw "VC++ runtime installer failed: $($process.ExitCode)" }