Repository navigation
Scan Windows bundles with MpCmdRun when the Defender cmdlets are down - #8358
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ac2d12cdc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # exist to stop real-time protection quarantining the copy mid-scan, and | ||
| # real-time protection is not running when the service RPC endpoint is | ||
| # what took the cmdlets out. | ||
| if (-not $cmdletsDown) { |
There was a problem hiding this comment.
Do not assume real-time protection stopped with the cmdlets
When the WMI/provider cmdlets are unavailable but the Defender engine and real-time protection remain active—a state this script already handles when EICAR is blocked on write—Add-MpPreference can fail for the same cmdlet outage, yet this guard skips the read-back and proceeds. A flagged bundle can then be quarantined during Copy-Item, causing the scan to report only a missing/unscanned file and leaving the failure-gated preservation step without the copy needed for false-positive submission. Confirm the exclusions whenever possible, and do not proceed with an unverified exclusion when real-time protection has demonstrated that it is active.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The premise is right and the stale comment claiming real-time protection cannot be live was wrong, so that comment is corrected in bfa1c69. The consequence does not follow, though: this path fails closed. If a copy is quarantined mid-scan, MpCmdRun does not return 0, so the file lands in $unscanned and the job exits 1 with "Refusing to publish bundles Defender could not scan" - no unscanned bundle reaches the release. Making the read-back fatal when it cannot run would instead block every release on these runners, reinstating the outage this PR fixes, and no code change can install exclusions when Add-MpPreference is itself the thing that is down. The residual cost is a missing copy for false-positive submission on an already-failing job. Note the item-1 fix does recover the read-back for the partial-outage case.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bfa1c69030
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # The unavailable branch records the fact and keeps going. | ||
| unavailable = scan.split("$cmdletsDown = [bool]$unavailable", 1) | ||
| assert len(unavailable) == 2, "the cmdlet-unavailable branch no longer sets $cmdletsDown" | ||
| before_control = unavailable[1].split("EICAR positive control", 1)[0] |
There was a problem hiding this comment.
Bound the skip assertion at the executable control
The delimiter matches the earlier explanatory comment containing EICAR positive control in the workflow, rather than the actual control beginning at $eicarPath. Consequently, before_control excludes the configuration and MAPS sections, so an exit 0 inserted there before the real positive control would leave this regression test green while silently skipping the bundle scan. Split on an executable marker such as $eicarPath = instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Measured this rather than argued it, and the premise does not hold. The split point is \$cmdletsDown = [bool]\$unavailable, which already discards the explanatory comment you mean - it sits above that line. The first 'EICAR positive control' match after the split is in the control region, so before_control does cover the configuration and MAPS sections: it contains $fatal = @(), $degraded = @(), MAPSReporting and ValidateMapsConnection on every commit of this branch. Confirmed by mutation as well - inserting exit 0 after $fatal = @() and again after $maps = $false each makes the current test fail. If anything the boundary over-reaches slightly into the control body, which is over-strict rather than fail-open, so there is nothing to loosen. Leaving as is.
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Every PE we ship in the Windows bundles is unsigned. Checking the assets from b10798-mix-659e406 directly: windows-x64-cuda12-legacy 47 PE files, 0 signed windows-x64-cpu 52 PE files, 1 signed windows-x64-cpu (b10715) 52 PE files, 1 signed The single signature is libomp140.x86_64.dll, which Microsoft signed before we vendored it. llama-server.exe, llama-common.dll, llama.dll, the ggml backends and the ROCm runtime DLLs all ship with no certificate table at all, and VirusTotal has never seen any of them, so they carry no prevalence either. Smart App Control evaluates every binary as it loads, not just installers, and blocks unknown unsigned code. When it does, Windows shows a Bad Image dialog naming the dependent DLL it refused and reporting status 0xc0e90002. Users have reported exactly that against llama-common.dll under ~/.unsloth/llama.cpp/build/bin/Release, with the block clearing when Smart App Control is turned off and returning after a reboot. The Studio installer downloads these bundles after its own signed installer has already run, so they sit outside the Authenticode scope of that installer and nothing downstream signs them. A SHA-256 manifest proves the bytes arrived intact but establishes no trust. This signs the whole build tree in each of the four Windows legs, before packaging, using the same Azure Trusted Signing setup the desktop release already uses. Signing is batched: trusted-signing-cli takes any number of trailing paths and authenticates once per invocation, so a bundle costs one round trip rather than one per file. The release then verifies the finished zip rather than the build tree, because packaging copies extra runtimes in afterwards (the OpenMP DLL out of the Visual Studio redist tree, the ROCm DLLs out of the TheRock dist), and only the archive shows what actually ships. An unsigned file fails the job. Forks have no signing credentials and keep building unsigned so that contributors are not blocked. On this repo a missing secret is a hard error instead: a skip that looks like a pass is how the desktop Defender scan went missing for five releases in unslothai/unsloth#8358. Before this can pass on unslothai/llama.cpp, a release-signing environment needs AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID, AZURE_TRUSTED_SIGNING_ACCOUNT_NAME and AZURE_CERTIFICATE_PROFILE_NAME.
The problem
The Windows bundle scan has been silently skipped on every desktop release since 2026-08-06. All three most recent runs logged:
The skip was added as a deliberately narrow escape hatch for a one-off platform incident, on the reasoning that dead cmdlets mean an absent engine and there is then no verdict to interpret. That reasoning no longer holds: the condition has persisted for days, so the hatch has become the permanent path and the gate has effectively been removed. This is the check that exists because 0.1.512-beta shipped a
Trojan:Win32/Wacatac.B!mlfalse positive.Why a scan is still possible
The cmdlets and
MpCmdRun.exefail independently.Get-MpComputerStatusandGet-MpPreferenceneed the Defender WMI provider and the service RPC endpoint, which is whatProvider load failureand0x800106bareport.MpCmdRun.exetalks to the engine directly, and it is present and executing on the affected runners (it appears in the harden-runner process audit). The scan and the EICAR positive control were already driven byMpCmdRun, not by the cmdlets.The change
Dead cmdlets now cost only what they actually provide, and never the scan:
$cmdletsDownreplaces the earlyexit 0. The run continues into theMpCmdRunpath.$status/$prefconfiguration checks are guarded byif (-not $cmdletsDown), since they cannot be read at all in that state.MpCmdRuncannot scan either, and the run skips with the same warning as today. So behaviour is never worse than the status quo.!mlverdicts go unseen. Failing there would block every release while the runner image is broken.Tests
New
test_dead_defender_cmdlets_do_not_skip_the_bundle_scanasserts the unavailable branch does not short-circuit before the positive control, that the cmdlet-dependent probes stay guarded, that the only remaining skip keys off the positive control, and that a detection still fails the job. Verified it fails againstmainand passes with this change, so it is not vacuous.Test plan
pytest tests/security tests/python/test_virustotal_scan.pypasses (335 passed)[System.Management.Automation.Language.Parser]::ParseFilemain, passes here