Ubuntu QA:
BlogBrainstormPackage status
Log in
Ubuntu QA
The Ubuntu community has contributed 21986 ideas, 135057 comments, 2615221 votes
Idea sandbox Idea sandbox
Popular ideas Popular ideas
Ideas in development Ideas in development
Implemented ideas Implemented ideas
Idea #17754: sudo timestamp vulnerability

Written by cdenley the 30 Jan 09 at 13:39. Category: Security. Related project: Nothing/Others. Status: New
Rationale
By default, a sudo timestamp is valid for 15 minutes, so any process running as your user within 15 minutes after you use sudo can easily gain root privileges, killing shells and creating new shells if necessary to use the same TTY as the sudo timestamp.

It doesn't matter how soon the timestamp is killed. If timestamps can be used at all, they can be used by a malicious process immediately after sudo is run.

-15
votes
up equal down
Solution #1: disable timestamps
Written by cdenley the 30 Jan 09 at 13:39.
By default, the timestamps should be disabled in /etc/sudoers, or sudo should do a better job of making sure the user is trying to use sudo from the same shell. Possibly check the PID and file name of the shell's process.
42
votes
up equal down
Solution #2: End sudo "session" on logout
Written by andruk the 31 Jan 09 at 15:10.
Timeouts for sudo are quite nice, and so you will not be able to remove them entirely by default (although there are ideas on Brainstorm to adjust the sudo time that will probably be implemented). The security issue is that you can sudo in a tty, then logout of the tty, log back in, and if you have done so within the sudo timeout you will not be asked to authenticate when you try to do something with sudo.

This is a security issue because a user may not realize that when they login the second time that their previous sudo "session" is still running.

I think that part of the logout process should kill any sudo "sessions" that are still alive.
-8
votes
up equal down
Solution #3: Use the existing 'sudo -k' to kill your timestamp
Written by cheesehead the 3 Feb 09 at 00:31.
If you feel this is a problem, end the sudo period manually anytime you wish with sudo's -k flag. You can also add it to your scripts, .bashrc, logouts, etc.
5
votes
up equal down
Solution #4: Allow the user to either reduce the timestamp or disable it via a GUI
Written by alexandros.java the 21 Mar 09 at 13:36.
Probably the System>Administration>Users and Groups should have options to configure various stuff regarding the /etc/sudoers file.
2
votes
up equal down
Solution #5: Allow user/program to set caller id and delay sudo command.
Written by Lachu the 10 Jan 10 at 11:43.
Just allow user/program to set sudo caller id, like "xAr4a", itd. With key icon on tray, we can delay executing of all sudo command and showing warning in tray:
"Some program identified by xAr4a would execute action: rm -rf / . To avoid it, click key icon on tray. Command will be executed in " x " seconds" .

Also allow to set X Window Id, to allow user see at really command invoking in this shell tries ran this command(it should show the same identifier.

Propose your solution

Attachments
No attachments.


Duplicates


Comments
Arnaudus wrote on the 30 Jan 09 at 21:53
Is it a bug report? Here is what I get with Intrepid:

Open a terminal
sudo apt-get update
password:**********


Open a second terminal
sudo apt-get dist-upgrade
password:**********

So, in another shell, I still need to type my password for sudo. Cam you please be more specific about what is the behavior you expect?

cdenley wrote on the 30 Jan 09 at 22:29
If the shell uses the same TTY, it does not require a password. A malicious process can easily create a shell to match the TTY you use for sudo after killing the shell you used to run it. I have proof-of-concept code if you want more details.

cdenley wrote on the 30 Jan 09 at 22:30
No this is not a bug report, but an idea to improve security by changing the default settings, or how sudo functions.

Arnaudus wrote on the 30 Jan 09 at 22:40
No, if you're right, this is an important security bug.

newirk wrote on the 30 Jan 09 at 23:59
Without cdenley's code in hand you can still confirm this happens - ssh to an ubuntu system then do something via sudo. (obviously the user must be permitted) Check your TTY ('w' for instance) then exit the ssh session. Now ssh to the system again as the same user and check TTY again - probably the same, and if so try sudo again and it will not ask for password if you're within 15 minutes of providing the password in the previous ssh session. It only cares that the userID and TTY are the same, it seems.

Various measures can ameliorate this, but the end effect is that if timestamps are used at all, it is possible to hijack the timestamp by killing off the shell that just authenticated to sudo and then gaining its TTY by spawning shells.

j

dinar wrote on the 1 Feb 09 at 15:35
related threads in ubuntuforums:

http://ubuntuforums.org/showthread.php?t=1045209 "can programs run sudo ... without password within sudo's 15 minutes?"

http://ubuntuforums.org/showthread.php?t=1051348 "sudo privilege escalation flaw?"

cdenley wrote on the 3 Feb 09 at 20:54
It doesn't matter if the timestamp is killed one minute after you use sudo or when you log out. A malicious process can wait for you to run sudo, then re-use the timestamp immediately.


Post your comment