Skip to content

Scan Windows bundles with MpCmdRun when the Defender cmdlets are down - #8358

Merged
danielhanchen merged 7 commits into
mainfrom
defender-mpcmdrun-fallback
Aug 11, 2026
Merged

danielhanchen merged 7 commits into
mainfrom
defender-mpcmdrun-fallback

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

The problem

The Windows bundle scan has been silently skipped on every desktop release since 2026-08-06. All three most recent runs logged:

Defender is unavailable on this runner (Get-MpComputerStatus: Provider load failure ;
Get-MpPreference: Operation failed with the following error: 0x800106ba); skipping the
bundle scan. This is a missing scanner, not a clean verdict - these bundles were not scanned.
  • v0.1.527-beta, run 31326667022 (2026-08-09)
  • v0.1.60-beta, run 31387284893 (2026-08-10)
  • v0.1.61-beta, run 31396795138 (2026-08-10)

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!ml false positive.

Why a scan is still possible

The cmdlets and MpCmdRun.exe fail independently. Get-MpComputerStatus and Get-MpPreference need the Defender WMI provider and the service RPC endpoint, which is what Provider load failure and 0x800106ba report. MpCmdRun.exe talks 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 by MpCmdRun, not by the cmdlets.

The change

Dead cmdlets now cost only what they actually provide, and never the scan:

  • $cmdletsDown replaces the early exit 0. The run continues into the MpCmdRun path.
  • The $status / $pref configuration checks are guarded by if (-not $cmdletsDown), since they cannot be read at all in that state.
  • The EICAR positive control decides whether a scanner exists. If it fires, the scan below is real and a detection fails the job exactly as before. If it does not fire, MpCmdRun cannot scan either, and the run skips with the same warning as today. So behaviour is never worse than the status quo.
  • Losing the Defender cloud degrades rather than fails when the cmdlets are down: signature detections still fire, only cloud-delivered !ml verdicts go unseen. Failing there would block every release while the runner image is broken.
  • The exclusion read-back is skipped when the cmdlets are down. It is unreadable then, and unnecessary: exclusions 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.

Tests

New test_dead_defender_cmdlets_do_not_skip_the_bundle_scan asserts 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 against main and passes with this change, so it is not vacuous.

Test plan

  • pytest tests/security tests/python/test_virustotal_scan.py passes (335 passed)
  • PowerShell parses cleanly via [System.Management.Automation.Language.Parser]::ParseFile
  • New test fails on main, passes here
  • Next desktop release logs either a real scan or the positive-control skip, not the cmdlet skip

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread .github/workflows/release-desktop.yml Outdated
# 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 4afbad8498

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 30be1cb929

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@danielhanchen
danielhanchen merged commit e8d0d39 into main Aug 11, 2026
19 of 29 checks passed
@danielhanchen
danielhanchen deleted the defender-mpcmdrun-fallback branch August 11, 2026 03:47
iodeh pushed a commit to iodeh/unsloth-llama.cpp that referenced this pull request Sep 14, 2026
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.
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.

1 participant