LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   how come sudo doesnt make it so anybody can become root? (https://www.linuxquestions.org/questions/linux-security-4/how-come-sudo-doesnt-make-it-so-anybody-can-become-root-760679/)

smeezekitty 10-08-2009 09:28 PM

how come sudo doesnt make it so anybody can become root?
 
if you type sudo bash even a reguler user becomes root
its not a problem because i dont use the multiuser system
but doesnt this defeat the privledge system?

FragInHell 10-08-2009 10:50 PM

Hi Sudo isn't really about becoming root, since once a user uses sudo su - or sudo bash they can do whatever they like and from a system auditing point of view it becomes hard to track down what that user does.
Sudo is designed to give normal users elevated permissions. Exmaple, lets say we have a helpdesk, they need to be able to start and stop apache, under normal conditions they cannot, but we can grant them permission just to run the commands they need to do this task. That way apache is still run as root but the commands are locked down to only those specified by the admin. Good news for the admin as well, now he doesn't get called every time the helpdesk can now do it.
You can create groups of system, users and commands to give better control.
There's more to it of course but thats the basics.

David the H. 10-08-2009 11:33 PM

On most distributions regular users aren't given the flexibility to run whatever they want. sudo is only there so that the administrator can give them the ability to run specific commands under specific conditions, and only after being explicitly configured to allow it. You can't use sudo to run things like bash unless the administrator lets you.

However the developers of Ubuntu and its relatives have decided to use sudo in a different way. It's their belief that users switching to a root console and then leaving it open for protracted periods of time is a bigger overall security risk than simply giving them the ability to administer the entire system with sudo as needed. The fact that you can use it to switch into root isn't the issue for them; they just think it's better to not need to do it.

It's basically a risk trade-off, with different people having different views on what's most important security-wise.

smeezekitty 10-09-2009 12:01 AM

i am not concerned on security and thats part of the reason i dont lie Ubuntu
i just thought sudo was a security hole

anomie 10-09-2009 12:04 AM

I'm an Ubuntu novice, but IIRC after a 9.04 installation, only the account that I created at install time was a full sudoer. I added accounts post-installation, and they were not automatically made sudoers.

The implication to me is that they (Ubuntu team) expect that the initial account will be acting as admin as well.

Wim Sturkenboom 10-09-2009 12:14 AM

Quote:

Originally Posted by smeezekitty (Post 3713054)
i am not concerned on security and thats part of the reason i dont lie Ubuntu
i just thought sudo was a security hole

So you are the actual security hole

avijitp 10-09-2009 12:20 AM

You can always set sudo to behave the way you want it to. You need to configure it.

smeezekitty 10-09-2009 05:49 PM

configurable? neat

David the H. 10-09-2009 10:12 PM

Configurable?

That's what we've been saying from the beginning. Sudo is simply a way for the root user to give other user's permission to run certain commands with elevated permissions, so it certainly is configurable. Highly configurable. In Ubuntu they've simply configured it by default to give the first user complete access to the system (as well as simultaneously disabling the root password), but there's no reason you can't reconfigure it to include or exclude whatever commands and users you want, or even if they need to use passwords or not.

It's all up to what you put in the /etc/sudoers file. Check out the man pages for sudo, sudoers, visudo, and the copious information on the net about it.

avijitp 10-10-2009 03:07 AM

Perhaps, you should be using "visudo" to edit the sudo configurations. Check man pages for quick reference. There are plenty of good guides available in the Google.

Hangdog42 10-10-2009 07:25 AM

Quote:

Originally Posted by anomie (Post 3713056)
I'm an Ubuntu novice, but IIRC after a 9.04 installation, only the account that I created at install time was a full sudoer. I added accounts post-installation, and they were not automatically made sudoers.

The implication to me is that they (Ubuntu team) expect that the initial account will be acting as admin as well.


I wish the *buntus would stop this and just use root and sudo the way they were intended. Sooner or later this sort of behavior is going to cause a huge security breach in the *buntus.

abefroman 10-13-2009 08:49 PM

You should be able to vi /etc/sudoers as well.

Wim Sturkenboom 10-13-2009 10:02 PM

@abefroman
You might already know this, but
Quote:

visudo edits the sudoers file in a safe fashion, analogous to vipw(8). visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors. If the sudoers file is currently being edited you will receive a message to try again later.
From man visudo

abefroman 10-13-2009 10:05 PM

Quote:

Originally Posted by Wim Sturkenboom (Post 3718339)
@abefroman
You might already know this, but

From man visudo

Thanks, and yes, I knew about visudo, never use it though.

avijitp 10-14-2009 07:42 AM

visudo often helps to eliminate some common mistakes that users make while creating sudo rules. It is always advisable to use it. The most adorable feature that I liked about visudo is that it will always tell you about a wrong rule when you want to save and come out of the vi editor.

jayjwa 10-16-2009 03:01 AM

Quote:

Originally Posted by Hangdog42 (Post 3714485)
I wish the *buntus would stop this and just use root and sudo the way they were intended. Sooner or later this sort of behavior is going to cause a huge security breach in the *buntus.

Agreed. We now have an entire generation of Linux users who want to stick sudo in front of everything they need to do as root, which is not what sudo was meant for. It's meant to delegate specific tasks to specific users using specific parameters, not as an "are you really sure you want to do that as root? If so, prefix with 'sudo' so I know"-type safety switch. I say we start a proper sudo usage compaign: it can be called "su-don't".

r3sistance 10-16-2009 02:59 PM

Quote:

Originally Posted by Wim Sturkenboom (Post 3713065)
So you are the actual security hole

Bit harsh I guess =P, unfortantly true. I have never really liked the way the *Buntus work to be honest tho, it's a complete abuse of sudo and it doesn't really encourage security like it's suppose to, infact possibly just makes the situtation worse in some cases.

If you wanna make a safe distributions, how about one that warns a user every time they use an unencrypted protocol (IE FTP, VNC) across the internet that other people maybe able to view their username and password.

Also ubuntu doesn't encourage things like locking down /tmp in ways that reduce the number of rootkit vunabilities you have...

I am curious with Ubuntu, what happens if you need to run a manual FSCK and it requires the maintainance password... is that the initial user password? or does this lead to a whole different level of headaches. Or worse yet, does it let just anybody into the maintainance terminal =P?

But as it goes, user apathy to server security/protection is my number 1 reason why servers get hacked (any OS). While direct logins as root and browsing the internet as root are on the list of insanely crazy things to do, most OSs disable or warn about GUI root logins and SSHD is easily configurable to disable direct root logins... but leave the benefit of "SU" and/or console root logins can be in my opinion beneficial and just easier...

Hangdog42 10-17-2009 07:49 AM

Quote:

If you wanna make a safe distributions, how about one that warns a user every time they use an unencrypted protocol (IE FTP, VNC) across the internet that other people maybe able to view their username and password.
I wish it were that easy. As Microsoft has THOROUGHLY proven, bugging the user about insecure behavior is futile at best. Unfortunately there is no OS level solution to user ignorance and apathy. What is equally disturbing is the number of users who feel they need to be root ALL THE TIME. I don't know about anyone else, but once I've got all my software installed, I can go weeks without needing to be root. The bottom line is we need smarter users, and that isn't gonna happen anytime soon.

Quote:

I am curious with Ubuntu, what happens if you need to run a manual FSCK and it requires the maintainance password... is that the initial user password? or does this lead to a whole different level of headaches. Or worse yet, does it let just anybody into the maintainance terminal =P?
My understanding is that the *buntus give root privileges to the first user that is created via sudo. So technically they aren't root, but effectively they are just by using sudo in front of the command. In your example, running sudo fsck and supplying the initial user's password should do the trick. Later users aren't awarded this privilege by default, but on a single user machine, the damage is done. I'm just waiting for malware to appear that simply uses sudo to escalate on *buntu installs.

Quote:

SSHD is easily configurable to disable direct root logins.
Now if distros would just ship with root disabled in SSHD. I bet there are tons of users that don't even know SSHD is running, let alone that you can log in using root. I suppose this is one area where the *buntu approach actually has a benefit. Since there isn't a root account you can log into (unless you activate it), it doesn't matter if sshd allows root login.

pixellany 10-17-2009 08:06 AM

This thread is perhaps past its prime, but my buttons have been pushed....;)

