Skip to content

fix(software): report the running Windows Defender platform version CU-17tkuw67fq5 - #268

Merged
aliaska-varieva merged 2 commits into
mainfrom
fix/windows-defender-platform-version
Nov 30, 2026
Merged

aliaska-varieva merged 2 commits into
mainfrom
fix/windows-defender-platform-version

Conversation

@aliaska-varieva

@aliaska-varieva aliaska-varieva commented Nov 16, 2026 •

Copy link
Copy Markdown

Ticket: https://app.clickup.com/t/17tkuw67fq5
Change-Set: fix-windows-defender-platform-version

Problem

Windows devices with an up-to-date Defender platform show CVE-2023-36422 (fixed in 4.18.23100.2009). The Program Files scan (upstream fleetdm#42992) takes the "Windows Defender" version from C:\Program Files\Windows Defender\MsMpEng.exe. That's the in-box copy, and platform updates don't touch it. The running copy is under C:\ProgramData\Microsoft\Windows Defender\Platform\<version>\. The CVE data is correct, but the version we compare against it is the old one.

Fix

  • windows_program_files_scan also scans C:\ProgramData\Microsoft\Windows Defender\Platform\%\MsMpEng.exe.
  • processProgramFilesScan keeps only the newest MsMpEng.exe, compared with SmartVerCmp. Old platform folders are dropped, and the in-box copy stays when no platform folder exists.

This is the same change as upstream fleetdm#58896, cherry-picked. The generated understanding-host-vitals.md isn't in the fork, so its regeneration is left out. Drop this once upstream is synced.

Testing

  • TestWindowsProgramFilesScan: new cases for the newest platform copy winning over the in-box copy and an older platform folder, the in-box copy alone, and the file_version fallback. Both platform-folder cases fail without the change.
  • go test ./server/service/osquery_utils/ passes.
  • Not checked on a real Windows host yet.

Reference

Change set flamingo-stack/fix-windows-defender-platform-version: this pull request is the only one in it so far. Another pull request joins by naming this one in a Depends-On line, or by carrying the same Change-Set line.

  • flamingo-stack/fleetmdm#268 (this pull request): fix(software): report the running Windows Defender platform version CU-17tkuw67fq5 · landed

Linked work

Linked by the Depends-On / Change-Set lines in these descriptions; this block is maintained by the hub.

@github-actions

Copy link
Copy Markdown

🦩 Flamingo Code Review

Not reviewed yet. Reviews start when you ask, so the reviewer reads this pull request when it is ready, not when it is opened.

When it is ready:

  • Review this pull request

Or comment @flamingo-review. Add the flamingo-review-always label to review every push.

Updated 2026-11-16 20:21 UTC · workflow run

…U-17tkuw67fq5

Defender platform updates install the running MsMpEng.exe under
C:\ProgramData\Microsoft\Windows Defender\Platform\<version>\, while
C:\Program Files\Windows Defender\MsMpEng.exe keeps the in-box version.
Scan the platform folder too and keep only the newest MsMpEng.exe, so
Windows Defender no longer matches CVEs the running platform has fixed
(e.g. CVE-2023-36422).

Upstream: fleetdm#58895, fleetdm#58896
@aliaska-varieva
aliaska-varieva force-pushed the fix/windows-defender-platform-version branch from c7cdd69 to ba360c1 Compare November 18, 2026 23:21
@aliaska-varieva
aliaska-varieva marked this pull request as ready for review November 30, 2026 18:05
Comment thread server/service/osquery_utils/queries.go Resolved
Comment thread server/service/osquery_utils/queries.go Resolved
Comment thread server/service/osquery_utils/queries.go Resolved
Comment thread server/service/osquery_utils/queries.go Resolved
@flamingo

flamingo Bot commented Nov 30, 2026

Copy link
Copy Markdown

🦩 Flamingo Code Review

❌ Tests and checks failed on this commit: tests (go test). What each printed is in the Tests and mutation section.

4 findings: 🔴 0 action required · 🟠 0 recommended · 🔵 4 informational

Advisory: findings do not block the merge.

Rules cited: FLEETMDM-001

Files Lines Languages Checks 🔴 Action required 🟠 Recommended 🔵 Informational
3 +107 / -7 Go (1 go test lane) ✅ 2 / 2 passed 0 0 4

🔵 Informational (4)

# Where Finding Flagged by
1 queries.go:1746 Defender platform-version fix edits upstream queries.go without OPENFRAME sentinels (Minor) FLEETMDM-001
2 queries.go:1722 New ProgramData\Platform path added to windows_program_files_scan without OPENFRAME sentinels (Minor) FLEETMDM-001
3 queries.go:31 New nvd import in upstream queries.go lacks OPENFRAME sentinels (Minor) FLEETMDM-001
4 queries.go:1822 keepNewestWindowsDefender/fileScanVersion added to upstream file without sentinels (Minor) FLEETMDM-001

✅ What this change does well

  • queries_test.go adds table cases covering all three branches of the new logic: newest platform copy wins, in-box-only fallback, and file_version fallback when product_version is empty.
  • queries.go factors the duplicated product_version/file_version fallback into a single fileScanVersion helper used by both the append path and the version comparison.
  • server/service/osquery_utils/queries.go fixes the version at its source (which MsMpEng.exe is reported) and keeps the in-box copy when no platform folder exists, so hosts without platform updates still report Defender.
  • server/service/osquery_utils/queries_test.go covers newest-platform selection, the no-platform-folder fallback and the file_version fallback with case-insensitive filenames.

Inline comments: 4 new

1 possible problem checked and ruled out
  • server/service/osquery_utils/queries.go:1838 Tie or missing version makes keepNewestWindowsDefender keep the first (in-box) MsMpEng.exe row: Line 1838 only updates newest on strictly greater; an empty-version or tied platform row leaves the in-box row as newest and drops the platform row, defeating the fix. Real but edge case.

🧪 Tests and mutation

Tests per lane

Language Project Command Status Counts Time
Go (go test) . go vet ./server/service/osquery_utils && go test -cover ./orbit/... ❌ failed 54.1 s
Tests failed in .: what it printed last
		coverage: 0.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/software_update	13.707s	coverage: 88.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/sudo_info	4.557s	coverage: 68.4% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/tablehelpers	5.608s	coverage: 96.7% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/tcc_access	7.201s	coverage: 79.5% of statements
	github.com/fleetdm/fleet/v4/orbit/pkg/table/user_login_settings		coverage: 0.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/yaml_to_json	4.612s	coverage: 91.7% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/token	5.890s	coverage: 88.7% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/update	24.197s	coverage: 57.2% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/update/badgerstore	5.080s	coverage: 88.9% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/update/filestore	5.071s	coverage: 75.0% of statements
	github.com/fleetdm/fleet/v4/orbit/pkg/user		coverage: 0.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/useraction	6.707s	coverage: 29.2% of statements
	github.com/fleetdm/fleet/v4/orbit/pkg/windows/oleconv		coverage: 0.0% of statements
	github.com/fleetdm/fleet/v4/orbit/pkg/windows/windowsupdate		coverage: 0.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/zenity	5.107s	coverage: 50.0% of statements
	github.com/fleetdm/fleet/v4/orbit/tools/build		coverage: 0.0% of statements
FAIL

Checks

Check Kind Language Project Status Time
gofmt format Go (go test) . ✅ passed 0 s
OpenGrep security Go (OpenGrep) . ✅ passed 13.5 s

The test services of flamingo-stack/fleetmdm (server/mdm/nanodep/storage/mysql/docker-compose-test.yml) did not come up: the integration tests may fail for that reason.

The planned Go lane ran go test ./orbit/..., which this change does not touch; its one failure is TestGetFleetdConfig in orbit/pkg/profiles (darwin-only, reads this Mac's configuration profiles) and is unrelated to the diff.

The changed package was run separately: go test -cover ./server/service/osquery_utils/ passes (73.1% coverage), including the three new TestWindowsProgramFilesScan cases.

No mutation tool is configured for Go, so mutation testing was not run.

1 gap (not tested here):

  • Go (go test) .: no mutation testing (no mutation tool for Go is configured: read the coverage of the changed packages instead)
🤖 Prompt for AI agents: fix every finding
Address these code-review findings on pull request #268 of flamingo-stack/fleetmdm, most important first.
For each one, make the minimal change that resolves it and do not refactor unrelated code.
If you can show a finding is wrong, skip it and say why.

1. [Informational] server/service/osquery_utils/queries.go:1746 Defender platform-version fix edits upstream queries.go without OPENFRAME sentinels
   `server/service/osquery_utils/queries.go` is a shared upstream fleetdm/fleet file; this repo already marks every fork edit in it with sentinels (e.g. lines 840/865 `>>> OPENFRAME(waf-inventory-shape)`, 3142/3148 `OPENFRAME(enroll-machine-identity)`). I grepped the whole file for `OPENFRAME` and there is none around `windows_program_files_scan` / `processProgramFilesScan`, so this region is upstream code. The diff adds the `keepNewestWindowsDefender(...)` call at line 1746, the two new helper functions, and the new `C:\ProgramData\Microsoft\Windows Defender\Platform\%\MsMpEng.exe` LIKE clause in the raw SQL (line 1722) with no sentinel comments anywhere.
2. [Informational] server/service/osquery_utils/queries.go:1722 New ProgramData\Platform path added to windows_program_files_scan without OPENFRAME sentinels
   server/service/osquery_utils/queries.go is a shared upstream fleetdm/fleet file, and the fork already marks its edits here with sentinel comments (e.g. lines 840-865 `>>> OPENFRAME(waf-inventory-shape)` and line 3475 `OPENFRAME(software-windows-details)`). The added SQL predicate scanning `C:\ProgramData\Microsoft\Windows Defender\Platform\%\MsMpEng.exe` and the `keepNewestWindowsDefender` call in processProgramFilesScan carry no `// >>> OPENFRAME(<slug>) ... // <<< OPENFRAME(<slug>)` wrapper, which FLEETMDM-001 requires for every change to an upstream-originating file so a future upstream sync can locate and re-apply it.
3. [Informational] server/service/osquery_utils/queries.go:31 New nvd import in upstream queries.go lacks OPENFRAME sentinels
   The import of `server/vulnerabilities/nvd/tools/cvefeed/nvd` is a fork edit to the shared upstream file server/service/osquery_utils/queries.go (which elsewhere uses sentinels, e.g. line 840). FLEETMDM-001 requires the added import block be enclosed in `// >>> OPENFRAME(<slug>)` / `// <<< OPENFRAME(<slug>)` so an upstream sync preserves it; otherwise the import is lost while the code that uses SmartVerCmp remains, breaking the build.
4. [Informational] server/service/osquery_utils/queries.go:1822 keepNewestWindowsDefender/fileScanVersion added to upstream file without sentinels
   These two new fork-only helper functions are added inside the shared upstream file server/service/osquery_utils/queries.go rather than under a fork-only path, so the FLEETMDM-001 exemption for net-new fork code does not apply; they must be wrapped in `// >>> OPENFRAME(<slug>): <why> — openframe/docs/<doc>.md` / `// <<< OPENFRAME(<slug>)`. The file already follows this convention (lines 840-865, 3149-3151).

Next: commit a suggestion, or hand a comment's prompt to your coding agent. React 👍 on a finding that helped and 👎 on one that is wrong: the reviewer learns from both.

Review again. New commits are not reviewed until you ask:

  • Review the new commits: only what was pushed since this review
  • Review the whole diff again: everything, including what was already reviewed
  • Run a security review: a review that looks for security problems only, with its own check

Or comment @flamingo-review (new commits) or @flamingo-review full (everything). Add the flamingo-review-always label to review every push.

Updated 2026-11-30 18:16 UTC · reviewed from Aliaska Varieva's machine

@aliaska-varieva
aliaska-varieva requested review from a team November 30, 2026 18:16
@aliaska-varieva
aliaska-varieva merged commit cb4e109 into main Nov 30, 2026
42 of 43 checks passed
@aliaska-varieva
aliaska-varieva deleted the fix/windows-defender-platform-version branch November 30, 2026 18:28
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.

3 participants