Skip to content

feat(mdm): wipe Windows hosts on Fleet Free over Windows MDM CU-17tkuw6a584 - #287

Merged
andrii-flamingo merged 8 commits into
mainfrom
feat/win-wipe
Nov 30, 2026
Merged

andrii-flamingo merged 8 commits into
mainfrom
feat/win-wipe

Conversation

@andrii-flamingo

@andrii-flamingo andrii-flamingo commented Nov 29, 2026 •

Copy link
Copy Markdown

What

POST /hosts/{id}/wipe wipes Windows hosts on Fleet Free, over Windows MDM, in OpenFrame mode or shared mode only. Before this Fleet answered 402 and OpenFrame's wipeWindowsDevice (openframe-oss-lib#3224) always failed.

  • WipeHost handles Windows next to Android with the same checks: permission to run MDM commands, MDM on for the host (422), no pending lock, unlock or wipe and not locked (422), not wiped already (409). Windows MDM off in the tenant's config: 400. Another tenant's host: 404. macOS, iOS, Linux and ChromeOS still answer 402, as does Windows outside OpenFrame mode. A RemoteWipe custom command still needs Premium and is refused in OpenFrame mode: a wipe goes only through the wipe action and its checks.
  • The command is an <Exec> on ./Device/Vendor/MSFT/RemoteWipe/<type>: doWipeProtected by default, or windows.wipe_type from the body. It is queued by upstream's WipeHostViaWindowsMDM; wiped_host is recorded when it is queued.
  • One device. The command is resolved by hardware uuid, so a wipe is refused, with the enrollment locked, when the uuid is empty, another host of any tenant has it, the tenant has more than one enrollment with it, there is no enrollment, or a wipe is queued or done already.
  • Before a wipe is sent it is checked again on the primary. It is sent only while it is unanswered, recorded on its host in the enrollment's tenant, and the uuid still has that one host and one enrollment. Otherwise it is cancelled and recorded as failed_wipe; it never comes back on its own.
  • completed_wipe: a new activity when the device accepts the wipe (2xx). Upstream records nothing then. It and failed_wipe name the host the wipe was requested for, carry the device's tenant (the CDC consumer drops activities without one) and are recorded even when the device has dropped the request.
  • A wipe that will not happen. An agent re-enrollment keeps an unanswered wipe, also one requested while it runs (upstream cleared it while the command stayed queued). MDM re-enrollment and unenrollment record the lost wipe as failed_wipe. Deleting a host cancels its queued wipe; nothing is recorded, as the host is gone.
  • Nothing is copied from ee/.

