Skip to content
Documentation

macOS sensors

This page is published from the agent repository. Edit on GitHub View source

The macOS agent collects telemetry through four sources, one crate each under crates/sensors/macos. Each depends only on schema and compiles to a stub on other operating systems; the pure parsing and normalization halves are compiled and tested on every OS.

SourceCrate (package)MechanismNeedsPage
EndpointSecurityendpoint-security/ (sensor-macos)ES client through a C shim, NOTIFY events onlyroot, the ES client entitlement, Full Disk Accessendpoint-security.md
Unified logunifiedlog/ (sensor-macos-unifiedlog)/usr/bin/log stream --style ndjson with a strict predicateroot for the full streamunified-log.md
Socket tablesockets/ (sensor-macos-sockets)libproc fd walk through a C shimnothing (root for full visibility)sockets.md
Network Extensionnetwork-extension/ (sensor-macos-network-extension) + Swift system extensionNDJSON over a Unix socket from NEFilterDataProvider and NEDNSProxyProvidera packaged, approved system extensionnetwork-extension.md

Why C shims

Apple's structures are large, version-gated unions (es_message_t, socket_fdinfo), and es_new_client takes an Objective-C block. Transcribing them into #[repr(C)] Rust would drift silently with each SDK. Instead, small C shims are compiled by build.rs against the SDK headers on the build machine, so the C compiler checks every field access, and Rust only sees flat structs the shim owns. The ES shim also defines its own event kind numbers instead of es_event_type_t ordinals, which change between SDK releases. Cross-compiling to macOS from another OS is not supported, since the shims need the SDK.

How the agent runs them

run_macos_sensors wires the four sources into one shared sink (behind the command-line credential redactor):

flowchart LR
    ES["MacosSensor::run<br/>(calling thread, ES dispatch threads)"] --> SINK[(shared EventSink<br/>+ redaction)]
    UL["unifiedlog-tail thread<br/>reads `log stream` child"] --> SINK
    SO["socket poller thread<br/>(10 s)"] --> SINK
    NE["ne-receiver thread<br/>Unix socket accept loop"] --> SINK
    SWIFT["Swift system extension"] -->|NDJSON| NE
  • EndpointSecurity is the primary sensor and runs on the calling thread; its error ends the run.
  • The unified-log tail, the socket poller and the NE receiver are supplementary. Each failure to start is logged and never fatal.
  • Ctrl-C stops the ES client, stops the socket poller and kills the log stream child (which ends the tail thread).
  • At startup, seeded_rule_state seeds the rule state with the running processes (ps) and the LISTENER-DRIFT baseline from one socket snapshot.

Differences from Windows and Linux

  • No silence heartbeats are registered for any macOS source, the log stream child is not restarted if it dies, and the shed/skew counters are not reported anywhere. Tracked in #34.
  • Code-signing state comes with the ES exec event, so the sensor fills ExecEvent::signature itself instead of leaving it to enrichment.
  • Container attribution and process incarnation stamps are not filled on macOS.
  • Network flows and DNS are not available from EndpointSecurity; they depend on the Network Extension, which is not yet packaged (#21).

Validation status

The ES sensor and its parsers are unit-tested against SDK-checked layouts, and its error paths were checked on a SIP-enabled host. Running an entitled client and observing real events end to end is tracked in #78. The unified-log parsers are pinned against verbatim captures from macOS 26.