From 456e1eadd2a3a2fb9617e60d4db90ef4ba7c6ba3 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Mon, 22 Feb 2016 12:22:43 +0530 Subject: [PATCH] Fix resolver assertion failure due to improper DNAME handling (CVE-2016-1286) (#41753) (cherry picked from commit 5995fec51cc8bb7e53804e4936e60aa1537f3673) --- CHANGES | 4 ++++ doc/arm/notes.xml | 7 +++++++ lib/dns/resolver.c | 33 ++++++++++++++++++--------------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index 3f329443d4..8f46141f87 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4319. [security] Fix resolver assertion failure due to improper + DNAME handling when parsing fetch reply messages. + (CVE-2016-1286) [RT #41753] + 4318. [security] Malformed control messages can trigger assertions in named and rndc. (CVE-2016-1285) [RT #41666] diff --git a/doc/arm/notes.xml b/doc/arm/notes.xml index 9ac57f68f4..846353add3 100644 --- a/doc/arm/notes.xml +++ b/doc/arm/notes.xml @@ -77,6 +77,13 @@ #41666] + + + The resolver could abort with an assertion failure due to + improper DNAME handling when parsing fetch reply + messages. This flaw is disclosed in CVE-2016-1286. [RT #41753] + + diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index f61572f65f..2987f75858 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -6981,21 +6981,26 @@ answer_response(fetchctx_t *fctx) { isc_boolean_t found_dname = ISC_FALSE; dns_name_t *dname_name; + /* + * Only pass DNAME or RRSIG(DNAME). + */ + if (rdataset->type != dns_rdatatype_dname && + (rdataset->type != dns_rdatatype_rrsig || + rdataset->covers != dns_rdatatype_dname)) + continue; + + /* + * If we're not chaining, then the DNAME and + * its signature should not be external. + */ + if (!chaining && external) { + log_formerr(fctx, "external DNAME"); + return (DNS_R_FORMERR); + } + found = ISC_FALSE; aflag = 0; if (rdataset->type == dns_rdatatype_dname) { - /* - * We're looking for something else, - * but we found a DNAME. - * - * If we're not chaining, then the - * DNAME should not be external. - */ - if (!chaining && external) { - log_formerr(fctx, - "external DNAME"); - return (DNS_R_FORMERR); - } found = ISC_TRUE; want_chaining = ISC_TRUE; POST(want_chaining); @@ -7024,9 +7029,7 @@ answer_response(fetchctx_t *fctx) { &fctx->domain)) { return (DNS_R_SERVFAIL); } - } else if (rdataset->type == dns_rdatatype_rrsig - && rdataset->covers == - dns_rdatatype_dname) { + } else { /* * We've found a signature that * covers the DNAME.