Lock company-owned & BYOD Androids by resetting PIN
Slack thread here.
The plan is to update the existing Lock button for Androids to reset the PIN to a randomly generated PIN that fits the host's password policy (instead of locking the screen), effectively locking the user out of the host during offboarding. This is a breaking change.
Goal
| User story |
|---|
| As an organization using Fleet, |
| I want to lock users out of company-owned & BYOD Androids during off-boarding instead of wiping their devices, |
| to preserve data during a legal hold. |
Changes
Product
- [ ] UI changes: Figma wireframes
- Also update copy in lock/unlock modals for macOS, Windows, iOS, and Linux. See Figma
- [ ] CLI (fleetctl) usage changes:
fleetctl mdm lock --host=<android-host>: update the output. It currently says "The end user can unlock by entering their device PIN." Replace it with this message, which points tofleetctl mdm unlockto get the PIN:The host will lock when it comes online. To view the unlock PIN, copy and run this command: fleetctl mdm unlock --host=<host>fleetctl mdm unlock --host=<android-host>: now supported for Android. The output should sayThis host was locked at [timestamp] with the PIN [6 digit PIN].
- [ ] YAML changes: No changes
- [ ] REST API changes (breaking):
- Lock host (
POST /api/v1/fleet/hosts/:id/lock): for Android, sends AMAPIRESET_PASSWORDwith a Fleet-generatednewPasswordthat fits the host's password policy (6 digits by default) and theLOCK_NOWflag, instead ofLOCK. - Unlock host (
POST /api/v1/fleet/hosts/:id/unlock): now supports Android. The output should sayThis host was locked at [timestamp] with the PIN [6 digit PIN].
- Lock host (
- [ ] Fleet's agent (fleetd) changes: No changes (AMAPI only)
- [ ] Fleet server configuration changes: No changes
- [ ] Exposed, public API endpoint changes: No changes
- [ ] fleetdm.com changes: No changes
- [ ] GitOps mode UI changes: No changes (host actions aren't GitOps-managed)
- [ ] GitOps generation changes: No changes
- [ ] Activity changes:
- New activity type:
viewed_host_unlock_pin.- Display name ("type" filter): "Viewed unlock PIN"
- Activity feed: "[user] viewed the unlock PIN for [host display name]."
- Generated when a user views an Android host's unlock PIN:
POST /api/v1/fleet/hosts/:id/unlock,fleetctl mdm unlock, or opening the View unlock PIN. - Fields:
host_id,host_display_name,host_platform{ "host_id": 1, "host_display_name": "Anna's Pixel 9", "host_platform": "android" }
locked_host: no new fields."view_pin"now also applies to Android hosts (POST /hosts/:id/lock?view_pin=true). Viewing the PIN as part of the lock request is captured here, not as a separateviewed_host_unlock_pinactivity.unlocked_host: not generated for Android hosts, since Fleet doesn't send an unlock command. No change for other platforms.
- New activity type:
- [ ] Permissions changes: No changes.
- [ ] Changes to paid features or tiers: No changes
- [ ] My device and fleetdm.com/better changes: No changes.
- [ ] Usage statistics: No changes
- [ ] Other reference documentation changes: Update Lock and wipe hosts. Android bullets: what gets locked on BYOD vs. company-owned and how to get the PIN. The Clear passcode steps also need fixing; they only mention iOS/iPadOS.
- [ ] First draft of test plan added (below)
- [ ] Once shipped, requester has been notified
- [ ] Once shipped, dogfooding issue has been filed
Open questions
Password policy conflicts. If the host's policy requires an alphanumeric or complex password, a 6-digit numeric PIN fails with INVALID_VALUE. Do we generate a password that meets the policy (no longer a "6-digit PIN" everywhere), or show an error?
- Resolved: Fleet generates a password that fits the host's password policy, read from the policy the device actually enforces. Most hosts still get a 6-digit PIN; hosts whose policy requires letters or a longer code (e.g.
COMPLEXITY_HIGHneeds at least 8 characters) get a longer code. The Android copy drops "six-digit" (decision); macOS keeps it.
Engineering
- [x] Test plan is finalized
- [x] Contributor API changes: No changes
- [x] Feature guide changes: Update Lock and wipe hosts (
articles/lock-wipe-hosts.md): Android lock behavior for BYOD vs. company-owned, how to get the PIN, the Clear passcode steps (currently iOS/iPadOS-only), and a note that a recent lock can block lost mode (RESET_PASSWORD_RECENTLY). - [x] Database schema migrations: Widen
host_mdm_actions.unlock_pinfromvarchar(6)tovarchar(32)so policy-fitting passwords longer than 6 characters fit. - [x] Load testing: Not required. Lock is an admin-triggered, per-host action. It adds one AMAPI
devices.getcall per lock, and host details adds no queries. - [x] Pre-QA load test: Not required.
- [x] Load testing/osquery-perf improvements: No changes.
ℹ️ Please read this issue carefully and understand it. Pay special attention to UI wireframes, especially "dev notes".
Sub-issues
- #58429 Backend: reset PIN on lock and view PIN through the unlock API
- #58430 Backend/CLI: fleetctl lock and unlock output (depends on #58429)
- #58431 Frontend: Lock and View unlock PIN modals, activity, and modal copy for all platforms (builds against the #58429 API contract)
- #58432 Documentation and engineering QA (depends on all of the above)
Risk assessment
- Requires testing in a hosted environment: No. Android commands work against AMAPI from a local server with a direct Google connection.
- Requires load testing: No.
- Risk level: High
- Risk description: Breaking change to Android lock behavior. A wrong generated password locks a user out of their work profile or device with no PIN Fleet can show; the fallback is Clear passcode. BYOD behavior when the user has one lock for personal and work isn't documented by Google and must be verified on a device.
Test plan
Make sure to go through the list and consider all events that might be related to this story, so we catch edge cases earlier.
- running unlock via API, CLI, or opening the "View unlock PIN" modal should record a
viewed_host_unlock_pinactivity, not anunlocked_hostactivity.
Core flow
Run on one company-owned (fully managed) Android and one BYOD (work profile) Android. Test BYOD with both a single lock and a separate work profile lock.
- [ ] Lock (UI): Host details > Actions > Lock. The modal says Fleet will generate an unlock PIN (no digit count).
locked_hostactivity is logged. - [ ] Device side: the device locks right away (
LOCK_NOW) and the old PIN no longer works.- Company-owned: the whole device requires the new PIN.
- BYOD: work apps require the new PIN
- [ ] View unlock PIN (UI): Actions > View unlock PIN shows the unlock PIN (6 digits by default, longer or alphanumeric if the host's password policy requires it) and a timestamp, and
viewed_host_unlock_pinactivity is logged. - [ ] API:
POST /hosts/:id/lock?view_pin=truereturnsunlock_pin.POST /hosts/:id/unlockreturns the same PIN. - [ ] fleetctl:
fleetctl mdm lockandfleetctl mdm unlockshow the updated output;unlockprints the PIN and timestamp. - [ ] Offline device: lock while the device is off → stays Lock pending until it comes online, then locks.
- [ ] Fleet Free: Lock/Unlock hidden in the UI; API returns the Premium error.
Edge cases
- [ ] Host whose policy is
NUMERIC_COMPLEXgets a PIN with no repeating or ordered sequence and the lock succeeds. - [ ] Host whose policy is
ALPHANUMERICorCOMPLEXgets an alphanumeric password that meets the policy and the lock succeeds. - [ ] BYOD host with one lock and BYOD host with a separate work profile lock: work apps need the new PIN, the personal lock is unchanged.
- [ ] View unlock PIN is hidden while the lock is pending and appears once the device acknowledges.
- [ ] Lock again after a successful lock: new PIN, new timestamp.
- [ ] Lock is rejected while a Clear passcode is pending, and Clear passcode is rejected while a lock is pending.
- [ ] Host locked before upgrade (old
LOCKcommand inlock_ref): View unlock PIN hidden, unlock API returns 409. - [ ] Re-enrolled host: View unlock PIN hidden until it's locked again.
Supplemental testing
Testing notes
Confirmation
- [ ] Engineer: Added comment to user story confirming successful completion of test plan (include any special setup, test data, or configuration used during development/testing if applicable).
- [ ] QA: Added comment to user story confirming successful completion of test plan.
- [ ] QA: Determined whether this story needs Playwright automation.
- Needs automation: Yes / No
- If yes, filed a follow-up issue in the :help-qa project with status "Needs automation":
@Leanngove @noahtalerman Let's target this for 5.1.0 for now until we've sized out all of the breaking changes in Fleet 5. Let me know if that's an issue. Thanks!
The plan is to update the existing Lock button for company-owned Android to activate Lost mode (instead of locking the screen), to be consistent with iOS and iPadOS. This is a breaking change.
Hey @lukeheath, this story includes a breaking change. That's why we put it in Fleet 5.
@noahtalerman Oh my bad, thanks for the clarification.
Oh my bad, thanks for the clarification.
@lukeheath all groovy! 🎵
TODO: @Leanngove: update iOS copy to be use-case first:
@Leanngove, three product decisions from spec review on Android lock:
- The unlock code fits the host's password policy. Fleet reads the policy the device actually enforces (from Google) and generates a code that meets it. Most hosts still get a 6-digit PIN. A host whose policy needs letters, or more than 6 digits (e.g.
COMPLEXITY_HIGHneeds at least 8), gets a longer code. That makes "six-digit" wrong for those hosts in the Lock modal, the View unlock PIN modal, theviewed_host_unlock_pinactivity text, and the fleetctl output. Can you check the copy? "unlock PIN" or "unlock code" without the digit count may be enough. - "Fleet locked this host [x time ago]" uses the time the device acknowledged the lock, not the time the admin sent it. View unlock PIN only shows once the device has acknowledged.
- Possible follow-up: Clear passcode doesn't currently clear the stored PIN, so View unlock PIN keeps showing a PIN that no longer works. The modal copy ("If the PIN doesn't work, it was changed…") covers this for now. We could hide the PIN after Clear passcode in a later ticket.
@dantecatalfamo
- I updated the wireframes to keep the "PIN" copy but remove the "six-digit" phrase.
- That's fine.
- I'm not sure if we'd want to hide the unlock PIN after someone clears passcode. What do you think @noahtalerman ? I can't seem to think of any reason why not, but I'm pausing due to the offboarding / legal hold scenario. Would we want to continue keeping track of who views the PIN, even if the passcode has been cleared? Otherwise, I can track this with a story.
I'm not sure if we'd want to hide the unlock PIN after someone clears passcode. What do you think @noahtalerman ? I can't seem to think of any reason why not, but I'm pausing due to the offboarding / legal hold scenario. Would we want to continue keeping track of who views the PIN, even if the passcode has been cleared? Otherwise, I can track this with a story.
@dantecatalfamo let's hit this in the parking lot during standup today.
UPDATE: @noahtalerman: On second thought, up to you @Leanngove.
I'm not sure if we'd want to hide the unlock PIN after someone clears passcode. What do you think @noahtalerman ? I can't seem to think of any reason why not, but I'm pausing due to the offboarding / legal hold scenario. Would we want to continue keeping track of who views the PIN, even if the passcode has been cleared? Otherwise, I can track this with a story.
@dantecatalfamo let's hit this in the parking lot during standup today.
UPDATE: @noahtalerman: On second thought, up to you @Leanngove.
@Leanngove up to you.
View unlock PIN keeps showing a PIN that no longer works.
This is true in other cases too, like if someone goes in and changes the PIN on the phone directly.
I think let's leave it for now. I think it might introduce some confusion (hitting Clear passcode can make View unlock PIN go away, but manually changing the PIN on the device doesn't?)
@dantecatalfamo @noahtalerman
hitting Clear passcode can make View unlock PIN go away, but manually changing the PIN on the device doesn't?
@Leanngove I hear you but we (Fleet) know for sure when we an IT admin selects Clear passcode. So we know for sure that the PIN we set won't work.
We don't know when an end user manually changed the PIN on the device (right?). So, we can't assume the PIN we set doesn't work.
I think totally ok to ship this story as-is but I think let's follow up w/ a quick win or user story to remove the unlock PIN if an IT admin selects Clear passcode.
@noahtalerman makes sense, I filed a user story for the follow up: https://github.com/fleetdm/fleet/issues/58572