Blame SOURCES/bind-9.11-CVE-2019-6465.patch

89a891
From 3824a600a51188c713e900115d6af129b54706df Mon Sep 17 00:00:00 2001
89a891
From: Mark Andrews <marka@isc.org>
89a891
Date: Wed, 6 Feb 2019 11:35:21 -0800
89a891
Subject: [PATCH] denied axfr requests were not effective for writable DLZ
89a891
 zones
89a891
89a891
(cherry picked from commit d9077cd0038e59726e1956de18b4b7872038a283)
89a891
(cherry picked from commit 34348d9ee4db15307c6c42db294419b4df569f76)
89a891
---
89a891
 bin/named/xfrout.c                    |  8 ++++----
89a891
 bin/tests/system/dlzexternal/driver.c | 18 +++++++++++++++---
89a891
 bin/tests/system/dlzexternal/tests.sh | 16 ++++++++++++----
89a891
 3 files changed, 31 insertions(+), 11 deletions(-)
89a891
89a891
diff --git a/bin/named/xfrout.c b/bin/named/xfrout.c
89a891
index c531e0acef..f6e57d889e 100644
89a891
--- a/bin/named/xfrout.c
89a891
+++ b/bin/named/xfrout.c
89a891
@@ -803,12 +803,12 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
89a891
 	result = dns_zt_find(client->view->zonetable, question_name, 0, NULL,
89a891
 			     &zone);
89a891
 
89a891
-	if (result != ISC_R_SUCCESS) {
89a891
+	if (result != ISC_R_SUCCESS || dns_zone_gettype(zone) == dns_zone_dlz) {
89a891
 		/*
89a891
-		 * Normal zone table does not have a match.
89a891
-		 * Try the DLZ database
89a891
+		 * The normal zone table does not have a match, or this is
89a891
+		 * marked in the zone table as a DLZ zone. Check the DLZ
89a891
+		 * databases for a match.
89a891
 		 */
89a891
-		// Temporary: only searching the first DLZ database
89a891
 		if (! ISC_LIST_EMPTY(client->view->dlz_searched)) {
89a891
 			result = dns_dlzallowzonexfr(client->view,
89a891
 						     question_name,
89a891
diff --git a/bin/tests/system/dlzexternal/driver.c b/bin/tests/system/dlzexternal/driver.c
89a891
index 37a62622da..dfa7847984 100644
89a891
--- a/bin/tests/system/dlzexternal/driver.c
89a891
+++ b/bin/tests/system/dlzexternal/driver.c
89a891
@@ -542,10 +542,22 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
89a891
  */
89a891
 isc_result_t
89a891
 dlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
89a891
-	UNUSED(client);
89a891
+	isc_result_t result;
89a891
+
89a891
+	result = dlz_findzonedb(dbdata, name, NULL, NULL);
89a891
+	if (result != ISC_R_SUCCESS) {
89a891
+		return (result);
89a891
+	}
89a891
 
89a891
-	/* Just say yes for all our zones */
89a891
-	return (dlz_findzonedb(dbdata, name, NULL, NULL));
89a891
+	/*
89a891
+	 * Exception for 10.53.0.5 so we can test that allow-transfer
89a891
+	 * is effective.
89a891
+	 */
89a891
+	if (strcmp(client, "10.53.0.5") == 0) {
89a891
+		return (ISC_R_NOPERM);
89a891
+	}
89a891
+
89a891
+	return (ISC_R_SUCCESS);
89a891
 }
89a891
 
89a891
 /*
89a891
diff --git a/bin/tests/system/dlzexternal/tests.sh b/bin/tests/system/dlzexternal/tests.sh
89a891
index 87dd13b10e..1754aaa57c 100644
89a891
--- a/bin/tests/system/dlzexternal/tests.sh
89a891
+++ b/bin/tests/system/dlzexternal/tests.sh
89a891
@@ -108,15 +108,23 @@ test_update testdc1.alternate.nil. A "86400 A 10.53.0.10" "10.53.0.10" || ret=1
89a891
 status=`expr $status + $ret`
89a891
 
89a891
 newtest "testing AXFR from DLZ drivers"
89a891
-$DIG $DIGOPTS +noall +answer axfr example.nil > dig.out.ns1.test$n
89a891
-lines=`cat dig.out.ns1.test$n | wc -l`
89a891
+$DIG $DIGOPTS +noall +answer axfr example.nil > dig.out.example.ns1.test$n
89a891
+lines=`cat dig.out.example.ns1.test$n | wc -l`
89a891
 [ ${lines:-0} -eq 4 ] || ret=1
89a891
-$DIG $DIGOPTS +noall +answer axfr alternate.nil > dig.out.ns1.test$n
89a891
-lines=`cat dig.out.ns1.test$n | wc -l`
89a891
+$DIG $DIGOPTS +noall +answer axfr alternate.nil > dig.out.alternate.ns1.test$n
89a891
+lines=`cat dig.out.alternate.ns1.test$n | wc -l`
89a891
 [ ${lines:-0} -eq 5 ] || ret=1
89a891
 [ "$ret" -eq 0 ] || echo_i "failed"
89a891
 status=`expr $status + $ret`
89a891
 
89a891
+newtest "testing AXFR denied from DLZ drivers"
89a891
+$DIG $DIGOPTS -b 10.53.0.5 +noall +answer axfr example.nil > dig.out.example.ns1.test$n
89a891
+grep "; Transfer failed" dig.out.example.ns1.test$n > /dev/null || ret=1
89a891
+$DIG $DIGOPTS -b 10.53.0.5 +noall +answer axfr alternate.nil > dig.out.alternate.ns1.test$n
89a891
+grep "; Transfer failed" dig.out.alternate.ns1.test$n > /dev/null || ret=1
89a891
+[ "$ret" -eq 0 ] || echo_i "failed"
89a891
+status=`expr $status + $ret`
89a891
+
89a891
 newtest "testing unsearched/unregistered DLZ zone is not found"
89a891
 $DIG $DIGOPTS +noall +answer ns other.nil > dig.out.ns1.test$n
89a891
 grep "3600.IN.NS.other.nil." dig.out.ns1.test$n > /dev/null && ret=1
89a891
-- 
89a891
2.20.1
89a891