Bug 98651

Summary: pam-timestamp allows root escalation
Product: [Retired] Red Hat Linux Reporter: Stephen Samuel <samuel>
Component: pamAssignee: Nalin Dahyabhai <nalin>
Status: CLOSED DUPLICATE QA Contact: Jay Turner <jturner>
Severity: medium Docs Contact:
Priority: high    
Version: 9CC: srevivo
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://www.security-focus.com/archive/82/327361/2003-06-26/2003-07-02/0
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-02-21 18:56:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stephen Samuel 2003-07-06 19:31:43 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

Description of problem:
pam-timestamp (as described in the vuln-dev article) allows any user
who can trick an setuid program into creating an arbitrary file to 
create a root account or do anything else which the pam-timestamp 
utility allows.

This escalates any file-creation vulnerability into a local-root exploit.



Version-Release number of selected component (if applicable):
pam-0.75-48

How reproducible:
Always

Steps to Reproduce:
1.as youreslf:
     ln -s /var/run/sudo/$USER/unknown:root /tmp/oops
2: as root:
     touch /tmp/oops
3: as yourself: open the system-settings/users&groups utility from 
the redhat menu. 
4: Create an account with explicit uid=0

Actual Results:  alowed to run program uid=0

Expected Results:  pam recognizes the /var/run/sudo/$USER/unknown:root file as a
fake.

Additional info:

The suggested idea of putting some hard-to-create information into the sudo file
seems like a good one.  
Something like:

tty=`tty`
tty=${tty#/dev/pts/}
userinfo="$USER/$tty:root" 
date=`date +%s`
    echo $userinfo $date `{ echo   $userinfo $date ; cat
/etc/ssh/ssh_host_rsa_key ; } | md5sum` > /var/run/sudo/$userinfo         

would create a reasonably high barrier to entry for any hacker trying to exploit
this bug. It's also reasonably  easy to verify:

datestamp=`awk '{ printf "%s", $2}'  /var/run/sudo/$userinfo`

echo $userinfo $datestamp  `{ echo $userinfo $datestamp ;  cat
/etc/ssh/ssh_host_rsa_key ; } | md5sum ` | diff - /var/run/sudo/$userinfo 

I'd also want to compare $datestamp to the modtime on /var/run/sudo/$userinfo 
 to make sure that they were within a couple of seconds of each other (to
frustrate replay attacks)

Comment 1 Mark J. Cox 2003-07-07 08:19:52 UTC

*** This bug has been marked as a duplicate of 98391 ***

Comment 2 Red Hat Bugzilla 2006-02-21 18:56:57 UTC
Changed to 'CLOSED' state since 'RESOLVED' has been deprecated.