fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.01k stars 418 forks source link

ADE hosts might not get the bootstrap package if they're deleted from the UI and turn on MDM features afterwards #17292

Closed roperzh closed 5 months ago

roperzh commented 7 months ago

Fleet version: 4.46.1


💥  Actual behavior

If an ADE host is deleted from the UI, and has been assigned to Fleet for a long time in ABM, it won't get the bootstrap package delivered the next time the host enrolls.

🧑‍💻  Steps to reproduce

  1. Turn on MDM features for a host using ADE
  2. Observe how we send a command to install the bootstrap package
  3. Delete the host from the UI
  4. Turn on MDM features again
  5. Observe how we don't send a command to install the bootstrap package

🕯️ More info (optional)

  1. Unless we hit this clause, a cursor is used to paginate the results we get from the ABM API
  2. When a device is repurposed we ask people to delete it from Fleet as well, based on this, we don't delete the entry from the table
  3. Since the table is keyed by host.id , we have an orphan row
  4. When the host enrolls again, we think it's not ADE-assigned, and as such we don't do any of the ADE-specific flows
mna commented 6 months ago

Investigating this a bit before sprint kickoff (not assigning myself just yet as I don't have the means to test those mac DEP enrollment flows by myself):

So the issue seems to be that the DEP syncer only moves forward, doesn't re-consider old devices once ingested once unless the setup assistant changed, but if we always did a full sync, it might introduce performance issues or rate limits? We already keep some DEP information in host_dep_assignments, but we only link the host via its host.id which isn't constant. Could we store the host UUID/serial and try to match using this on host_dep_assignments, and ignore it if the row has been soft-deleted (which I believe would indicate that the host is no longer assigned to Fleet in ABM)?

fleet-release commented 5 months ago

ADE host reborn, Fleet's embrace ensures no scorn, Tools restored, no mourn.