I had a chat with a Ubuntu rep at the last SCALE. He was arguing that their no-root-user weirdness was actually a plus for security. I don't remember what the rationale was, but I was not impressed. Since then, I have read about people being disciplined on the Ubuntu fora for divulging the "secret" to enabling the root account. Bad dog, Ubuntu---BAD Dog!!

As for "sudo bash" creating a security hole, consider some other security holes:
  • You can typically reboot into a machine in single-user mode and get root powers with no password.
  • If that doesn't work, you can boot from a liveCD and disable the password in the installed system.
  • CD booting disabled and the BIOS password-protected? Open the case, and reset the CMOS.

If you want real security, you have to control who has physical and network access to the hardware.

unSpawn 10-17-2009 08:40 AM

Quote:

Originally Posted by pixellany (Post 3722695)
Since then, I have read about people being disciplined on the Ubuntu fora for divulging the "secret" to enabling the root account.

You're probably referring to http://ubuntuforums.org/showthread.php?t=716201. I think users should respect how a distribution envisions it to be used. Especially if they're new to GNU/Linux it could be beneficial. More experienced users or users not wanting to do that could easily switch to another distribution with different rules of play, better suitable release schedules, social contract or not, herd-like behaving usergroups, SPOF maintainers or whatever else unique selling points they favour.

