]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Test validation deadlock recovery
authorMark Andrews <marka@isc.org>
Tue, 7 Dec 2021 03:26:10 +0000 (14:26 +1100)
committerEvan Hunt <each@isc.org>
Wed, 8 Dec 2021 18:56:25 +0000 (10:56 -0800)
Check that the following scenarios do not cause fetches to hang:
- An undelegated unsigned zone with CNAME to apex where the parent
  zone is signed
- An NSEC3 zone with only DNSKEY correctly signed

bin/tests/system/dnssec/clean.sh
bin/tests/system/dnssec/ns2/example.db.in
bin/tests/system/dnssec/ns2/named.conf.in
bin/tests/system/dnssec/ns2/notdelegated.example.db [new file with mode: 0644]
bin/tests/system/dnssec/ns2/sign.sh
bin/tests/system/dnssec/ns3/all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db.in [new file with mode: 0644]
bin/tests/system/dnssec/ns3/named.conf.in
bin/tests/system/dnssec/ns3/sign.sh
bin/tests/system/dnssec/tests.sh

index b4ff9f394148e932e521e976244b38f2290c3337..dbf3597b9ea5ac0a4d701ec7145d5a34881eff4a 100644 (file)
@@ -25,7 +25,6 @@ rm -f ./canonical?.*
 rm -f ./delv.out*
 rm -f ./delve.out*
 rm -f ./dig.out.*
-rm -f ./ns2/too-many-iterations.db
 rm -f ./dnssectools.out*
 rm -f ./dsfromkey.out.*
 rm -f ./keygen.err
@@ -52,7 +51,12 @@ rm -f ./ns2/cds.secure.db ./ns2/cds-x.secure.db
 rm -f ./ns2/in-addr.arpa.db
 rm -f ./ns2/nsec3chain-test.db
 rm -f ./ns2/single-nsec3.db
+rm -f ./ns2/too-many-iterations.db
 rm -f ./ns2/updatecheck-kskonly.secure.*
+rm -f ./ns3/NSEC ./ns3/NSEC3
+rm -f ./ns3/all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db not removed
+rm -f ./ns3/all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db.badsigs not removed
+rm -f ./ns3/all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db.goodsigs not removed
 rm -f ./ns3/auto-nsec.example.db ./ns3/auto-nsec3.example.db
 rm -f ./ns3/badds.example.db
 rm -f ./ns3/dname-at-apex-nsec3.example.db
@@ -94,7 +98,6 @@ rm -f ./ns3/ttlpatch.example.db ./ns3/ttlpatch.example.db.signed
 rm -f ./ns3/ttlpatch.example.db.patched
 rm -f ./ns3/unsecure.example.db ./ns3/bogus.example.db ./ns3/keyless.example.db
 rm -f ./ns3/unsupported.managed.db.tmp ./ns3/unsupported.trusted.db.tmp
-rm -f ./ns3/NSEC ./ns3/NSEC3
 rm -f ./ns4/managed-keys.bind*
 rm -f ./ns4/named_dump.db*
 rm -f ./ns6/optout-tld.db
index 2545faf6b9fb68cffc4add8827fbee7612381874..51a74ad4e591f6c023dbc5884f55837b78a8eed6 100644 (file)
@@ -163,3 +163,6 @@ revkey                      NS      ns.revkey
 ns.revkey              A       10.53.0.3
 
 dname-at-apex-nsec3    NS      ns3
+
+all-but-dnskey-signed-with-nonexistent-key-nsec3 NS ns.all-but-dnskey-signed-with-nonexistent-key-nsec3
+ns.all-but-dnskey-signed-with-nonexistent-key-nsec3 A 10.53.0.3
index 1709b467384fbc461b6873ca0ec30704e3acebb7..53a57c5f6da514c9b6de6d6d90420ad14505a448 100644 (file)
@@ -56,6 +56,11 @@ zone "example" {
        allow-update { any; };
 };
 
