Lesson 9 of 9 · 29m
Fleet Inventory, osquery, Unified Logs, and Incident Response
Collect trustworthy endpoint facts, query fleet state with osquery, preserve evidence from unified logs, and execute response actions through controlled channels.
The difference between administering ten Macs and one thousand is not effort multiplied by one hundred. It is uncertainty multiplied by everything you failed to inventory. During an incident, nobody cares what the MDM dashboard thinks should be true. They need to know which devices are enrolled, which users are logged in, which extensions are loaded, which processes persist, and whether evidence still exists.
Inventory is a security control
A useful Mac inventory includes more than serial number and OS version:
hardware model and architecture
macOS build and update state
FileVault and recovery-key posture
SIP, Gatekeeper, firewall state
enrollment type and MDM identity
local users and admin rights
installed apps, package receipts, browser extensions
launch agents, daemons, kernel/system extensions
network configuration and security agentsosquery turns endpoint state into relational evidence
osquery exposes operating system state as SQL tables. Test locally before distributing queries:
sudo osqueryi --json "select name,version,path from apps where path like '/Applications/%' limit 5;"
sudo osqueryi --json "select label,path,program,run_at_load from launchd where disabled = 0;"Useful tables include system_info, os_version, apps, launchd, users, logged_in_users, startup_items, processes, listening_ports, and file for targeted paths. Exact table availability depends on osquery and macOS versions, so validate in your deployment.
Fleet query design is operational discipline
A broad select * across a fleet is expensive and often useless. Write narrow queries with explicit columns, predicates, and intervals. Prefer differential queries for change detection. Test cardinality: querying every file under /Users is how endpoint tooling becomes the outage.
The unified log is powerful and volatile
macOS unified logging is structured, high-volume, and not merely a text file. Query recent events with predicates:
log show --last 2h --predicate 'subsystem == "com.apple.ManagedClient"' --info
log show --last 30m --predicate 'process == "cloudd"' --debugFor incident evidence, collect promptly with consent and scope. sysdiagnose is comprehensive but huge and sensitive:
sudo sysdiagnose -f /var/tmpDo not email a sysdiagnose archive around like a screenshot. It can contain sensitive device, network, and user state.
Response actions need control planes
Common macOS response actions include unenrolling or locking a device, rotating FileVault keys, removing malicious launch items, revoking user admin rights, pushing updated security agents, and isolating at the network layer. Prefer reversible, auditable actions through MDM or endpoint tooling. Direct SSH access is sometimes useful but should not be the only incident path.
Field notes
- A missing endpoint in inventory is itself an investigation signal; silence can mean offline, uninstalled agent, or intentional tampering.
- Preserve timestamps and timezone context in evidence. macOS logs use precise machine time, but analysts often misread them.
- TCC and privacy controls intentionally limit visibility. Incident response must respect legal and organizational consent boundaries.
- Build restore paths before destructive response. Erasing a Mac may be correct, but it is not evidence preservation.
Was this lesson helpful?