Blame SOURCES/bind-9.16-CVE-2022-3094-test.patch

7e24df
From 630529ea7d4587703008de1465021bdde2a3a971 Mon Sep 17 00:00:00 2001
7e24df
From: Evan Hunt <each@isc.org>
7e24df
Date: Wed, 9 Nov 2022 21:56:16 -0800
7e24df
Subject: [PATCH] test failure conditions
7e24df
7e24df
verify that updates are refused when the client is disallowed by
7e24df
allow-query, and update forwarding is refused when the client is
7e24df
is disallowed by update-forwarding.
7e24df
7e24df
verify that "too many DNS UPDATEs" appears in the log file when too
7e24df
many simultaneous updates are processing.
7e24df
7e24df
(cherry picked from commit b91339b80e5b82a56622c93cc1e3cca2d0c11bc0)
7e24df
---
7e24df
 bin/tests/system/nsupdate/ns1/named.conf.in   |  2 +
7e24df
 bin/tests/system/nsupdate/tests.sh            | 28 +++++++++++++
7e24df
 bin/tests/system/upforwd/clean.sh             |  2 +
7e24df
 .../ns3/{named.conf.in => named1.conf.in}     | 13 ++++--
7e24df
 bin/tests/system/upforwd/ns3/named2.conf.in   | 41 +++++++++++++++++++
7e24df
 bin/tests/system/upforwd/setup.sh             |  2 +-
7e24df
 bin/tests/system/upforwd/tests.sh             | 39 ++++++++++++++++++
7e24df
 7 files changed, 123 insertions(+), 4 deletions(-)
7e24df
 rename bin/tests/system/upforwd/ns3/{named.conf.in => named1.conf.in} (78%)
7e24df
 create mode 100644 bin/tests/system/upforwd/ns3/named2.conf.in
7e24df
7e24df
diff --git a/bin/tests/system/nsupdate/ns1/named.conf.in b/bin/tests/system/nsupdate/ns1/named.conf.in
7e24df
index 436c97d..83fe884 100644
7e24df
--- a/bin/tests/system/nsupdate/ns1/named.conf.in
7e24df
+++ b/bin/tests/system/nsupdate/ns1/named.conf.in
7e24df
@@ -21,6 +21,7 @@ options {
7e24df
 	recursion no;
7e24df
 	notify yes;
7e24df
 	minimal-responses no;
7e24df
+	update-quota 1;
7e24df
 };
7e24df
 