Known limits

  • A wipe that has reached the device can't be cancelled. doWipeProtected can leave some devices unable to boot (Microsoft's RemoteWipe CSP).
  • A tenant that knows another's hardware uuid can block or cancel its wipe by enrolling a host with it.
  • A uuid with two MDM enrollments in a tenant can't be wiped until the other device is disconnected from MDM in its Windows settings; Fleet can't turn MDM off for a Windows host. A machine that comes back to the same host with a new hardware id leaves such an enrollment behind for good. Kept on purpose: the older enrollment can be a clone's (same machine id and uuid), and a wipe must not reach the wrong machine. Telling the two apart needs a record of when the old enrollment was last in contact, which is a separate change.
  • A device that repeats its answer records completed_wipe again; the consumer has to be idempotent. "Completed" means the device accepted the command, not that the reset finished.
  • A device that was reset but never answered is recorded as failed_wipe when it enrolls again, and so is one whose answer arrives in the moment its enrollment is removed.
  • A wipe already sent but unanswered when the conditions change is recorded as failed, though the device may be wiped.
  • The host list can show another wipe state than the host page after an MDM unenrollment (upstream's batch read).
  • OpenFrame doesn't handle completed_wipe and failed_wipe yet (CU-17tkuw6a583).
  • Not checked on a real Windows device.

Tests

  • server/service: TestOpenframeWipeWindowsHostQueuesCommand, TestOpenframeWipeWindowsHostRefused, TestOpenframeWipeWindowsHostErrors, TestOpenframeWindowsWipeResultActivity, TestOpenframeWindowsWipesSent, TestOpenframeWindowsWipesLostWithEnrollment, TestOpenframeWindowsWipeCustomCommandRefused, TestOpenframeWipeCompletedActivity.
  • server/datastore/mysql (MYSQL_TEST=1), two tenants, TestOpenframeWindowsWipe*: Lifecycle, NeedsOneDevice, Delivery (moved device, clone, second enrollment, relinked enrollment, transferred and deleted host), LostWithEnrollment, AfterHostDeletion, SurvivesReenroll, QueuedOnce (concurrent requests), ManyHosts, RequestedDuringReenroll, CancelAnswered, SingleTenant, Clones, ResultNamesItsHost, OutsideOpenframeModeAsUpstream.
  • Run once, not in the PR: TestIntegrationsMDM (Wipe, Windows) with the OpenFrame checks on, 39 of 39; 12 hosts with concurrent wipes, deliveries, answers and agent re-enrollments, every wipe sent got its result.
  • Upstream: TestIntegrationsMDM (Wipe, Windows), Enterprise LockUnlockWipe, TestPremiumEndpointsWithoutLicense, MDM and host MySQL tests. TestHosts/DeleteHosts fails the same on main.

ClickUp: CU-17tkuw6a584

Change-Set: windows-wipe

Change set flamingo-stack/windows-wipe: these pull requests are one change, reviewed together.

Linked work

  • …and 3 linked items not shown here

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

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

🦩 Flamingo Code Review

✅ Tests and checks passed on this commit (2 lanes).

✅ No findings on the current head.

Advisory: findings do not block the merge.

Files Lines Languages Checks 🔴 Action required 🟠 Recommended 🔵 Informational
18 +2140 / -16 Go (1 go test lane) ✅ 1 / 1 passed 0 0 0

✅ What this change does well

  • server/service/microsoft_mdm.go wraps the new fork call in OPENFRAME(windows-wipe) sentinels pointing at openframe/docs/windows-wipe.md, keeping upstream-sync hygiene intact.
  • server/service/openframe_windows_wipe.go factors the cancel-and-record loop into openframeFailWindowsWipes, so the new replaced-enrollment path reuses the exact failure handling (log + ctxerr.Handle + continue) of the lost-enrollment path instead of duplicating it.
  • server/service/openframe_windows_wipe_test.go covers each new branch (insert refused, list error, cancel error, answered meanwhile, non-OpenFrame mode, and an enrollment linked to no host) and asserts the wipes are only listed after the insert succeeded.
  • storeWindowsMDMEnrolledDevice in server/service/microsoft_mdm.go ends the wipes of a host's other enrollments only after the insert, so a refused or failed enrollment ends none of them, in shared mode and in a single tenant.
  • TestOpenframeWindowsWipesOfReplacedEnrollments covers a refused insert, a failed list, a failed cancel, an answer that came meanwhile and an enrollment linked to no host.
1 possible problem checked and ruled out
  • server/service/microsoft_mdm.go:1269 GetMDMWindowsEnrollResponse is changed and no test references it: The change only removes an unused hostUUID argument from an internal helper call inside the large upstream GetMDMWindowsEnrollResponse; requiring a new test for this mechanical refactor in a vendored upstream file is noise.

🧪 Tests and mutation

Tests per lane

Language Project Command Status Counts Time
Go (go test) . go vet ./server/datastore/mysql ./server/fleet ./server/mock ./server/service && go test -cover ./orbit/... ✅ passed 151.1 s

Checks

Check Kind Language Project Status Time
OpenGrep security Go (OpenGrep) . ✅ passed 13.8 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.

Go has no local toolchain on this machine; stage 2 ran the planned go vet and go test through golang:1.26.6 in Docker as a non-root user. The planned go test covers orbit/ only.

Run separately in Docker on this commit's code and passed: server/datastore/mysql with MYSQL_TEST=1 (TestOpenframe Windows, TestMDMWindows) and the Windows tests of server/service. Not run with the race detector.

Ten hand-made mutants of this round's change (the hook, its place, its filter, its guards and the query) were all caught by those tests.

TestIntegrationsMDM (Wipe, Windows): 39 of 39 as upstream, and 39 of 39 in a temporary copy with the OpenFrame checks on and the fork migrations applied.

What the surviving mutations leave unverified

  • openframe_windows_wipe.go:35-47: The XML the device receives is checked only by Fleet's own parser; Microsoft's RemoteWipe page gives no SyncML example, so whether Windows accepts this Exec needs a real device.

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)

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 15:45 UTC · reviewed from Andrii Koropets's machine

Comment thread server/datastore/mysql/microsoft_mdm.go Resolved
Comment thread server/service/microsoft_mdm.go Resolved
Comment thread server/service/scripts.go Resolved
…t re-enrollment, cancel only an unanswered one
Comment thread server/service/openframe_windows_mdm.go Resolved
Comment thread server/service/openframe_windows_mdm.go Resolved
@andrii-flamingo
andrii-flamingo enabled auto-merge (squash) November 30, 2026 21:54
@andrii-flamingo
andrii-flamingo merged commit d853312 into main Nov 30, 2026
14 checks passed
@andrii-flamingo
andrii-flamingo deleted the feat/win-wipe branch November 30, 2026 21:55
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.

2 participants