Slashdot Mirror


Sudo vs. Root

lessthan0 writes "In Mac OS X, the root account is disabled by default. The first user account created is added to the admin group and that user can use the sudo command to execute other commands as root. The conventional wisdom is that sudo is the most secure way to run root commands, but a closer look reveals a picture that is not so clear." The article is about OSX but the debate is a little older ;)

26 of 327 comments (clear)

  1. Layered Security by Mattygfunk1 · · Score: 4, Informative
    The conventional wisdom is that sudo is the most secure way to run root commands, but a closer look reveals a picture that is not so clear.

    The article doesn't say that sudo isn't the most secure way to run commands, it just details how to make it even more secure.

    1. Re:Layered Security by Jason+Hood · · Score: 5, Insightful

      I honestly feel dumber for RTFA.

      --
      Are you intolerant of intolerant people?
    2. Re:Layered Security by BrianPan · · Score: 4, Funny

      What in the world are you doing reading the articles on Slashdot? Who does that?

  2. Oh, great! by Len+Budney · · Score: 4, Funny

    Now all the black-hats out there will have a powerful new tool in their arsenal! You mean, a sudoer can, like, type "sudo /bin/bash" and then do all sorts of things as root? Pretty irresponsible of him to go telling the world a secret like THAT!

    1. Re:Oh, great! by GoingDown · · Score: 5, Insightful

      When running "sudo rm -rf /" it still asks user's password if that user has not ran sudo before on that same environment. In Ubuntu, only FIRST user account created during installation is able to do sudo by default, rest of the accounts are not in wheel group and are not permitted to sudo. Root account is disabled, it is not "account without a password". So, you need to know password of wheel user to be able to use it.

  3. Sudo is only useful when there are lots of admins by eln · · Score: 5, Insightful

    When there are lots of admins, sudo can be helpful. However, even then it's mostly useless because most admins get so irritated at having to type sudo before every command that they'll just sudo into a shell and be done with it, which sort of eliminates most of the advantages of sudo. To get around this, you'd need a security admin that is not only diligent about what access he gives out, but is also willing to deal with a lot of abuse from the other admins because he won't let them do what they want to do.

    For a single-user system, sudo is pointless. Nearly everyone is just going to sudo into a shell to do anything where root is needed on their own personal box anyway.

  4. This just in: by djh101010 · · Score: 5, Informative

    News flash: Sudo, like many other tools, has a configuration file, which allows you to customize it's behavior. Details will be provided as they become available.

    C'mon, anyone with even a passing involvement with sudo has looked at the sudoers file. You can configure pretty much any group or role based permission you want; if you can describe it as a logical statement, you can do it in sudo. Yes, out of the box, you can sudo to a shell (or to an app which has a shell escape).

  5. Good Advice by Se7enLC · · Score: 5, Interesting

    This article is good advice for anyone running a unix-like operating system (OSX, Linux, etc). It's not knocking on OSX, just knocking on the default configuration. Sudo is really just a way to allow root access without allowing root logins. The best way to configure it: Root Account with a unique password (not the same as your user account) Sudo requires password to activate (caching is ok, but no automatic access, no keys) Sudo logs all commands Sudo only enabled for specific user accounts Root account has login disabled, ftp/ssh disabled. (using the /usr/bin/false trick mentioned in the article, I use true myself)

  6. Sudo vs. Root? by Evro · · Score: 5, Funny
    --
    rooooar
  7. Use sudo to revoke root from a single user by jrifkin · · Score: 5, Insightful
    One advantage of sudo occurs when a box has multiple admins, because a single admin can have his root privilege revoked without affects other admins.

    But when you share a root account, revoking privilege from a single admin means that every remaining admin has to learn a new password.

  8. My favorite sudo command: by AsnFkr · · Score: 4, Funny

    sudo passwd root

  9. The best way to secure the root account... by aurb · · Score: 5, Funny

    ...is to choose a really difficult password and forget it. This will secure the box from its' worst enemy - yourself.

  10. No it's not a mystery by doomy · · Score: 4, Insightful
    Every other command after starting a root shell does NOT get logged at all. All you can tell from this is when someone started the root shell. Whatever happened after that is a mystery.


    All that is in bash history for the root user. And anyone who knows how to clean that can clean the log as well.
    --
    ...free your source and the rest would follow...
  11. Re:Sudo is only useful when there are lots of admi by Joshua+Cowan · · Score: 4, Informative
    most admins get so irritated at having to type sudo before every command that they'll just sudo into a shell and be done with it
    The BOFH patch for Bash works well for this scenario.
    For a single-user system, sudo is pointless.
    It is an effective way to eliminate root logins and encourage least privilege practices.
  12. Re:How To Become Root on OS X by beelsebob · · Score: 4, Informative

    The root account is disabled by having the shadow password set to * - thus you can't enter a valid password for root. If you already are root (as in this case) you don't need to enter a password, and thus it allows you to do the command.

  13. Re:Sudo is only useful when there are lots of admi by Flwyd · · Score: 4, Informative

    I'm the only user on my Linux laptop. My password is dead simple; I'm not worried about security -- the most likely people who might try to do something to my computer are other developers in my company, and they probably have a good reason.

    However, I never run sudo su Why? Being forced to type "sudo" in front of potentially dangerous commands forces me to think a second time and make sure I'm not doing something stupid. If I type rm -r * and get prompted that I don't have access, you bet I'm going to double check to see if I'm in the right directory.

    --
    Ceci n'est pas une signature.
  14. Re:Sudo is a tool not the entire solution by Hieronymus+Howard · · Score: 4, Informative

    4. Allowing non-human users (e.g. www) to execute a strictly limited set of commands as root.

    For example, I have this command in my sudoers file:

    www ALL = NOPASSWD: /sbin/ipfw add 2000 deny ip from [0-9.]* to any in

    This allows apache to use /sbin/ipfw to add the ip addresses of script kiddies to the firewall. Note that only adding addresses to one particular rule (in this case rule 2000) is allowed - any other usage of ipfw will fail.

  15. Here's the Score by 99BottlesOfBeerInMyF · · Score: 4, Interesting

    By default OS X machines use the same password for sudo commands as they do for the regular user account. If you are more concerned about security than the average bear (or OS X user) you can change the password or you can disable sudo altogether and enable the root account with a different password. All of this is good info for those interested in security, but who are still learning.

    From this article I predict a number of people knocking this default setup and then a rehash of the old argument as to what the default should be. I contend, that it is probably the correct default. OS X is a workstation not a server. It is designed for normal users. Having two password (heck having even one) is a usability issue for many users. People are confused by the whole concept of passwords and many have trouble remembering even one. Further, setting a second password only slightly increases the difficulty for a competent cracker. The truth is, there will be local escalations for the foreseeable future. OS X is not a super-locked-down server.

    Basically, for the average user, a second password gains them very little except confusion. For more advanced users, well they can change the defaults, as many do. Maybe the only issue here is the in-between people. Those are the people targeted by this article. Those that might want to change the defaults if they knew about the issue and how to do it. Maybe this configuration should be made a little easier, or even incorporated as an option in the install process.

    This default bears revisiting should Apple ever move to a more locked-down system. Maybe when users are accustomed application specific privileges they should also be introduced to a more layered security scheme. For now, though, I think the usability issue outweighs the security one.

  16. Re:Messed up sudoers by cloudmaster · · Score: 4, Insightful

    In addition to the other comments about using visudo (which respects the EDITOR env. variable, so if you really wanna use pico or whatever, just run "EDITOR=pico visudo"), you should always leave an active shell runnuing when you're editing something that could potentially break login access. Editing the main authentication scheme in pam.d/? Editing sudoers? Changing nsswitch.conf around? Make sure that you already have a root shell open in another terminal - either another xterm, a virtual console, or something else. Save your changes, make sure they worked, and if not, you can usually use the already-open root shell to change it back.

    Yes, this is the voice of experience with breaking just about everything at some point or another - it's how you learn. Well, it's one way *I* learn, anyway. :)

  17. Pretty Tenuous Argument by jinxidoru · · Score: 4, Insightful

    As far as I can figure, his argument all comes down to someone possibly stealing or guessing your password. Doesn't this problem exist with root as well? I love that his solution is to disable sudo and enable remote login on root. He then says that you should only allow public key authentication. So now we are back to the original problem. If someone obtains the password to an authorized account, they now have non-password root access to any server they want. From there, it's not too hard to setup another public key on the root servers that links to an unprivileged account. Now the user cannot just change their password every week for security, they need to go update all of these keychains. No, I'm afraid this author is horribly wrong. If you want to get rid of the problem of using your own password for doing root work, shut down sudo and use su. Do not under any circumstance enable remote login on root.

    In related news, I am so tired of all of these non-news blog entries that keep being put on Slashdot. Give me real news from a reliable source, not some no-name idiot that has no clue what he is talking about. Seriously, we need some sort of blog tag that allows us to immediately identify blog articles and appropriately ignore them.

  18. Phil Collins by Jon+Luckey · · Score: 5, Funny
    Phil Collins probably had fits when this didn't work:

    pcollins$ su su sudio

    --
    -- 3 events that reshaped the world in the 20th century: WW1, WW2, and WWW
  19. Re:Oh, great! (ways around) by HTMLSpinnr · · Score: 4, Insightful
    Ya know, I've always worked around the first two with exclusions, and the -s flag is automagically included.

    Try the following:
    Cmnd_Alias SHUTDOWN = /sbin/shutdown
    Cmnd_Alias HALT = /sbin/halt
    Cmnd_Alias SHELLS = /bin/sh, /bin/bash, /sbin/nologin, /bin/ash, /bin/bsh /bin/ksh, /usr/bin/ksh, /usr/bin/pdksh, /bin/tcsh, /bin/csh, /bin/zsh
    Cmnd_Alias SU = /usr/bin/su, /bin/su, /usr/sbin/visudo
     
    %usergroup ALL=(ALL) ALL,!SHELLS,!SU,!SHUTDOWN,!HALT
    However, that's not going to stop joe user from copying bash over to /usr/local/bin/myshell and still gaining root that way. A better approach is to permit specifics and allow for an implicit deny rather than explicitly permitting all and denying specifics. There are times though when it's a giant PITA to permit just about everything specific under the sun because there's always going to be one command you've left out here or there. At that point, you just have to trust your users enough to know better and then take steps to secure the machine from the outside world.
    --
    $ man woman *
    -bash: /usr/bin/man: Argument list too long
  20. Sudo insecure if same account used for email by adrenaline_junky · · Score: 4, Insightful

    The most insecure thing about sudo that I see occurring frequently is that a person with an account that has sudo access uses the SAME account for unencrypted email.

    So basically their password gets sent openly when they login via POP to check their email. Anyone with a sniffer can get their password, login, and have full sudo access.

    Now that's great security for ya.

    That's why when I install a distro like Ubuntu that defaults to using sudo I always make the first account a dedicated admin account. Which sort of raises the question of why not just use "root" in the first place...

  21. Re:2 passwords instead of 1 by asuffield · · Score: 4, Insightful

    Actually, you missed the point of why sudo only asks for the user password. And so did the author of that web page (which is why he's wrong).

    Firstly, asking for a root password has no effect on the security of the system. A cracker does not have to crack an extra password. Once your user account has been cracked, if you know the root password and use su (or sudo or whatever), then at some point you are going to login and do that. Unfortunately, the cracker knows your user password - your .bashrc was replaced, the shell you are running is a trojan. The password that you typed in was captured, and the cracker now knows the root password. In fact, it probably just used that password to launch a rootkit.

    This can be solved, with some form of secured authentication path (like a smartcard device, which can't be trojaned using the user's password, and there are also ways to do this without needing extra hardware). sudo supports stuff like that, if you know what you're doing. But simply asking for a second password, in an application running in the terminal, is no more than a speed bump. It's not the second layer of security that it looks like it should be. Anything you type into the terminal is compromised once an attacker has your user password.

    Secondly, shared passwords are bad security. You can't easily change them - it has to be arranged between several people. You have to pass the secret between at least two people on at least one occasion, and somebody else can overhear when you do that. People tend to be less careful about information that is known to several people. If the secret leaks out, there's no easy way to trace who leaked it. There's all sorts of issues with shared passwords. If you really wanted a second password, you should have one 'root' password for every user who has root access (Kerberos systems allow for this scenario, because a Kerberos environment can have secure authentication paths; sudo and su don't, although you could have one 'login' password and one 'sudo' password by creative use of PAM, but you have to tackle the authentication path issue first).

    Thirdly, the point of sudo asking for the user password is to authenticate that the user currently sitting in front of the computer is the same user that logged in at some point in the past. Users are forgetful; they walk away from their console to get coffee without locking it. sudo attempts to verify that the user currently sitting there is probably the right one, and not somebody else who snuck into their office. If you have sudo ask for a single shared root password, then one of the other users with root access could use somebody else's account, and would appear in the logs as that user. That means they deflect blame for their actions onto somebody else. If you really wanted to have a second password with a shared root password, you should ask for both the user and the root password.

    You could argue that a user with root access can always just clean the logs afterwards - but this is not necessarily true. A system can be configured so that syslog immediately sends every message over the network to another host. sudo deliberately sends the message to syslog before running the command, so that this scenario remains secure. The user could immediately disable this configuration, but they can't stop that first message from going out, saying who they are and when they logged in. (We will assume that this scenario involves ssh access to a server located in a locked datacentre, so there is no opportunity to interfere with the physical network connection).

    sudo's way of doing things really does have security advantages. It may be true that these advantages aren't relevant to the default macosx configuration, but that does not mean they don't exist. However, using a single root password, like the article author suggests, does not have security advantages over the default behaviour (see the first point in this post). And the default behaviour is more convinient for users (who only have to remember one password instead of two), which is almost certainly why Apple set it up that way. The article ignored this aspect.

  22. Re:How To Become Root on OS X by ScriptedReplay · · Score: 4, Interesting

    The root account is disabled by having the shadow password set to * - thus you can't enter a valid password for root.

    Why people keep on confusing this?

    Password login to the root account is disabled by having the shadow password set to * - thus you can't enter a valid password for root. Just because password logins are disabled does not mean the account is disabled — try ps -U root -u root u sometime. Besides, 'root' is just one name for uid=0, change your user's uid to 0 and bam! you're it, whatever name you have (but then if you can change your uid you're it already, this was just an academic example)

    Also, if your login relies on other methods than pam_unix then the star in /etc/shadow is meaningless. So in fact it should be further qualified as password login to root relying on /etc/shadow is disabled... The point being that 'root account is disabled' is hugely misleading.

  23. Re:MUCH MUCH Much better solution by TheCarp · · Score: 5, Insightful

    I would argue that this is even not needed.

    Just pick a good damned password.

    Seriously. Nobody really cracks passwords anymore. Sure there are the ubiquitous SSH scans on the net looking for just insanely stupid passwords. Pick a good password and move on.

    Firstly... any security discussion that starts with "what if they have your password" is flawed. They shouldn't have your password, if you let it go, or its THAT easy to guess.... then your security is broken right from the start and there is nothing you can do YOU ARE FUCKED.

    I worked at a place that did sudo for root passwords, and I thought it was one of the god damned stupidest things ever. The ONLY benefit of it, was that it forced us to figure out how to make secure passwords for root that people could easily memorize and taught us all to use mnemonics. That was seriously the ONLY benefit.

    Basically if you log in locally, or use ssh for everything, then your password never goes out in clear text. If you worry about ssh, then fine... use key authentication, then your password never gets used for anything but sudo.

    Basically.... this is a totally fake issue. If someone has your user account password, you are just screwed. They can trojan your entire environment such that the chances that you will EVER notice is minimal, and then they will just get the root password the very next time you sudo.

    Bottom line... protect your password... your security depends on it.

    -Steve

    --
    "I opened my eyes, and everything went dark again"