7e24df
 acl named-acl {
7e24df
@@ -81,6 +82,7 @@ zone "other.nil" {
7e24df
 	check-integrity no;
7e24df
 	check-mx warn;
7e24df
 	update-policy local;
7e24df
+	allow-query { !10.53.0.2; any; };
7e24df
 	allow-query-on { 10.53.0.1; 127.0.0.1; };
7e24df
 	allow-transfer { any; };
7e24df
 };
7e24df
diff --git a/bin/tests/system/nsupdate/tests.sh b/bin/tests/system/nsupdate/tests.sh
7e24df
index b5f562f..13ba577 100755
7e24df
--- a/bin/tests/system/nsupdate/tests.sh
7e24df
+++ b/bin/tests/system/nsupdate/tests.sh
7e24df
@@ -1268,6 +1268,34 @@ END
7e24df
 grep "NSEC3PARAM has excessive iterations (> 150)" nsupdate.out-$n >/dev/null || ret=1
7e24df
 [ $ret = 0 ] || { echo_i "failed"; status=1; }
7e24df
 
7e24df
+n=$((n + 1))
7e24df
+ret=0
7e24df
+echo_i "check that update is rejected if query is not allowed ($n)"
7e24df
+{
7e24df
+  $NSUPDATE -d <
7e24df
+  local 10.53.0.2
7e24df
+  server 10.53.0.1 ${PORT}
7e24df
+  update add reject.other.nil 3600 IN TXT Whatever
7e24df
+  send
7e24df
+END
7e24df
+} > nsupdate.out.test$n 2>&1
7e24df
+grep 'failed: REFUSED' nsupdate.out.test$n > /dev/null || ret=1
7e24df
+[ $ret = 0 ] || { echo_i "failed"; status=1; }
7e24df
+
7e24df
+n=$((n + 1))
7e24df
+ret=0
7e24df
+echo_i "check that update is rejected if quota is exceeded ($n)"
7e24df
+for loop in 1 2 3 4 5 6 7 8 9 10; do
7e24df
+{
7e24df
+  $NSUPDATE -4 -l -p ${PORT} -k ns1/session.key > /dev/null 2>&1 <
7e24df
+  update add txt-$loop.other.nil 3600 IN TXT Whatever
7e24df
+  send
7e24df
+END
7e24df
+} &
7e24df
+done
7e24df
+wait_for_log 10 "too many DNS UPDATEs queued" ns1/named.run || ret=1
7e24df
+[ $ret = 0 ] || { echo_i "failed"; status=1; }
7e24df
+
7e24df
 if ! $FEATURETEST --gssapi ; then
7e24df
   echo_i "SKIPPED: GSSAPI tests"
7e24df
 else
7e24df
diff --git a/bin/tests/system/upforwd/clean.sh b/bin/tests/system/upforwd/clean.sh
7e24df
index 2025252..12311df 100644
7e24df
--- a/bin/tests/system/upforwd/clean.sh
7e24df
+++ b/bin/tests/system/upforwd/clean.sh
7e24df
@@ -29,3 +29,5 @@ rm -f keyname keyname.err
7e24df
 rm -f ns*/named.lock
7e24df
 rm -f ns1/example2.db
7e24df
 rm -f ns*/managed-keys.bind*
7e24df
+rm -f nsupdate.out.*
7e24df
+rm -f ns*/named.run.prev
7e24df
diff --git a/bin/tests/system/upforwd/ns3/named.conf.in b/bin/tests/system/upforwd/ns3/named1.conf.in
7e24df
similarity index 78%
7e24df
rename from bin/tests/system/upforwd/ns3/named.conf.in
7e24df
rename to bin/tests/system/upforwd/ns3/named1.conf.in
7e24df
index 7bd13d3..2f690ff 100644
7e24df
--- a/bin/tests/system/upforwd/ns3/named.conf.in
7e24df
+++ b/bin/tests/system/upforwd/ns3/named1.conf.in
7e24df
@@ -28,20 +28,27 @@ key rndc_key {
7e24df
 };
7e24df
 
7e24df
 controls {
7e24df
-        inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
7e24df
+	inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
7e24df
 };
7e24df
 
7e24df
 zone "example" {
7e24df
 	type secondary;
7e24df
 	file "example.bk";
7e24df
-	allow-update-forwarding { any; };
7e24df
+	allow-update-forwarding { 10.53.0.1; };
7e24df
 	primaries { 10.53.0.1; };
7e24df
 };
7e24df
 
7e24df
 zone "example2" {
7e24df
 	type secondary;
7e24df
 	file "example2.bk";
7e24df
-	allow-update-forwarding { any; };
7e24df
+	allow-update-forwarding { 10.53.0.1; };
7e24df
+	primaries { 10.53.0.1; };
7e24df
+};
7e24df
+
7e24df
+zone "example3" {
7e24df
+	type secondary;
7e24df
+	file "example3.bk";
7e24df
+	allow-update-forwarding { 10.53.0.1; };
7e24df
 	primaries { 10.53.0.1; };
7e24df
 };
7e24df
 
7e24df
diff --git a/bin/tests/system/upforwd/ns3/named2.conf.in b/bin/tests/system/upforwd/ns3/named2.conf.in
7e24df
new file mode 100644
7e24df
index 0000000..86d7469
7e24df
--- /dev/null
7e24df
+++ b/bin/tests/system/upforwd/ns3/named2.conf.in
7e24df
@@ -0,0 +1,41 @@
7e24df
+/*
7e24df
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
7e24df
+ *
7e24df
+ * SPDX-License-Identifier: MPL-2.0
7e24df
+ *
7e24df
+ * This Source Code Form is subject to the terms of the Mozilla Public
7e24df
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
7e24df
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
7e24df
+ *
7e24df
+ * See the COPYRIGHT file distributed with this work for additional
7e24df
+ * information regarding copyright ownership.
7e24df
+ */
7e24df
+
7e24df
+options {
7e24df
+	query-source address 10.53.0.3;
7e24df
+	notify-source 10.53.0.3;
7e24df
+	transfer-source 10.53.0.3;
7e24df
+	port @PORT@;
7e24df
+	pid-file "named.pid";
7e24df
+	listen-on { 10.53.0.3; };
7e24df
+	listen-on-v6 { none; };
7e24df
+	recursion no;
7e24df
+	notify yes;
7e24df
+	update-quota 1;
7e24df
+};
7e24df
+
7e24df
+key rndc_key {
7e24df
+	secret "1234abcd8765";
7e24df
+	algorithm @DEFAULT_HMAC@;
7e24df
+};
7e24df
+
7e24df
+controls {
7e24df
+	inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
7e24df
+};
7e24df
+
7e24df
+zone "example" {
7e24df
+	type secondary;
7e24df
+	file "example.bk";
7e24df
+	allow-update-forwarding { any; };
7e24df
+	primaries { 10.53.0.1; };
7e24df
+};
7e24df
diff --git a/bin/tests/system/upforwd/setup.sh b/bin/tests/system/upforwd/setup.sh
7e24df
index e748078..88ab28d 100644
7e24df
--- a/bin/tests/system/upforwd/setup.sh
7e24df
+++ b/bin/tests/system/upforwd/setup.sh
7e24df
@@ -17,7 +17,7 @@ cp -f ns3/nomaster.db ns3/nomaster1.db
7e24df
 
7e24df
 copy_setports ns1/named.conf.in ns1/named.conf
7e24df
 copy_setports ns2/named.conf.in ns2/named.conf
7e24df
-copy_setports ns3/named.conf.in ns3/named.conf
7e24df
+copy_setports ns3/named1.conf.in ns3/named.conf
7e24df
 
7e24df
 if $FEATURETEST --enable-dnstap
7e24df
 then
7e24df
diff --git a/bin/tests/system/upforwd/tests.sh b/bin/tests/system/upforwd/tests.sh
7e24df
index 8062d68..20fc46f 100644
7e24df
--- a/bin/tests/system/upforwd/tests.sh
7e24df
+++ b/bin/tests/system/upforwd/tests.sh
7e24df
@@ -80,6 +80,7 @@ if [ $ret != 0 ] ; then echo_i "failed"; status=`expr $status + $ret`; fi
7e24df
 echo_i "updating zone (signed) ($n)"
7e24df
 ret=0
7e24df
 $NSUPDATE -y hmac-sha256:update.example:c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K -- - <
7e24df
+local 10.53.0.1
7e24df
 server 10.53.0.3 ${PORT}
7e24df
 update add updated.example. 600 A 10.10.10.1
7e24df
 update add updated.example. 600 TXT Foo
7e24df
@@ -138,6 +139,7 @@ fi
7e24df
 echo_i "updating zone (unsigned) ($n)"
7e24df
 ret=0
7e24df
 $NSUPDATE -- - <
7e24df
+local 10.53.0.1
7e24df
 server 10.53.0.3 ${PORT}
7e24df
 update add unsigned.example. 600 A 10.10.10.1
7e24df
 update add unsigned.example. 600 TXT Foo
7e24df
@@ -194,6 +196,7 @@ while [ $count -lt 5 -a $ret -eq 0 ]
7e24df
 do
7e24df
 (
7e24df
 $NSUPDATE -- - <
7e24df
+local 10.53.0.1
7e24df
 server 10.53.0.3 ${PORT}
7e24df
 zone nomaster
7e24df
 update add unsigned.nomaster. 600 A 10.10.10.1
7e24df
@@ -225,6 +228,7 @@ then
7e24df
 	ret=0
7e24df
 	keyname=`cat keyname`
7e24df
 	$NSUPDATE -k $keyname.private -- - <
7e24df
+	local 10.53.0.1
7e24df
 	server 10.53.0.3 ${PORT}
7e24df
 	zone example2
7e24df
 	update add unsigned.example2. 600 A 10.10.10.1
7e24df
@@ -249,5 +253,40 @@ EOF
7e24df
 	fi
7e24df
 fi
7e24df
 
7e24df
+echo_i "attempting an update that should be rejected by ACL ($n)"
7e24df
+ret=0
7e24df
+{
7e24df
+        $NSUPDATE -- - << EOF
7e24df
+        local 10.53.0.2
7e24df
+        server 10.53.0.3 ${PORT}
7e24df
+        update add another.unsigned.example. 600 A 10.10.10.2
7e24df
+        update add another.unsigned.example. 600 TXT Bar
7e24df
+        send
7e24df
+EOF
7e24df
+} > nsupdate.out.$n 2>&1
7e24df
+grep REFUSED nsupdate.out.$n > /dev/null || ret=1
7e24df
+if [ $ret != 0 ] ; then echo_i "failed"; status=`expr $status + $ret`; fi
7e24df
+n=`expr $n + 1`
7e24df
+
7e24df
+n=$((n + 1))
7e24df
+ret=0
7e24df
+echo_i "attempting updates that should exceed quota ($n)"
7e24df
+# lower the update quota to 1.
7e24df
+copy_setports ns3/named2.conf.in ns3/named.conf
7e24df
+rndc_reconfig ns3 10.53.0.3
7e24df
+nextpart ns3/named.run > /dev/null
7e24df
+for loop in 1 2 3 4 5 6 7 8 9 10; do
7e24df
+{
7e24df
+  $NSUPDATE -- - > /dev/null 2>&1 <
7e24df
+  local 10.53.0.1
7e24df
+  server 10.53.0.3 ${PORT}
7e24df
+  update add txt-$loop.unsigned.example 300 IN TXT Whatever
7e24df
+  send
7e24df
+END
7e24df
+} &
7e24df
+done
7e24df
+wait_for_log 10 "too many DNS UPDATEs queued" ns3/named.run || ret=1
7e24df
+[ $ret = 0 ] || { echo_i "failed"; status=1; }
7e24df
+
7e24df
 echo_i "exit status: $status"
7e24df
 [ $status -eq 0 ] || exit 1
7e24df
-- 
7e24df
2.39.1
7e24df