How to disable or remove the root account created as a side effect from this High Sierra security bug

bughigh sierraSecurity

This article describes a bug where entering root when prompted for an unlock allows any user to unlock system preferences. It warns that:

There’s no need to do this yourself to verify it. Doing so creates a
“root” account that others may be able to take advantage of if you
don’t disable it.

The article does not describe what to do if an over-eager engineer reproduced the problem and now needs to remove or disable the root account.

How can this account be safely disabled or removed?

This Apple page describes how to disable the account but this does doesn't protect against the fault because the fault can just re-enable the account. It will work to restore the system to its normal state with root disabled once the security bug is fixed.

Update 2017-11-29 16:43 UTC

See About the security content of Security Update 2017-001 to update macOS High Sierra to protect from bypassing administrator authentication without supplying the administrator’s password.

Best Answer

Patch available, click here, or just update on the machine

Interestingly enough there is no patch for the beta and developer versions of OSX yet as far as I know. I'll update this answer as soon as I hear of them.

Download the patch above. Leaving the rest of the post for history :-)

The CVE is CVE-2017-13872 and NIST will update the analysis in the near future.

Original answer, relevant without patch

First off, do not disable the root account via the GUI, having a "disabled" root account is the cause of the problem.

You shall enable the root user and give it a password. This is important, since the vulnerability is available remotely as well, via VNC and Apple Remote Desktop (to name a few)(another source).

There are two basic ways to do this; GUI and terminal.

First off, GUI

To enable the root account, go to "Directory Utility", ie cmd + space and search. Press the lock to unlock "admin mode", then enable the root account through edit -> "Enable Root User".

How to enable root

It should ask for a root password, for now enter your normal password (so you don't forget it). If it doesn't ask for a password, use Edit -> "Change Root Password..." above.

Terminal

If you are more of a terminal person, use the below:

sudo passwd -u root
## Enter passwords as needed.... 
## (if you are using the terminal you should know what you are doing...)

This is enough with a terminal, the problem with the GUI way is that we have to enable the account to set a password, which we don't have to with the terminal.

Notes

Even if you have a password set for the root account your computer it will become vulnerable if you disable the root account. The action of disabling the root account seems to be the culprit. So I repeat, the root user should be enabled and have a password if using the GUI, whilst via terminal only using ´passwd´ is "ok" (although this state is unreachable via only the GUI). It seems that the "Disable Root User" in "Directory Utility" removes the password for the root account, in a sense giving you a password-less root account which is vulnerable.

It seems like trying to log in with "root" in a systems login-window enables the root account if it is disabled previously. Ie with a disabled root account you need to enter root twice in a systems login-windows to gain root access, and (according to my testing) on the first try the root account is enabled (with no password if not set via passwd), and on the second try you go through.

It seems that the issue has been in the open since at least 2017-11-13 (13th of November), when it is mentioned in the Apple support forum.

Please prove me wrong, I would really appreciate to be wrong right now.

Scary update

After enabling the passwordless root account (i.e. through the system preferences panel and clicking a "lock" and entering "root" with blank password one, two or three times (number of times depends on initial state)) it is possible to log on to the computer from the main login screen using "root" and a blank password (!). SSH / Telnet does not seem to work, but Apple Remote Desktop, Screen Sharing and VNC are vulnerable.

So for networks admins it might be of interest to temporarily drop packets to the following ports:

  • 5900-5905(ish, to be ninja safe) to get the most common VNC ports. VNC starts at 5900 by default and enumerates upwards if you are using multiple displays (uncommon though). Screen Sharing and Apple Remote Desktop also seems to use these ports (list of Apple software ports)
  • 3283 and 5988 for Apple Remote Desktop (list of Apple software ports)

Additional reading:

A valiant attempt to reference other sources dealing with the issue. Do edit and update my answer if you have more.