Android BYOD: /commands/run WIPE, Unenroll and Clear passcode are accepted while a wipe is already pending
Fleet versions
- Discovered: 4.94.0-rc.2610131847
- Reproduced: 4.94.0-rc.2610131847
Web browser and operating system:
💥 Actual behavior
On a personally-owned (BYOD) Android host with a wipe already pending (device offline), a second wipe request is refused by the wipe endpoint and fleetctl mdm wipe (422 "Host has pending wipe request. The host will be wiped when it comes online."), but other requests are still accepted on the host:
| Second request | Result |
|---|---|
POST /api/v1/fleet/commands/run with {"type":"WIPE","wipeParams":{}} |
200, new WIPE sent to Google, ran_custom_mdm_command logged |
Unenroll: DELETE /api/v1/fleet/hosts/{id}/mdm (also the UI Unenroll action) |
204, new work-profile WIPE sent to Google, mdm_unenrolled logged immediately |
Clear passcode: POST /api/v1/fleet/hosts/{id}/clear_passcode / fleetctl mdm clear-passcode |
200 / exit 0, RESET_PASSWORD sent to Google, cleared_passcode logged on every request (no duplicate check: sent twice, both accepted) |
When the device reconnects, the work profile is removed once and the host ends MDM Off, but the second WIPE stays Pending in the command list (nothing left to ack it) until the host re-enrolls. The activity feed also shows the extra entries.
For Clear passcode, the RESET_PASSWORD commands also stay Pending after the wipe (nothing left to run them), and the activity feed shows "cleared passcode" even though it never happened.
For comparison, Lock in the same state is correctly refused: API 422 / fleetctl mdm lock exit 1, "Host has pending wipe request. Cannot process lock requests once host is wiped." (LockHost checks IsPendingWipe()).
Cause:
/commands/run→enqueueAndroidMDMCommand(server/service/mdm.go) only callsfleet.ValidateAndroidWipeRequest, which checks Android MDM is configured. The pending lock/wipe checks live only inWipeHost.UnenrollAndroidHost(server/mdm/android/service/service.go) has no pending-wipe check and always issues a new WIPE on BYOD.- Clear passcode →
clearPasscodeAndroid(ee/server/service/mdm.go) only checks Android MDM is configured and the host is connected; neither it norClearAndroidPasscode(server/mdm/android/service/service.go) checks for a pending wipe/lock.
Found while testing #53471 (Allow WIPE for all Android hosts). Note: the #53471 test plan currently accepts the /commands/run and Unenroll behavior; Clear passcode was found afterwards (asked by LeAnn). Filing to track the duplicate commands/activities.
🛠️ Expected behavior
If a wipe (or work-profile wipe from Unenroll) is already pending on a BYOD Android host, a second wipe request through any path is refused the same way as the wipe endpoint:
/commands/runWIPE → 422 "Host has pending wipe request…", nothing sent to Google, no activity.- Unenroll → refused with a pending-wipe message, nothing sent to Google, no
mdm_unenrolledlogged. - Clear passcode → refused with a pending-wipe message (like Lock: "Host has pending wipe request…"), nothing sent to Google, no
cleared_passcodelogged.
(Same for a pending Lock on Premium: the wipe endpoint refuses with the pending-lock message; /commands/run WIPE should too.)
🧑💻 Steps to reproduce
These steps:
- [ ] Have been confirmed to consistently lead to reproduction in multiple Fleet instances.
- [x] Describe the workflow that led to the error, but have not yet been reproduced in multiple Fleet instances.
- Fleet Premium with Android MDM on. Enroll an Android phone with a work profile (BYOD, "On (personal)").
- Put the phone in airplane mode.
POST /api/v1/fleet/hosts/{id}/wipe→ 200, WIPE Pending.POST /api/v1/fleet/hosts/{id}/wipeagain → 422 "Host has pending wipe request…" ✅ (correct).POST /api/v1/fleet/commands/runwith base64{"type":"WIPE","wipeParams":{}}and the host UUID → 200, second WIPE Pending,ran_custom_mdm_commandlogged. ❌- (Separate run, steps 1–3 again)
DELETE /api/v1/fleet/hosts/{id}/mdm→ 204, second WIPE Pending,mdm_unenrolledlogged while host still shows MDM On. ❌ - (Separate run, steps 1–3 again)
POST /api/v1/fleet/hosts/{id}/lock→ 422 "Host has pending wipe request…" ✅ (correct);POST /api/v1/fleet/hosts/{id}/clear_passcode→ 200, RESET_PASSWORD Pending,cleared_passcodelogged. Same withfleetctl mdm lock/fleetctl mdm clear-passcode. ❌ - Turn airplane mode off → first WIPE Acknowledged, work profile removed, host MDM Off; second WIPE stays Pending.
🕯️ More info (optional)
- Repro log, 2026-10-19 (UTC):
/commands/runpath: wipe 15:41:30 (919b1293…),/commands/runWIPE 15:41:46 → 200 (14837d26…); after reconnect 16:06:39 first WIPE Acknowledged,14837d26…stayed Pending until re-enroll at 16:12.- Unenroll path: wipe 13:43:16 (
15342ec2…), Unenroll 13:43:26 → 204 (36201fe5…),mdm_unenrolledlogged 13:43:26; after reconnect 13:44:09 first WIPE Acknowledged,36201fe5…stayed Pending until re-enroll at 14:22. - Clear passcode path (host 49): wipe 20:53:44 (
34066806…); Lock API/CLI → 422; Clear passcode API 20:53:53 → 200 (70d5c362…), CLI 20:53:53 → accepted (fc3d77c1…), twocleared_passcodeactivities; after reconnect 20:54:17 WIPE Acknowledged, host MDM Off, both RESET_PASSWORD stayed Pending.
- Re-enrolling the host clears the leftover Pending command (
AndroidResetOnReenrollmentdeletes Pending commands).