socketfilterfw
socketfilterfw is the command-line control for the macOS Application Layer Firewall (ALF), the built-in firewall that filters inbound network connections on a per-application basis. It lives in its own libexec subdirectory rather than a standard bin path and is normally used by administrators and MDM tooling to turn the firewall on or off, toggle stealth and block-all modes, and allow or block individual applications. Every one of these operations is a single root command with no GUI interaction. An attacker who already has root can use it to weaken the host's inbound network defenses by disabling the firewall, or by pre-authorizing a planted listener so an inbound bind shell or command-and-control implant accepts connections without ever raising the "allow incoming connections?" prompt. The ALF only governs inbound traffic, so socketfilterfw does not help hide outbound beacons.
Paths
/usr/libexec/ApplicationFirewall/socketfilterfw Example Use Cases
Disable the Application Firewall entirely #
Turning the firewall off with --setglobalstate off removes all per-application inbound filtering and the associated "allow incoming connections?" prompts, so any listening service an attacker plants on the host becomes reachable from the network. Requires root.
/usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off Register and allow a planted listener to receive inbound connections #
--add registers an application with the firewall and --unblockapp marks it as allowed to receive inbound connections. Applied to a bind shell or C2 implant, this creates a persistent firewall allow-list entry so the implant accepts connections while the firewall stays enabled. Requires root, and the binary must exist at the referenced path.
/usr/libexec/ApplicationFirewall/socketfilterfw --add <IMPLANT_PATH> && /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp <IMPLANT_PATH> Disable block-all mode to re-open inbound access #
Block-all mode blocks incoming connections to all non-essential applications, including signed ones, and is sometimes enabled as a hardening measure. Turning it off with --setblockall off reverses that hardening so a listening implant is once again reachable while the firewall itself remains on. Requires root.
/usr/libexec/ApplicationFirewall/socketfilterfw --setblockall off Enumerate Application Firewall state and allowed applications #
--getglobalstate reports whether the firewall is enabled, --getstealthmode whether stealth mode is active, and --listapps the registered applications with their allow/block state. Together these tell an attacker whether an inbound listener needs the firewall weakened and which existing allow-list entries are worth impersonating. All require root.
/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate Detections
- Jamf Protect: Application Firewall configuration changes (socketfilterfw used with --setglobalstate off, --setblockall off, --unblockapp, or --remove)
- Splunk: MacOS List Firewall Rules (socketfilterfw --getglobalstate execution)
- Sigma: System Network Discovery - macOS (process image path ends with /socketfilterfw)