安全研究

安全漏洞
Dnsmasq TFTP服务远程堆溢出漏洞

发布日期:2009-08-31
更新日期:2009-09-01

受影响系统:
Simon Kelley Dnsmasq 2.4x
不受影响系统:
Simon Kelley Dnsmasq 2.50
描述:
BUGTRAQ  ID: 36121
CVE ID: CVE-2009-2957

Dnsmasq是可方便配置的轻型DNS转发器和DHCP服务器。

dnsmasq在启用了TFTP服务(--enable-tftp命令行选项或在/etc/dnsmasq.conf中启用enable-tftp)的时候存在堆溢出漏洞。如果所配置的tftp-root足够长,且远程用户发送的请求中包含有超长的文件名,dnsmasq就可能崩溃或以dnsmasq服务的权限(通常为非特权的nobody用户)执行任意代码。

tftp_request对daemon->namebuff调用strncat,其预定义大小为MAXDNAME字节(默认1025)。

/-----------

      else if (filename[0] == '/')
         daemon->namebuff[0] = 0;
      strncat(daemon->namebuff, filename, MAXDNAME);

- -----------/

由于daemon->namebuff可能已经包含有数据,也就是通过配置文件传送给守护程序的daemon->tftp_prefix,因此这可能触发堆溢出。

/-----------

  if (daemon->tftp_prefix)
    {
      if (daemon->tftp_prefix[0] == '/')
        daemon->namebuff[0] = 0;
      strncat(daemon->namebuff, daemon->tftp_prefix, MAXDNAME)

- -----------/

默认的前缀是/var/tftpd,但如果使用了更长的前缀,就可能执行任意代码。

<*来源:Simon Kelley
  
  链接:http://marc.info/?l=full-disclosure&m=125175574625750&w=2
        http://secunia.com/advisories/36394/
        https://www.redhat.com/support/errata/RHSA-2009-1238.html
        http://security.gentoo.org/glsa/glsa-200909-19.xml
*>

测试方法:

警 告

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

/-----------

import sys
sys.stdout.write( '\x00\x01' + "A"*1535 + '\x00' + "netascii" + '\x00' )

- -----------/

建议:
厂商补丁:

RedHat
------
RedHat已经为此发布了一个安全公告(RHSA-2009:1238-01)以及相应补丁:
RHSA-2009:1238-01:Important: dnsmasq security update
链接:https://www.redhat.com/support/errata/RHSA-2009-1238.html

Gentoo
------
Gentoo已经为此发布了一个安全公告(GLSA-200909-19)以及相应补丁:
GLSA-200909-19:Dnsmasq: Multiple vulnerabilities
链接:http://security.gentoo.org/glsa/glsa-200909-19.xml

所有Dnsmasq用户都应升级到最新版本:

    # emerge --sync
    # emerge --ask --oneshot --verbose =3Dnet-dns/dnsmasq-2.5.0

Simon Kelley
------------
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:

http://www.thekelleys.org.uk/dnsmasq/doc.html

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