Security Engineering / Fundamentals / macOS
Fundamental 03

macOS
internals The fleet most FinTechs actually run, and the platform most security engineers know least well. Different persistence, different logging, a permission system Windows has no equivalent for, and an EDR agent that operates under Apple's rules rather than its own.

feeds → SentinelOne, MDM4 tiers
Tier 0 · Groundthe shape of the system

Unix underneath, Apple on top

macOS is a BSD-derived Unix (so ps, launchd, /etc, POSIX permissions all apply) wrapped in Apple frameworks that add code signing, consent prompts and a read-only system volume.

Module 0.1

Filesystem geography

Where things legitimately live — and where they shouldn't
/System            Apple only. Sealed, read-only (SSV) since Big Sur.
/Library           system-wide config, agents, daemons, extensions
~/Library          per-user equivalent — persistence hides here
/Applications      app bundles (.app = a directory, not a file)
/usr/local, /opt   Homebrew and third-party CLI tools
/private/var/log   legacy text logs (mostly superseded)
/tmp, /var/folders staging areas for droppers

An app bundle is a folder: Foo.app/Contents/MacOS/Foo is the executable, Info.plist the metadata. Malware frequently ships as a bundle with a document icon.

Property lists (plists) are the config format — XML or binary. Read them with plutil -p file.plist, since binary plists look like noise in a text editor.

Module 0.2

The four Apple security layers

Gatekeeper, XProtect, SIP, TCC — what each one actually does
LayerQuestion it answersBypassed by
GatekeeperIs this downloaded app signed and notarised?User right-click-open; stripped quarantine attribute; stolen dev cert
XProtect / XProtect RemediatorDoes this match known malware?Novel samples; it is signature-based AV, updated out of band
SIPMay even root modify system files?Only by disabling from Recovery — a strong tamper signal
TCCMay this app access mic, camera, Documents, Full Disk?Social-engineered consent; TCC database attacks (mostly patched)

Quarantine attribute — anything downloaded by a browser or mail client gets the extended attribute com.apple.quarantine. That flag is what triggers Gatekeeper and notarisation checks. Check it with xattr -l file; malware often removes it, and that removal is itself detectable.

Notarisation means Apple has scanned the binary and issued a ticket — not that Apple vouches for the developer's intentions. Notarised malware exists. Treat it as hygiene, not assurance.
Tier 1 · Mechanicshow it runs and persists

launchd, persistence and process telemetry

Module 1.1

launchd — PID 1 and the persistence hub

Four directories cover most persistence on macOS
/Library/LaunchDaemons     runs as root at boot, no user needed
/Library/LaunchAgents      runs as any user at login
~/Library/LaunchAgents     runs for that user — no admin rights required!
/System/Library/Launch*    Apple only, SIP-protected

A malicious agent is a small plist with Label, ProgramArguments, and RunAtLoad or StartInterval. Because ~/Library/LaunchAgents is user-writable, commodity macOS malware needs no privilege escalation to persist.

# enumerate
launchctl list
ls -la ~/Library/LaunchAgents /Library/Launch{Agents,Daemons}
plutil -p ~/Library/LaunchAgents/com.suspicious.updater.plist

Other persistence to sweep

  • Login items — modern ones registered by apps (sfltool dumpbtm, and the Background Task Management database).
  • Configuration profilesprofiles list; a rogue profile can install certificates or lock settings.
  • Cron / at — legacy but functional.
  • Shell rc files~/.zshrc, ~/.zprofile for anything that starts a terminal.
  • Dylib hijacking — an app loading a library from a writable path.
  • Kernel/System extensions — rare now, and highly visible: user approval plus MDM.
Module 1.2

Unified logging and the Endpoint Security framework

Where macOS telemetry comes from

Apple replaced text syslog with the unified log — a compressed, structured, memory-and-disk store queried with the log command. Much of it is ephemeral and private-redacted, which surprises people expecting Windows-style durable event logs.

log show --last 1h --predicate 'process == "sudo"'
log stream --predicate 'eventMessage CONTAINS "quarantine"'
log show --last 24h --predicate 'subsystem == "com.apple.TCC"'

Endpoint Security (ES) framework is the sanctioned API that EDR agents — SentinelOne included — use to subscribe to process exec, file, and mount events in kernel-adjacent user space, replacing the old kernel extensions. Consequences: agents need explicit MDM approval (a PPPC profile granting Full Disk Access and system extension permission), and if that profile is missing the agent installs but sees almost nothing.

The most common macOS EDR failure is not a broken agent — it is a device that never received the MDM privacy preferences profile, so the agent lacks Full Disk Access. It reports healthy while being partially blind. Always validate coverage with a live test event, not with the console's health status.
Module 1.3

How macOS actually gets attacked

Infostealers, fake installers, TCC abuse
  • Fake app installers / cracked software — DMGs with instructions to right-click-open (defeating Gatekeeper by design) or to paste a curl | bash line into Terminal.
  • Infostealers (Atomic Stealer and relatives) — grab browser cookies, keychain items via a fake password prompt, crypto wallets, then exit. Fast, non-persistent, financially motivated. The fake osascript password dialog is the signature move: osascript -e 'display dialog "macOS needs your password"'.
  • Malicious profiles / MDM abuse — installing a configuration profile to add a trusted CA or proxy.
  • TCC social engineering — prompting the user to grant Screen Recording or Accessibility, which then permits keystroke capture and screen capture legitimately.
  • Living off the landcurl, osascript, launchctl, defaults, xattr -d, base64, python3.
# high-signal command lines to detect
osascript -e 'display dialog ... with hidden answer'   fake password prompt
xattr -d com.apple.quarantine /path/app                Gatekeeper evasion
curl -fsSL http... | bash                              remote script exec
security find-generic-password -w                      keychain access
csrutil disable                                        SIP tampering
Drill 1

EDR shows osascript invoked with display dialog containing "System Preferences requires your password", followed by security find-generic-password. What is happening?

Local credential phishing. macOS infostealers imitate a system password prompt because the real OS asks for passwords constantly, so users comply. The follow-on keychain query confirms intent. Response: isolate, collect the parent process and its origin (a DMG? a curl-pipe?), rotate the user's credentials and any SSO sessions, and check browser cookie stores as compromised.
Tier 2 · Engineerfleet management

Managing a Mac fleet defensibly

Module 2.1

MDM, baselines and the evidence auditors want

What "managed" has to mean in practice
  • Automated Device Enrolment (via Apple Business Manager) so enrolment is supervised and non-removable — the difference between a managed device and a device with an agent someone can uninstall.
  • FileVault enforced with escrowed recovery keys.
  • PPPC profile granting the EDR and any DLP/steering client the access they need, pushed before the agent.
  • Firewall + stealth mode, Gatekeeper enforced, automatic security updates and Rapid Security Responses enabled.
  • Local admin removed for standard users, with a break-glass account; guest disabled.
  • Baseline against CIS Benchmarks for macOS, with drift reporting — this is what turns "we manage Macs" into an auditable statement.
Device posture is the bridge: your MDM's compliance state should feed the IdP's conditional access and Netskope's device classification, so an unmanaged or non-compliant Mac cannot reach sanctioned SaaS. That single integration does more than any endpoint setting in isolation.
Referencesearchable

Glossary