{"id":5806,"date":"2017-01-18T22:26:10","date_gmt":"2017-01-18T22:26:10","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/01\/18\/news-21\/"},"modified":"2017-01-18T22:26:10","modified_gmt":"2017-01-18T22:26:10","slug":"news-21","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2017\/01\/18\/news-21\/","title":{"rendered":"Analysis of ISC BIND TKEY Query Response Handling DoS (CVE-2016-9131)"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/image(1).jpg\"\/><\/p>\n<div class=\"entry\">\n<p>Another TKEY record-related bug in BIND has been fixed with a&nbsp;<a href=\"https:\/\/mail.fortinet-us.com\/owa\/redir.aspx?SURL=Ya5NiqIrwOmrhGPJVkImwVnWM_3J6kTx3H8ul6tTYXTqzXR8vD_UCGgAdAB0AHAAcwA6AC8ALwBrAGIALgBpAHMAYwAuAG8AcgBnAC8AYQByAHQAaQBjAGwAZQAvAEEAQQAtADAAMQA0ADMAOQA.&amp;URL=https%3a%2f%2fkb.isc.org%2farticle%2fAA-01439\" target=\"_blank\">patch<\/a>&nbsp;from the Internet Systems Consortium (ISC) that was released just after the New Year. This bug may take down BIND recursive servers by sending a simple query response with TKEY record, thereby causing a denial of service (DoS).<\/p>\n<p>This potential DoS vulnerability is caused by an assertion failure in Resolver.c when caching the DNS response with TKEY Record. In this post we will analyze the BIND source codes and expose the root cause of this vulnerability.<\/p>\n<p>The TKEY record (record type 249) is used to operate the secret keys information shared between DNS resolvers and servers. It is not supposed to be in the DNS ANY query response, which responds to the DNS query with Type ANY, nor stored or cached by DNS recursive servers. This bug is caused by a mismatch error when DNS recursive servers try&nbsp;to cache the TKEY record in the DNS ANY query response.<\/p>\n<p>The following code snippet was taken from BIND version 9.10.4-P4. Comments added by me have been highlighted.<\/p>\n<p>Resolver.c:<\/p>\n<blockquote>\n<p>5246&nbsp;&nbsp;&nbsp;&nbsp; static inline isc_result_t<\/p>\n<p>5247&nbsp;&nbsp;&nbsp;&nbsp; cache_name(fetchctx_t *fctx, dns_name_t *name, dns_adbaddrinfo_t *addrinfo,<\/p>\n<p>5248&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isc_stdtime_t now)<\/p>\n<p>5249&nbsp;&nbsp;&nbsp;&nbsp; {<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;&nbsp;<\/p>\n<p>&nbsp;&nbsp;<span style=\"color:#FF0000;\">\/\/&nbsp;caching the TKEY Record in the DNS ANY query response<\/span><\/p>\n<p>5620&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;result = dns_db_addrdataset(fctx-&gt;cache,<\/p>\n<p>5621&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node, NULL, now,<\/p>\n<p>5622&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rdataset,<\/p>\n<p>5623&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; options,<\/p>\n<p>5624&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addedrdataset);<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p>db.c:<\/p>\n<blockquote>\n<p>749&nbsp;&nbsp;&nbsp;&nbsp; isc_result_t<\/p>\n<p>750&nbsp;&nbsp;&nbsp;&nbsp; dns_db_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,<\/p>\n<p>751&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; isc_stdtime_t now, dns_rdataset_t *rdataset,<\/p>\n<p>752&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; unsigned int options, dns_rdataset_t *addedrdataset)<\/p>\n<p>753&nbsp;&nbsp;&nbsp;&nbsp; {<\/p>\n<p>754&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;\/*<\/p>\n<p>755&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; * Add &#39;rdataset&#39; to &#39;node&#39; in version &#39;version&#39; of &#39;db&#39;.<\/p>\n<p>756&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; *\/<\/p>\n<p>757&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>758&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;REQUIRE(DNS_DB_VALID(db));<\/p>\n<p>759&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;REQUIRE(node != NULL);<\/p>\n<p>760&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;REQUIRE(((db-&gt;attributes &amp; DNS_DBATTR_CACHE) == 0 &amp;&amp; version != NULL)||<\/p>\n<p>761&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;((db-&gt;attributes &amp; DNS_DBATTR_CACHE) != 0 &amp;&amp;<\/p>\n<p>762&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; version == NULL &amp;&amp; (options &amp; DNS_DBADD_MERGE) == 0));<\/p>\n<p>763&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;REQUIRE((options &amp; DNS_DBADD_EXACT) == 0 ||<\/p>\n<p>764&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;(options &amp; DNS_DBADD_MERGE) != 0);<\/p>\n<p>765&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;REQUIRE(DNS_RDATASET_VALID(rdataset));<\/p>\n<p>766&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;REQUIRE(dns_rdataset_isassociated(rdataset));<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#FF0000;\"> \/\/db-&gt;rdclass comes from the ANY query which is &quot;1&quot;, rdataset-&gt;rdclass is the &quot;Class&quot; property of TKEY record, which is &quot;0xff&quot;, they doesn&#39;t match and assertion failure occurs.<\/span><\/p>\n<p>767&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;REQUIRE(rdataset-&gt;rdclass == db-&gt;rdclass);<\/p>\n<\/blockquote>\n<p>Following is the image showing the abortion of the affected DNS server:<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/image(1).jpg\" style=\"width: 1600px; height: 231px;\" \/><\/p>\n<p>Please note that authentication is NOT required to exploit this vulnerability.<\/p>\n<p>Fortinet released IPS signature ISC.BIND.TKEY.Query.Reponse.Handling.DoS to address this vulnerability.<\/p>\n<p>&nbsp;<\/p>\n<\/div<br \/><a href=\"http:\/\/blog.fortinet.com\/2017\/01\/18\/analysis-of-isc-bind-tkey-query-response-handling-dos-cve-2016-9131\" target=\"bwo\" >https:\/\/blog.fortinet.com\/feed<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/image(1).jpg\"\/><br \/>Another TKEY record-related bug in BIND has been fixed with a\u00a0patch\u00a0from the Internet Systems Consortium (ISC) that was released just after the New Year. This bug may take down BIND recursive servers by sending a simple query response with TKEY record, thereby causing a denial of service (DoS).    This potential DoS vulnerability is caused by an assertion failure in Resolver.c when caching the DNS response with TKEY Record. In this post we will analyze the BIND source codes and expose the root cause of this vulnerability.    The TKEY record&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10424,10378],"tags":[],"class_list":["post-5806","post","type-post","status-publish","format-standard","hentry","category-fortinet","category-security"],"_links":{"self":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/5806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=5806"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/5806\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=5806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=5806"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=5806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}