It's the opposite: they generally design their daemons such that they only run when a socket is open.
It depends. Ideally daemons should only run when enabled but one can clearly see 100s of daemons running on modern Mac systems including for services not enabled. For example there are 4 iCloud-related services running on one of my laptops even though I don't have iCloud enabled and have never enabled it. Similarly, studentd -- something for classroom management -- more than occasionally updates a preferences file under ~/Library even though I don't use that and my laptops have never been part of an educational system. Clearly it runs even when not used.
That's also true of screensharingd. You can easily try this yourself:
This is a mechanism in launchd with security and energy benefits. Instead of having screensharingd constantly listening for connections, launchd does the listening:
- With Screen Sharing disabled, open Activity Monitor, and search for screensharingd. You probably won't find it.
- Now in Terminal, do telnet localhost 5900. This will fail with "connection refused", as there's nothing listening. screensharingd still won't be running, of course.
- Now turn it on. Notice that screensharingd still isn't running!
- Finally, try telnet localhost 5900 again. This time, it'll work, and the very act of connecting to that port is what actually launches the daemon.
Yes glad to see that Apple handled this one like that -- kind of like the old BSD inetd design. That's the way it should be but not the way that a lot of Mac services are setup.
Then for now I am going to assume that the bug is in screensharingd and/or ScreensharingAgent and not launchd or related configuration of such, and therefore having the Firewall On and this Off is good protection against this hole (short of the patch -- but even on patched system, what similar holes are out there waiting to be discovered in other Apple services?).
Still it would be better if Apple provided more information on the bug. Apple goes crazy with protections against "evil maid" scenarios but I am most concerned about vulnerabilities to remote exploits.
P.S.Apple removed Telnet from macOS years ago -- nc(1) would be the builtin tool to test something like this now.