Skip to content

Commit 7978973

Browse files
committed
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
1 parent 8b66bdc commit 7978973

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎.github/workflows/test-wheel-windows.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,15 @@ jobs:
426426
- name: Install Visual C++ Redistributable (required by PyTorch on Windows)
427427
if: ${{ inputs.test-mode == 'nightly-pytorch' }}
428428
run: |
429-
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe"
430-
Start-Process -FilePath ".\vc_redist.x64.exe" -ArgumentList "/install", "/quiet", "/norestart" -Wait
431-
Remove-Item "vc_redist.x64.exe"
429+
$redist = Join-Path $env:RUNNER_TEMP "vc_redist.x64.exe"
430+
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile $redist
431+
$signature = Get-AuthenticodeSignature $redist
432+
if ($signature.Status -ne "Valid" -or $signature.SignerCertificate.Subject -notmatch "O=Microsoft Corporation") {
433+
throw "VC++ runtime is not validly signed by Microsoft: $($signature.Status)"
434+
}
435+
$process = Start-Process $redist -ArgumentList "/install", "/quiet", "/norestart" -Wait -PassThru
436+
if ($process.ExitCode -notin 0, 1638, 3010) { throw "VC++ runtime installer failed: $($process.ExitCode)" }
437+
Remove-Item $redist
432438
433439
- name: Install cuda-python wheels + PyTorch
434440
if: ${{ inputs.test-mode == 'nightly-pytorch' }}

0 commit comments

Comments
 (0)