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

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