However in no way should the uninformed actions of an OP who clearly does all the right stuff for all the wrong reasons be left unchallenged.

pixellany 10-17-2009 08:51 AM

I can see your logic, but let's try a loose analogy:
Suppose I check in to the ArchLinux forum and post something on how to disable pacman and set up Arch with Synaptic.....Or maybe how to get rid of rc.conf and replace it with something more "normal". Will I get disciplined or ejected from the forum? I think not.

Carrying it further: Suppose I posted instructions on how to set up Arch to be like Ubuntu? They are still not going to punish me. LAUGH AT ME--perhaps.

I'm obviously in the camp that NO-ONE should be practicing thought control.

AND--look at Mint: They don't bother just **telling** you how to have a root account---they put it in the installer as an option.

pixellany 10-17-2009 08:58 AM

Another slightly more obscure analogy:

Circa 1970, I pull the 2-speed Powerglide out of my Chevy Impala, and replace it with a 3-speed hydramatic. Off to the dealer to get the right speedometer gears.

Tell dealer person what I have done. Answer: "You can't do that."

Showing him the actual car in which I had successfully driven to his establishment did not seem to make an impression.....


Moral: The world is full of people who are quite willing to decide how you **should** do something, but there is only ONE person who **should** be making the decision. I want Ubuntu to advise me, not to dictate.

r3sistance 10-17-2009 10:31 AM

To be honest what put me off of Ubuntu was it's inability to actually work on any system I put it on, it's probably more compatible by now but when I place it on my state of the art white boxes I just use to get so many graphical glitches and compatibility issues it wasn't worth it. Now I just use CentOS since I am use to dealing with it so much as it's the mode OS used in the data center that I work in. Also I rarely get graphical problems with CentOS...

But as for Ubuntu's Security, naturally as I never got on with it, it wasn't til I came across servers that used it that I found out just how annoying the whole distribution actually is when you ignore the putrid orange interfaces... The whole not allowing logins as root is something I just by-pass in 10 seconds if I do have to use it for some reason, I am after all in my line of work, use to having to by-pass people securing themselves so well they secure themselves out of their own servers.

smeezekitty 10-17-2009 12:13 PM

this is whyy i dislike Ubuntu


Quote:

Originally Posted by pixellany (Post 3722695)
  • You can typically reboot into a machine in single-user mode and get root powers with no password.
  • If that doesn't work, you can boot from a liveCD and disable the password in the installed system.
  • CD booting disabled and the BIOS password-protected? Open the case, and reset the CMOS.

you cannot do any of this over a network so its of no concern to me and alot of other users

jschiwal 10-17-2009 12:23 PM

The main advantage of sudo allow certain users and administrators to run root commands without needing to distribute the root password. You can temporarily give someone permission to run sudo and then remove this privilege later.

Also look at using PolicyKit for the types of things that regular users may commonly need to do. For example, there may be a setting to allow a user install updates. This would allow a user click OK in the updater applet without then needing to enter the root password. Or perhaps allow the user to change the pulse audio setting to high priority.

It can be difficult totally eliminating holes in using sudo. Such as using rvim; forbidding "sudo su -"; using a different mail server without an escape character, etc. It may be combined with kernel auditing to audit all root commands. IMO, this is more likely the case for servers where an inflexible policy is more useful.

The only difficulty I would have with Ubuntu is using redirection is more difficult. The > and < operators manipulate files with the privileges of the "sudo" command not the command you are running.

r3sistance 10-18-2009 06:19 AM

Quote:

Originally Posted by unSpawn (Post 3722714)
I think users should respect how a distribution envisions it to be used. Especially if they're new to GNU/Linux it could be beneficial.