+zone "notdelegated.example" {
+       type primary;
+       file "notdelegated.example.db";
+};
+
 zone "insecure.secure.example" {
        type primary;
        file "insecure.secure.example.db";
diff --git a/bin/tests/system/dnssec/ns2/notdelegated.example.db b/bin/tests/system/dnssec/ns2/notdelegated.example.db
new file mode 100644 (file)
index 0000000..9781f9c
--- /dev/null
@@ -0,0 +1,17 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+$TTL 300
+@      SOA     ns2 hostmaster 0 0 0 0 0
+@      NS      ns2
+@      NS      ns3
+@      A       10.53.0.100
+ns2    A       10.53.0.2
+ns3    A       10.53.0.3
+www    CNAME   @
index 6e3893b782eb9927dee603168c2a41918dd7081f..6347876c80582b3cf3c6d1cffc7b531fa7bf4cd1 100644 (file)
@@ -61,7 +61,8 @@ for subdomain in secure badds bogus dynamic keyless nsec3 optout \
        ttlpatch split-dnssec split-smart expired expiring upper lower \
        dnskey-unknown dnskey-unsupported dnskey-unsupported-2 \
        dnskey-nsec3-unknown managed-future revkey \
-       dname-at-apex-nsec3 occluded
+       dname-at-apex-nsec3 occluded \
+       all-but-dnskey-signed-with-nonexistent-key-nsec3
 do
        cp "../ns3/dsset-$subdomain.example$TP" .
 done
diff --git a/bin/tests/system/dnssec/ns3/all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db.in b/bin/tests/system/dnssec/ns3/all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db.in
new file mode 100644 (file)
index 0000000..1cd8eaa
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+$TTL 300       ; 5 minutes
+@                      IN SOA  mname1. . (
+                               2000042407 ; serial
+                               20         ; refresh (20 seconds)
+                               20         ; retry (20 seconds)
+                               1814400    ; expire (3 weeks)
+                               3600       ; minimum (1 hour)
+                               )
+                       NS      ns3
+ns3                    A       10.53.0.3
+
+a                      A       10.0.0.1
+b                      A       10.0.0.2
+c                      A       10.0.0.3
+d                      A       10.0.0.4
+e                      A       10.0.0.5
+f                      A       10.0.0.6
+g                      A       10.0.0.7
+z                      A       10.0.0.26
+a.a.a.a.a.a.a.a.a.a.e  A       10.0.0.27
+x                      CNAME   a
+zz                     DNSKEY  258 3 5 Cg==
+
+normalthenrrsig                A       10.0.0.28
+rrsigonly              A       10.0.0.29
+
+cnameandkey            CNAME   @
+cnamenokey             CNAME   @
+dnameandkey            DNAME   @
index 7262359b3231b798a91718518685ea0863a4189f..3d142d5273d6637d06fc5dbaf81b886fc3c5cd54 100644 (file)
@@ -46,6 +46,12 @@ zone "example" {
        file "example.bk";
 };
 
+zone "notdelegated.example" {
+       type secondary;
+       primaries { 10.53.0.2; };
+       file "notdelegated.example.bk";
+};
+
 zone "secure.example" {
        type primary;
        file "secure.example.db.signed";
@@ -370,6 +376,11 @@ zone "too-many-iterations" {
        file "too-many-iterations.bk";
 };
 
+zone "all-but-dnskey-signed-with-nonexistent-key-nsec3.example" {
+       type primary;
+       file "all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db";
+};
+
 include "siginterval.conf";
 
 include "trusted.conf";
index d89287f1bf9abfa5e07b2d96e8e9e683803519bf..7776f253448d64b2f5c739a05fc880f8ae47c38c 100644 (file)
@@ -670,3 +670,28 @@ $DSFROMKEY "$dnskeyname.key" > "dsset-delegation.${zone}$TP"
 cat "$infile" "${kskname}.key" "${zskname}.key" "${keyname}.key" \
     "${dnskeyname}.key" "dsset-delegation.${zone}$TP" >"$zonefile"
 "$SIGNER" -P -o "$zone" "$zonefile" > /dev/null
+
+#
+# A NSEC3 zone which is signed but only has a valid DNSKEY RRSet.
+#
+zone=all-but-dnskey-signed-with-nonexistent-key-nsec3.example
+infile=all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db.in
+zonefile=all-but-dnskey-signed-with-nonexistent-key-nsec3.example.db
+
+# these keys will be discarded
+kskname=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -3fk "$zone")
+zskname=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -3 "$zone")
+cat "$infile" "${kskname}.key" "${zskname}.key" >"$zonefile"
+"$SIGNER" -P -D -O full -3 - -o "$zone" "$zonefile" > /dev/null
+awk '$4 == "RRSIG" && $5 == "DNSKEY" { next }
+{ print }' "$zonefile.signed" > "$zonefile.badsigs"
+
+# these keys will be added to the final zone
+kskname=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -3fk "$zone")
+zskname=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -3 "$zone")
+cat "$infile" "${kskname}.key" "${zskname}.key" >"$zonefile"
+"$SIGNER" -P -D -O full -3 - -o "$zone" "$zonefile" > /dev/null
+awk ' $4 == "RRSIG" && $5 == "DNSKEY" { print }
+{ next }' "$zonefile.signed" > "$zonefile.goodsigs"
+echo '$INCLUDE "'"$zonefile.goodsigs"'"' >> "$zonefile"
+echo '$INCLUDE "'"$zonefile.badsigs"'"' >> "$zonefile"
index fecf5048558fac3d3179804fc123fbc25b174dfd..786c364f63460f57aca47ea8b3c0ebe750e8171b 100644 (file)
@@ -4421,5 +4421,31 @@ n=$((n+1))
 test "$ret" -eq 0 || echo_i "failed"
 status=$((status+ret))
 
+echo_i "check for validation deadlock - NSEC3 zone with only DNSKEY correctly signed ($n)"
+ret=0
+nextpart ns4/named.run > /dev/null
+zone=all-but-dnskey-signed-with-nonexistent-key-nsec3.example
+pattern="validating [0123456789ABCDEFGHIJKLMNOPQRSTUV]*.$zone/DS:"
+pattern="$pattern fetch/validator loop detected: aborting validation"
+dig_with_opts xx.$zone A @10.53.0.4 > dig.out.ns4.test$n || ret=1
+grep "status: SERVFAIL" dig.out.ns4.test$n > /dev/null || ret=1
+nextpart ns4/named.run | grep "$pattern" > /dev/null || ret=1
+n=$((n+1))
+test "$ret" -eq 0 || echo_i "failed"
+status=$((status+ret))
+
+echo_i "check for validation deadlock - undelegated unsigned zone with CNAME to apex ($n)"
+ret=0
+zone=notdelegated.example
+nextpart ns4/named.run > /dev/null
+dig_with_opts www.$zone A @10.53.0.3 > dig.out.ns3.test$n || ret=1
+grep "status: NOERROR" dig.out.ns3.test$n > /dev/null || ret=1
+dig_with_opts www.$zone A @10.53.0.4 > dig.out.ns4.test$n || ret=1
+grep "status: SERVFAIL" dig.out.ns4.test$n > /dev/null || ret=1
+nextpart ns4/named.run | grep "aborting validation" || ret=1
+n=$((n+1))
+test "$ret" -eq 0 || echo_i "failed"
+status=$((status+ret))
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1