mirror of
https://github.com/usnistgov/macos_security.git
synced 2026-02-03 05:53:24 +00:00
rules/os/os_root_disable does more than prevent root login- it breaks functionality (and isn't actually needed) #14
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lattwood on GitHub.
Summary
rules/os/os_root_disable.yamlsets the root shell to/usr/bin/false(or/sbin/nologinif #591 is merged).sudo -iand forces users to take an unsafe approach ofsudo $SHELLrootdisabled in Directory ServicesDetails
Changing the shell to prevent login breaks
sudo -i, which is used for getting a root shell safely. Without using-i, you have to runsudo zsh, which meansHOMEand other environment variables are inherited from the current user. This sets them up to accidentally create files owned byrootin their actual home directory, and to that end,zshcomplaints about ownership ofcompinitfiles in the home directory when started this way.It turns out that Apple actually disables root login OOTB (at least on Tahoe).
There is a shell utility (that requires a password when run by anyone other than root)- https://ss64.com/mac/dsenableroot.html.
That program properly enables and disables the root account in Directory Services. Based on the implementation of that program, here are the correct steps for disabling and enabling the root account- which doesn't require touching root's shell.
Steps to disable root
Note: this is the default state of the operating system, and they're prefixed with
sudofor completeness.Steps to enable root
Note: this is overly verbose, you may only need to set a password at the cli through dscl, and the commands are prefixed with
sudofor completeness.Steps to reproduce
Apply
rules/os/os_root_disable.Operating System version
Tahoe
Intel or Apple Silicon
Apple Silicon
What is the current bug behavior?
root's shell gets set to/bin/false.It also appears this rule's fix/check was copied from a 2017 blog post- https://derflounder.wordpress.com/2017/03/19/disabling-login-to-the-root-account-by-changing-the-root-accounts-user-shell/ and doesn't adhere to Apple's own documentation here- https://support.apple.com/en-ca/102367 (this indicates on a machine w/o
rules/os/os_root_disableapplied, that root is disabled, and root's shell is still set to/bin/sh, indicating that changing root's shell is not a supported method to disable the Root User. Search results of Apple's public Support site also agrees with this- https://www.google.com/search?q=%22disable+root%22+site%3Asupport.apple.comWhat is the expected correct behavior?
rootshould be verified as disabled via the use ofdsclcommands checkingAuthenticationAuthorityandPassword, and disabled if needed by usingdsclto set thePasswordto the "account disabled marker" of*and removing theAuthenticationAuthoritykey.