Something suddenly occured to me on this statement, if you say that users should respect how the developers envisioned them to use Ubuntu, could the same also not be said that Ubuntu should respect how the developers of Sudo envisioned it to be used, as Ubuntu uses it as a near enough full swap out for root, what Sudo was never meant to do, SU was already there for that purpose.

unSpawn 10-18-2009 10:35 AM

Quote:

Originally Posted by pixellany (Post 3722722)
I can see your logic, but let's try a loose analogy:
Suppose I check in to the ArchLinux forum and post something on how to disable pacman and set up Arch with Synaptic.....Or maybe how to get rid of rc.conf and replace it with something more "normal". Will I get disciplined or ejected from the forum? I think not.

Carrying it further: Suppose I posted instructions on how to set up Arch to be like Ubuntu? They are still not going to punish me. LAUGH AT ME--perhaps.

I'm obviously in the camp that NO-ONE should be practicing thought control.

And I'm of the opinion that all people require thought control. Except some people require more thought control than others ;-p Seriously, from your reply I get the idea you're more opposed to how this distribution advertises usage than anything else. And as far as I know you don't even use .*buntu, right?


Quote:

Originally Posted by r3sistance (Post 3723656)
Something suddenly occured to me on this statement, if you say that users should respect how the developers envisioned them to use Ubuntu, could the same also not be said that Ubuntu should respect how the developers of Sudo envisioned it to be used,

I think that would hold true if Sudo came with explicit usage instructions. AFAIK it does not. (I do get what you mean though.)


Quote:

Originally Posted by r3sistance (Post 3723656)
as Ubuntu uses it as a near enough full swap out for root, what Sudo was never meant to do

I think jschiwal's post #25 explains that.

smeezekitty 10-18-2009 12:43 PM

Ubuntus horrable prompts remind me of windows vistas UAC
that i disabled the first day
i feel restricted in ubuntu so i do not use it
and i feel i have to warn other people about it

Quakeboy02 10-18-2009 02:09 PM

This is an interesting thread. I very rarely login to root; preferring to do almost all maintenance activity with sudo. For me this works because I don't really do that much maintenance activity, and "command not found" or "must be root" (whatever the actual messages are) are enough to remind me to use sudo. This is good, because I don't accidentally do the infamous "rm -rf /". :)

Does it make my system less secure having "myuserid ALL=(ALL) ALL"? Probably. But, I don't have any open ports, so the risk is small on a home-user desktop. I can see that in a larger installation, or on a web-open install, I might want to set aside different sudo users for different maintenance activities; even if there was only just me. I'm not convinced that logging in to root is the right option, though.

smeezekitty 10-18-2009 02:22 PM

Quote:

Originally Posted by Quakeboy02 (Post 3724014)
This is an interesting thread. I very rarely login to root; preferring to do almost all maintenance activity with sudo. For me this works because I don't really do that much maintenance activity, and "command not found" or "must be root" (whatever the actual messages are) are enough to remind me to use sudo. This is good, because I don't accidentally do the infamous "rm -rf /". :)

Does it make my system less secure having "myuserid ALL=(ALL) ALL"? Probably. But, I don't have any open ports, so the risk is small on a home-user desktop. I can see that in a larger installation, or on a web-open install, I might want to set aside different sudo users for different maintenance activities; even if there was only just me. I'm not convinced that logging in to root is the right option, though.

like 5 mins ago i was browsing the internet as root LOL

r3sistance 10-18-2009 02:33 PM

> Quakeboy02

Should be safe since that line should still require a password, however are you certain you don't have any open ports and are not running a service like SSH? Some distributions ship with SSH live and open.

Also I once saw a guy do "sudo rm -rf /*" at work... just having to put sudo infront doesn't stop you doing it if your use to typing sudo when doing similar commands. Personally I have never even got anywhere close to executing that command however.

Quote:

Originally Posted by smeezekitty (Post 3723949)
Ubuntus horrable prompts remind me of windows vistas UAC
that i disabled the first day

As has already been said, you are a security hole ya know, UAC was introduced so that people would not browse the internet as administrator and the prompts only come up with things are asking to be installed. However UAC is only a half-arsed attempt at security because it's still by-passable by viruses (IE conflicker) and we don't know actually how secure that prompt really is... could it be hi-jacked?

It's actually safer to have a seperate administrator account and user account (the traditional Windows Method and similarly the method I use on my Mac), however there are applications that actually take advantage of this EXTREMELY bad method of administrating a PC... it's really rather shameless how professional software development companies require administrator rights for their applications for them to be run at all and this is when they are already installed.

