Operating System - HP-UX
1819763 Members
3215 Online
109606 Solutions
New Discussion юеВ

Re: sudo su - root - What AM I Missing Here?

 
SOLVED
Go to solution
Michael Steele_2
Honored Contributor

sudo su - root - What AM I Missing Here?

Happy JETS, STEELERS, PACKERS and BEARS fans.

Regarding the above and the reasoning behind its elimination, I mean, how anal do you have to be? Or am I missing the whole tamale?

Issue: With the "...su - root..." command a password is required.

With the "...sudo su - root..." command no password is required when: a) After the user has provided the root password once, and b) The user is within his 5 minute timeout period. (* Or 10 minute time out or 15 minute or whatever *).

Am I missing the problem here or is the issue the timeout period?

The problem as I see it: When the user walks away from his / her desk (* and violates the rule about locking up his /her work station when he /she walks away *), the keyboard is left unattended while :

a) the sudo user is within his timeout period,
b) thereby not requiring the root password.

What other conditions need to be true for this command to be valid?

Comments? Because the level of analness is really getting - UMMPH - tight, and I'm sure that I'm missing something from all of these people WHO HAVE NEVER LOGGED INTO UNIX IN THEIR LIVES.
Support Fatherhood - Stop Family Law
11 REPLIES 11
RickT_1
Valued Contributor

Re: sudo su - root - What AM I Missing Here?

Michael,

I think you are being told that because of security reasons you need to get rid of SUDO and go to SU. First of all the users should only have to give their own password to get access to a limited root. That is the primary reason behind SUDO is control of what root functions are available. SU - root gives all access and you have the same security problem if they su to root and don't lock their computer. I hope this gives you some ideas and helps.

Rick
Michael Steele_2
Honored Contributor

Re: sudo su - root - What AM I Missing Here?

I don't have a test box up for this right now so here's the question rephrased again.

If a sudo user invokes 'sudo su - root' for the first time then he / she types in his own password and has access to root, thereby bypassing the root password?

YES / NO?
QUESTION: Correct description of the Sudo problem?

If the same sudo user invokes 'sudo su - root' within his timeout period (* 2nd time or greater *) then he goes straight to root without entering either his password or roots?

YES / NO?
QUESTION: Same as above.
Support Fatherhood - Stop Family Law
Patrick Wallek
Honored Contributor

Re: sudo su - root - What AM I Missing Here?

Michael,

The answer to both of your questions is 'Yes'.

If the user walks away and does not lock his/her workstation, and someone comes up and does 'sudo su - root' (or sudo su -), then yes there is a possibility they could immediately gain root access.

Is it a big risk? The answer could vary from one organization to the next.
RickT_1
Valued Contributor

Re: sudo su - root - What AM I Missing Here?

The answer to your first question is YES, however, the user would have to be built into the configuration file to have any access at all. If that user is built into the system then yes they will be root for the functions they were assigned in the file.

I'm still checking on the second question.

Rick
Doug O'Leary
Honored Contributor
Solution

Re: sudo su - root - What AM I Missing Here?

Hey;

I'm not sure I'm understanding the question. Are you being told that you have to get rid of the sudo capability?

If that's the case: while I wouldn't argue for its elimination, I do argue that there's a better way to gain root privileges through ssh/public key authentication.

One of the big issues with it is it's password authentication - 1 factor. The objective, theoretically, is to get the admin to authenticate twice - once when he logs in and again when he su's to root.

The problem with that approach is that it's the same password both times. If a bad guy has an admin's password, he has root through this approach.

I go through that reason and others in a document that argumes for ssh/pka over sudo/su approach to root privileges available at http://www.olearycomputers.com/ll/sudo_v_ssh-pka.html

One of the bigger *advantages* to this approach is that not everyone has to have the root password.

One of the bigger disadvantages to *not* using sudo and not having ssh/pka access is that everyone suddenly needs to know the root password. If/when you have to change it, password dissemination becomes an issue.

While the ssh/pka approach is better, it's certainly not an either/or thing. If your keys file gets blasted or the root account gets locked, it's good to have an alternative route to root privileges.

Hopefully that didn't take us off on a tangent.

Doug O'Leary

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
Patrick Wallek
Honored Contributor

Re: sudo su - root - What AM I Missing Here?

If part of the concern is the password timeout period within sudo you could disable that.

Adding the following line to your sudoers file:

Defaults timestamp_timeout=0

will force a user to enter their password every time they run sudo.
ManojK_1
Valued Contributor

Re: sudo su - root - What AM I Missing Here?

Hi Patrick Wallek,

Thanks for your solution. I was looking for this and it is working perfectly.

Hi Michael,
I think you got the solution what you are looking for.

Please assign full points to Patrick.

Manoj K
Thanks and Regards,
Manoj K
Matti_Kurkela
Honored Contributor

Re: sudo su - root - What AM I Missing Here?

The usual reason to implement sudo is that there is a requirement to have a reliable record of who-did-what for privileged accounts. In those cases, "looks like root did it" is not going to be an acceptable answer: the expected answer is more like "This log proves beyond reasonable doubt that at 14:30 yesterday, Joe Bloggs the junior sysadmin used his root privileges to make this change."

The problem of "sudo su -" is mostly related to logging, and it is three-fold:

1.)
When a user is allowed to run a shell as root, only the fact that a shell is started is logged - not the commands entered within the shell.

One possible solution is to forbid running a shell through sudo. The solution is not ergonomically optimal, and may be hated by sysadmins; but although sysadmins may not like it, they can live with it if necessary.

Using the shell's history file as a log is not a good solution: the history file is not designed as a secure log. It must be writeable by the user whose actions it records, so the user can always overwrite it to hide his/her actions.

Alternative solutions are to use the audit logging functionality of the OS, or a session recorder like sudosh/rootsh. For root access, these should be paired with some mechanism that transmits the log events to another secure system, because root can typically undo or side-step any purely local security measures.

2.)
"sudo su -" in particularly troublesome, because it causes two log lines to be recorded.

The first log line will be written by sudo, and it tells that the user executed sudo to run the command "su -" as expected. The second line will be recorded by su, and in some OS versions it will tell you that it was invoked by root to become root. That is not very useful. If two users do it simultaneously enough, the log lines will get entwined together and it will be hard to track which line belongs to which session. Granted, you can usually use the TTY field in both sudo's and su's messages to sort it out - but if the commands are run in a context that has no TTY (e.g. cron jobs), your log might be ambiguous. For legally-mandated audit requirements, this is a bad thing.

For most practical purposes, "sudo -H -i" does exactly the same thing as "sudo su -": the only significant difference is the four $SUDO_* variables sudo adds to the environment to indicate sudo was used. But it has the added property of producing one clear and easily processible log line telling exactly what was done. If you're implementing something like HIDS to automatically screen your log files for signs of intrusion, this makes the log analysis rules easier to write.

If you set "Defaults set_home" in sudoers, you can shorten the command to "sudo -i", so you don't even have the excuse of "But it's easier to type sudo su -".

3.)
When a system is configured to run applications using dedicated application accounts rather than the root account, the requirement to access those specific accounts will usually be more common than the need to do thing using the root account. Commonly, this is done using a command like "sudo su - appuser".

In my opinion, "sudo su - appuser" indicates persistent refusal to learn new things. To allow this, you need to grant the user root access for the purpose of running "su - appuser" as root:

joeuser ALL=(root) su - appuser

This is excessive, for sudo could do the entire job in one step, using this syntax:

sudo -H -u appuser -i

If the latter sudo syntax is used, the sudoers file line can be more straightforward to understand:

joeuser ALL=(appuser) ALL

The auditor needs only take one look at it to see "Joe User is authorized to run commands as appuser, but has no root access."

If "sudo -H -u appuser -i" is too long to type, shell aliases or scripts can easily remedy that.

MK

MK
MK
Zinky
Honored Contributor

Re: sudo su - root - What AM I Missing Here?

Go JETS!

"sudo su - " - will require no password IF sudo is config'd accordingly. "su -" will always ask for a password period.

If sudoers is not set up for passwordless access and he/she was sudoed and eventually times out and returns to his/her prompt -- and someone "sudo su -" again - and it is within the timeout period - it will NOT require a password.

What is the issue?
Surely the WIndows Desktop policy (if admins are using windows) are also set and not modifiable to do a screen lock.

Most corporates these days however forbid "sudo su -" for admin full root interactivity. What I see as a trend is a combination of SUDO + AT&T Enhanced Korn shell where all commands by a user are logged locally and to a centrralised log server.

Additionally - the POI (point of interaction/intrusion) - which is that Windows or Linux Desktop has a utility where all Keyboard activity is captured. A product called Encentuate (now a Big Blue product?) is increasingly becoming a standard for most corporates and secure computing facilities.

Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
Michael Steele_2
Honored Contributor

Re: sudo su - root - What AM I Missing Here?

Wow - lots of points to award here. In fact, there's so much on target good stuff that 10 points each in most cases isn't enough for the comments posted.

Doug O'Leary of olearycomputers.com.
a) Is that you?
b) Great URL and article in my opinion. Especially the comments about capturing remotely executed root commands from one server to another by activating,

SyslogFacility VERBOSE
LogLevel VERBOSE

... sshd_config.

This actually hits another ongoing concern here where I work. Mgmt wants to do away with remote root logins via ssh. So this is very helpful.

RickT
If we werenтАЩt using a curve youтАЩd get a 10 for both instead of a 9.

Pat
Same for Rick but 8тАЩs.

Manjo
No help тАУ 1 pointer

Matt K
Always, always you give good stuff as you did in this response. But ALL need to read DougтАЩs URL which is a very insightful argument.

http://www.olearycomputers.com/ll/sudo_v_ssh-pka.html

1). two log lines to be recorded, sudo -i
2) On target
3) sudo -H -u appuser тАУI тАУ On target

Alzhy
You are all over this project and implementing all sorts of sudo and su тАУ stuff.
Support Fatherhood - Stop Family Law
Doug O'Leary
Honored Contributor

Re: sudo su - root - What AM I Missing Here?

Hey;

Doug O'Leary of olearycomputers.com.
a) Is that you?

That would be me :)

b) Great URL and article in my opinion. Especially the comments about capturing remotely executed root commands from one server to another by activating,

Glad you liked it. It was a lot of work and quite a bit of research, but my client's now using ssh/pka as the preferred method of root access with sudo/su being an acceptable alternative.

Thanks for the feedback.

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html