Skip to content

Commit 2d5e946

Browse files
authored
Merge pull request #1185 from HackTricks-wiki/research_update_src_macos-hardening_macos-security-and-privilege-escalation_macos-protocols_20250725_162434
Research Update Enhanced src/macos-hardening/macos-security-...
2 parents 6a37b08 + bf74973 commit 2d5e946

File tree

1 file changed

+62
-4
lines changed

1 file changed

+62
-4
lines changed

src/macos-hardening/macos-security-and-privilege-escalation/macos-protocols.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Check if any is enabled running:
1717
```bash
1818
rmMgmt=$(netstat -na | grep LISTEN | grep tcp46 | grep "*.3283" | wc -l);
1919
scrShrng=$(netstat -na | grep LISTEN | egrep 'tcp4|tcp6' | grep "*.5900" | wc -l);
20-
flShrng=$(netstat -na | grep LISTEN | egrep 'tcp4|tcp6' | egrep "\*.88|\*.445|\*.548" | wc -l);
20+
flShrng=$(netstat -na | grep LISTEN | egrep 'tcp4|tcp6' | egrep "\\*.88|\\*.445|\\*.548" | wc -l);
2121
rLgn=$(netstat -na | grep LISTEN | egrep 'tcp4|tcp6' | grep "*.22" | wc -l);
2222
rAE=$(netstat -na | grep LISTEN | egrep 'tcp4|tcp6' | grep "*.3031" | wc -l);
2323
bmM=$(netstat -na | grep LISTEN | egrep 'tcp4|tcp6' | grep "*.4488" | wc -l);
@@ -38,6 +38,28 @@ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resourc
3838

3939
ARD provides versatile control levels, including observation, shared control, and full control, with sessions persisting even after user password changes. It allows sending Unix commands directly, executing them as root for administrative users. Task scheduling and Remote Spotlight search are notable features, facilitating remote, low-impact searches for sensitive files across multiple machines.
4040

41+
#### Recent Screen-Sharing / ARD vulnerabilities (2023-2025)
42+
43+
| Year | CVE | Component | Impact | Fixed in |
44+
|------|-----|-----------|--------|----------|
45+
|2023|CVE-2023-42940|Screen Sharing|Incorrect session rendering could cause the *wrong* desktop or window to be transmitted, resulting in leakage of sensitive information|macOS Sonoma 14.2.1 (Dec 2023) |
46+
|2024|CVE-2024-23296|launchservicesd / login|Kernel memory-protection bypass that can be chained after a successful remote login (actively exploited in the wild)|macOS Ventura 13.6.4 / Sonoma 14.4 (Mar 2024) |
47+
48+
**Hardening tips**
49+
50+
* Disable *Screen Sharing*/*Remote Management* when not strictly required.
51+
* Keep macOS fully patched (Apple generally ships security fixes for the last three major releases).
52+
* Use a **Strong Password** *and* enforce the *“VNC viewers may control screen with password”* option **disabled** when possible.
53+
* Put the service behind a VPN instead of exposing TCP 5900/3283 to the Internet.
54+
* Add an Application Firewall rule to limit `ARDAgent` to the local subnet:
55+
56+
```bash
57+
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent
58+
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setblockapp /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent on
59+
```
60+
61+
---
62+
4163
## Bonjour Protocol
4264

4365
Bonjour, an Apple-designed technology, allows **devices on the same network to detect each other's offered services**. Known also as Rendezvous, **Zero Configuration**, or Zeroconf, it enables a device to join a TCP/IP network, **automatically choose an IP address**, and broadcast its services to other network devices.
@@ -111,6 +133,43 @@ finally:
111133
zeroconf.close()
112134
```
113135

136+
### Enumerating Bonjour over the network
137+
138+
* **Nmap NSE** – discover services advertised by a single host:
139+
140+
```bash
141+
nmap -sU -p 5353 --script=dns-service-discovery <target>
142+
```
143+
144+
The `dns-service-discovery` script sends a `_services._dns-sd._udp.local` query and then enumerates each advertised service type.
145+
146+
* **mdns_recon** – Python tool that scans entire ranges looking for *misconfigured* mDNS responders that answer unicast queries (useful to find devices reachable across subnets/WAN):
147+
148+
```bash
149+
git clone https://github.com/chadillac/mdns_recon && cd mdns_recon
150+
python3 mdns_recon.py -r 192.0.2.0/24 -s _ssh._tcp.local
151+
```
152+
153+
This will return hosts exposing SSH via Bonjour outside the local link.
154+
155+
### Security considerations & recent vulnerabilities (2024-2025)
156+
157+
| Year | CVE | Severity | Issue | Patched in |
158+
|------|-----|----------|-------|------------|
159+
|2024|CVE-2024-44183|Medium|A logic error in *mDNSResponder* allowed a crafted packet to trigger a **denial-of-service**|macOS Ventura 13.7 / Sonoma 14.7 / Sequoia 15.0 (Sep 2024) |
160+
|2025|CVE-2025-31222|High|A correctness issue in *mDNSResponder* could be abused for **local privilege escalation**|macOS Ventura 13.7.6 / Sonoma 14.7.6 / Sequoia 15.5 (May 2025) |
161+
162+
**Mitigation guidance**
163+
164+
1. Restrict UDP 5353 to *link-local* scope – block or rate-limit it on wireless controllers, routers, and host-based firewalls.
165+
2. Disable Bonjour entirely on systems that do not require service discovery:
166+
167+
```bash
168+
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
169+
```
170+
3. For environments where Bonjour is required internally but must never cross network boundaries, use *AirPlay Receiver* profile restrictions (MDM) or an mDNS proxy.
171+
4. Enable **System Integrity Protection (SIP)** and keep macOS up to date – both vulnerabilities above were patched quickly but relied on SIP being enabled for full protection.
172+
114173
### Disabling Bonjour
115174

116175
If there are concerns about security or other reasons to disable Bonjour, it can be turned off using the following command:
@@ -124,8 +183,7 @@ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.p
124183
- [**The Mac Hacker's Handbook**](https://www.amazon.com/-/es/Charlie-Miller-ebook-dp-B004U7MUMU/dp/B004U7MUMU/ref=mt_other?_encoding=UTF8&me=&qid=)
125184
- [**https://taomm.org/vol1/analysis.html**](https://taomm.org/vol1/analysis.html)
126185
- [**https://lockboxx.blogspot.com/2019/07/macos-red-teaming-206-ard-apple-remote.html**](https://lockboxx.blogspot.com/2019/07/macos-red-teaming-206-ard-apple-remote.html)
186+
- [**NVD – CVE-2023-42940**](https://nvd.nist.gov/vuln/detail/CVE-2023-42940)
187+
- [**NVD – CVE-2024-44183**](https://nvd.nist.gov/vuln/detail/CVE-2024-44183)
127188

128189
{{#include ../../banners/hacktricks-training.md}}
129-
130-
131-

0 commit comments

Comments
 (0)