5

The recent major security flaw in macOS 11.13.[1,2] has turned the usual advice of not enabling the root account on its head. But it has left me a bit confused about exactly what root account is being discussed.

The Darwin shell has a root account listed, and has many files and directories listed as owned by root, but macOS has no login account enabled for root.

What's the difference between the root account listed as an existing owner for files in the Terminal, and the (disabled) root login account?

4

The root user (UID 0) exists in every Unix or Unix-like operating system. Every process of a Unix operating systems must run as a valid user/UID, independently of system processes, daemons, services or user-initiated applications. Every basic system-process runs under UID 0 (root), and every system-relevant file is owned by that user. For reasons of security, some processes are running as different "users" with lesser privileges than the superuser root. Such users are there for the solely purpose to start services, such as a webserver, a database, the window server and so on. This means, not every user configured on Unix (or macOS) is a "real" user. In fact, most of those system-users can not log-in interactively.

For example a webserver (nginx, apache, ...) will be started by a script running under UID 0 (=root). The webserver-process afterwards drops the privileges to a specific UID (in this case, it could be the user www). www is not a real user and cannot be used to log in to the system interactively.
There are two ways to "deactivate" a (system) user:

  • set the user shell to /bin/false (or any non valid-shell)
  • disable the users's password, setting it to an invalid, empty or specific value.

On macOS AFAIK a non-valid user has an empty password and a specific property set on the local OpenDirectory server.

Usually, for a request like "is this a valid user" the OpenDirectory service in macOS does a simple check on the requested user and returns true (user can log in) or false (user cannot log in).
It seems, Apples bug was not to check user's validity but to set it to enabled. On already enabled accounts this had no effect, but disabled accounts became valid, enabled accounts. And since a disabled user has no password, an empty password was accepted as a valid option to log in as superuser/root.

  • What does it mean, in this context, that dscl . list /Users UserShell gives root /bin/bash (though I have no interactive login for that set up)? – orome Nov 30 '17 at 17:57
  • @orome This means that the root user, if it would be enabled, would get /bin/bash as shell. Use sudo /usr/bin/dscl . -create /Users/root UserShell /usr/bin/false to change it for extra security. – nohillside Nov 30 '17 at 19:09
  • @patrix: And doing that just changes the shell that rout would get if it were enabled (but doesn't enable it), correct? – orome Nov 30 '17 at 19:13
  • @orome What else would you expect to be impacted here? – nohillside Nov 30 '17 at 19:32
  • @patrix: What I asked about parenthetically. Is the answer secret? – orome Nov 30 '17 at 20:17
3

File ownership does not require that a user can login. Files that run the operating system are typically owned by root and are placed by an installation process that requires some form of authentication. Also, the operating system uses other users that run processes beside root. These user usually have their shell set to /bin/false ,cannot login, and may produce files owned by themselves.

To list users on your system and their shell:

dscl . list /Users UserShell

To find files on your system not owned by root or you:

sudo find -x / ! \( -user root -o -user "$(id -un)" \) -exec ls -ld {} +
  • The first command lists (aside from a bunch of /usr/bin/false users): _mbsetupuser /bin/bash, _uucp /usr/sbin/uucico, root /bin/bash, and Rax /bin/bash. – orome Nov 30 '17 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .