fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Lock company-owned & BYOD Androids by resetting PIN

Open Leanngove opened this issue 4 months ago • 12 comments

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 to fleetctl mdm unlock to 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 say
      This 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 AMAPI RESET_PASSWORD with a Fleet-generated newPassword that fits the host's password policy (6 digits by default) and the LOCK_NOW flag, instead of LOCK.
    • Unlock host (POST /api/v1/fleet/hosts/:id/unlock): now supports Android. The output should say
      This host was locked at [timestamp] with the PIN [6 digit PIN].
      
  • [ ] 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 separate viewed_host_unlock_pin activity.
    • unlocked_host: not generated for Android hosts, since Fleet doesn't send an unlock command. No change for other platforms.
  • [ ] 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_HIGH needs 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_pin from varchar(6) to varchar(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.get call 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_pin activity, not an unlocked_host activity.

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_host activity 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_pin activity is logged.
  • [ ] API: POST /hosts/:id/lock?view_pin=true returns unlock_pin. POST /hosts/:id/unlock returns the same PIN.
  • [ ] fleetctl: fleetctl mdm lock and fleetctl mdm unlock show the updated output; unlock prints 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_COMPLEX gets a PIN with no repeating or ordered sequence and the lock succeeds.
  • [ ] Host whose policy is ALPHANUMERIC or COMPLEX gets 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 LOCK command in lock_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

  1. [ ] 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).
  2. [ ] QA: Added comment to user story confirming successful completion of test plan.
  3. [ ] 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 avatar Jul 24 '26 17:07 Leanngove

@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!

lukeheath avatar Sep 22 '26 19:09 lukeheath

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 avatar Sep 22 '26 21:09 noahtalerman

@noahtalerman Oh my bad, thanks for the clarification.

lukeheath avatar Sep 22 '26 21:09 lukeheath

Oh my bad, thanks for the clarification.

@lukeheath all groovy! 🎵

noahtalerman avatar Sep 22 '26 22:09 noahtalerman

TODO: @Leanngove: update iOS copy to be use-case first:

Image

Leanngove avatar Oct 30 '26 17:10 Leanngove

@Leanngove, three product decisions from spec review on Android lock:

  1. 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_HIGH needs at least 8), gets a longer code. That makes "six-digit" wrong for those hosts in the Lock modal, the View unlock PIN modal, the viewed_host_unlock_pin activity text, and the fleetctl output. Can you check the copy? "unlock PIN" or "unlock code" without the digit count may be enough.
  2. "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.
  3. 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 avatar Nov 10 '26 21:11 dantecatalfamo

@dantecatalfamo

  1. I updated the wireframes to keep the "PIN" copy but remove the "six-digit" phrase.
  2. That's fine.
  3. 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. Image

Leanngove avatar Nov 10 '26 21:11 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.

noahtalerman avatar Nov 11 '26 16:11 noahtalerman

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.

noahtalerman avatar Nov 11 '26 16:11 noahtalerman

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

Leanngove avatar Nov 11 '26 23:11 Leanngove

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 avatar Nov 12 '26 14:11 noahtalerman

@noahtalerman makes sense, I filed a user story for the follow up: https://github.com/fleetdm/fleet/issues/58572

Leanngove avatar Nov 12 '26 19:11 Leanngove