Quote:

Originally Posted by unSpawn (Post 3723837)
I think that would hold true if Sudo came with explicit usage instructions. AFAIK it does not. (I do get what you mean though.)

I think jschiwal's post #25 explains that.

That wasn't the point I was making, the point I was making is that your saying we should respect the way the developers want it done is not true if they are using things from other developers and not respecting the way developers intended those tools to be used.

However even so as Jschiwal's post also says, it's a bad thing. I am yet to see what protection this is all suppose to offer anyway. I mean most if not all up-to-date distributions warn you heavily about login in as root on GUI or stop you all together on the and I can't see what on the CLI would be any more open to being logged in as root over using sudo.

All I really see coming out of it, is teaching people how to abuse SUDO and not really consider using sudo for things like only giving people the privellages on the indivual commands or scripts that they need.

smeezekitty 10-18-2009 02:49 PM

one good advice would be
look at the command before you execute it
and if you see you have executed something bad (like sudo rm -r /) first try control+C
if that fails cut the power

Quakeboy02 10-18-2009 02:49 PM

Quote:

Originally Posted by r3sistance (Post 3724032)
> Quakeboy02

Should be safe since that line should still require a password, however are you certain you don't have any open ports and are not running a service like SSH? Some distributions ship with SSH live and open.

Sorry, I mis-spoke. I meant that my firewall doesn't have any open ports. Yes, there are several ports open on my machine for use on my local network.

Mostly I was just pointing out that logging in as root is akin to carrying a loaded gun with the safety off. Sudo is like that safety, but if you always use sudo, you get the habit of turning the safety off at any excuse. That's not good, either. In my case, I do very little maintenance work, so I'm not a victim of habit. The few admin things (mostly updates) that need to be done in the GUI force gksu to come up, so I'm protected on that front.

You poor buggers that deliberately expose ports to the internet: good luck! :)

r3sistance 10-18-2009 03:28 PM

Alot of computers aren't even running a firewall or behind a hardware one... I know where I work it's a part of our policy to enable the OS supplied firewalls by default with necessary ports open, but would you believe some of our customer's rather then put up with the luxery of opening/closing ports on the firewall would rather just turn the damned thing off... I kid you not. I always advise the customers against such actions of course.

Sudo is as much a safety latch as SU or login as root, you don't login as root unless your doing things that need to be ran as root. In reality it doesn't stop you killing a system if you run the wrong command... The only thing that stops that is not doing none root activities as root in the first place. You shouldn't need to be root or have root to remove directories if user settings are set correctly as most of the file system you shouldn't really be touched that often, mostly what you should be touching is in /home and should already be under your control to remove.

Quote:

Originally Posted by smeezekitty (Post 3724050)
one good advice would be
look at the command before you execute it
and if you see you have executed something bad (like sudo rm -r /) first try control+C
if that fails cut the power

Actually I'd advise Control + Alt + Delete if Control + C. Powering off the machine while you KNOW the hard drive is being written to is going to mess things up as well.

unSpawn 10-18-2009 04:48 PM

Quote:

Originally Posted by r3sistance (Post 3724032)
the point I was making is that your saying we should respect the way the developers want it done is not true if they are using things from other developers and not respecting the way developers intended those tools to be used.

I do not see how the .*buntu people disrespect the Sudo developers work. Correct me if I'm wrong but wrt sudo there's only common sense and best practices, no rules or regulations I know of the Sudo developers impose on usage.


Quote:

Originally Posted by r3sistance (Post 3724032)
However even so as Jschiwal's post also says, it's a bad thing.

No I meant him explaining about the need for sharing the root password or not.


Quote:

Originally Posted by r3sistance (Post 3724032)
All I really see coming out of it, is teaching people how to abuse SUDO and not really consider using sudo for things like only giving people the privellages on the indivual commands or scripts that they need.

That's something I can kind of agree on. If a distribution does not explain why a user should not log in as root but at the same time advertises to just stick "sudo" in front of every command, sane or not, then it's actually as bad as logging in as root. However a distribution is not the only party to blame. I'm thinking users who don't care an ounce for Linux architecture and concepts, reading the documentation or lack common sense and just want "something done right now" regardless of the implications. And equally bad are answers that say "just stick sudo in front of it" without considering the implications.


All times are GMT -5. The time now is 07:13 AM.