]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add DNSSEC EDE test for unsupported digest and alg
authorColin Vidal <colin@isc.org>
Mon, 20 Jan 2025 19:59:23 +0000 (20:59 +0100)
committerColin Vidal <colin@isc.org>
Fri, 24 Jan 2025 12:26:30 +0000 (12:26 +0000)
A DNSSEC validation can fail in the case where multiple DNSKEY are
available for a zone and none of them are supported, but for different
reasons: one has a DS record in the parent zone using an unsupported
digest while the other one uses an unsupported encryption algorithm.

Add a specific test case covering this flow and making sure that two
extended DNS error are provided: code 1 and 2, each of them highlighting
unsupported algorithm and digest.

bin/tests/system/dnssec/ns2/example.db.in
bin/tests/system/dnssec/ns2/sign.sh
bin/tests/system/dnssec/ns3/digest-alg-unsupported.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/ns4/named1.conf.in
bin/tests/system/dnssec/ns4/named2.conf.in
bin/tests/system/dnssec/ns4/named3.conf.in
bin/tests/system/dnssec/ns4/named4.conf.in
bin/tests/system/dnssec/tests.sh
bin/tests/system/dnssec/tests_sh_dnssec.py

index 03246978c7c974a71ef431b2e525021803ef5111..93b7f708af14452ad84e74681c8bb83de8bce610 100644 (file)
@@ -105,6 +105,9 @@ ns.dnskey-unsupported       A       10.53.0.3
 ds-unsupported NS      ns.ds-unsupported
 ns.ds-unsupported      A       10.53.0.3
 
+digest-alg-unsupported    NS   ns.digest-alg-unsupported
+ns.digest-alg-unsupported A    10.53.0.3
+
 dnskey-nsec3-unknown   NS      ns.dnskey-nsec3-unknown
 ns.dnskey-nsec3-unknown        A       10.53.0.3
 
index 5d326c23c5d3f434762e2427b0b2c92fc42712ba..9ac57f776cdcd9af938d7092c0df2a2d5d7b8536 100644 (file)
@@ -56,7 +56,8 @@ infile=example.db.in
 zonefile=example.db
 
 # Get the DS records for the "example." zone.
-for subdomain in ds-unsupported secure badds bogus dynamic keyless nsec3 optout \
+for subdomain in digest-alg-unsupported ds-unsupported secure badds \
+  bogus dynamic keyless nsec3 optout \
   nsec3-unknown optout-unknown multiple rsasha256 rsasha512 \
   kskonly update-nsec3 auto-nsec auto-nsec3 secure.below-cname \
   ttlpatch split-dnssec split-smart expired expiring upper lower \
diff --git a/bin/tests/system/dnssec/ns3/digest-alg-unsupported.example.db.in b/bin/tests/system/dnssec/ns3/digest-alg-unsupported.example.db.in
new file mode 100644 (file)
index 0000000..94fa465
--- /dev/null
@@ -0,0 +1,22 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; SPDX-License-Identifier: MPL-2.0
+;
+; 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 https://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      ns
+ns                     A       10.53.0.3
+a                      A       10.0.0.1
index 1d7157b93b6b8ef21a03440ace769adcb7da28aa..293ff2dda8f1d014632e2ae21a732dd804d88d7d 100644 (file)
@@ -195,6 +195,12 @@ zone "dnskey-unknown.example" {
        file "dnskey-unknown.example.db.signed";
 };
 
+zone "digest-alg-unsupported.example" {
+       type primary;
+       file "digest-alg-unsupported.example.db.signed";
+       allow-update { any; };
+};
+
 zone "ds-unsupported.example" {
        type primary;
        file "ds-unsupported.example.db.signed";
index cdf06f45d4ce0fadaf891546b9ed7bfbc2da05d4..5689979cf1131a389c89c4ab705df7719b74115e 100644 (file)
@@ -299,7 +299,31 @@ DSFILE="dsset-${zone}."
 $DSFROMKEY -A -f ${zonefile}.signed "$zone" >"$DSFILE"
 
 #
-# A zone which is fime by itself (supported alg and digest) but that is used
+# A zone which uses an unsupported algorithm for a DNSKEY and an unsupported
+# digest for another DNSKEY
+#
+zone=digest-alg-unsupported.example.
+infile=digest-alg-unsupported.example.db.in
+zonefile=digest-alg-unsupported.example.db
+
+cnameandkey=$("$KEYGEN" -T KEY -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -n host "cnameandkey.$zone")
+dnameandkey=$("$KEYGEN" -T KEY -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -n host "dnameandkey.$zone")
+keyname=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -n zone "$zone")
+keyname2=$("$KEYGEN" -q -a ED448 -b "$DEFAULT_BITS" -n zone "$zone")
+
+cat "$infile" "$cnameandkey.key" "$dnameandkey.key" "$keyname.key" "$keyname2.key" >"$zonefile"
+
+"$SIGNER" -z -D -o "$zone" "$zonefile" >/dev/null
+cat "$zonefile" "$zonefile".signed >"$zonefile".tmp
+mv "$zonefile".tmp "$zonefile".signed
+
+# override generated DS record file so we can set different digest to each keys
+DSFILE="dsset-${zone}"
+$DSFROMKEY -1 -A -f ${zonefile}.signed "$zone" | head -n 1 >"$DSFILE"
+$DSFROMKEY -2 -A -f ${zonefile}.signed "$zone" | tail -1 >>"$DSFILE"
+
+#
+# A zone which is fine by itself (supported algorithm) but that is used
 # to mimic unsupported DS digest (see ns8).
 #
 zone=ds-unsupported.example.
index 8d2d87141e1bc877cbec2115059a5f058595661a..4871f07879f992978a5774242f0d12ea86c6bece 100644 (file)
@@ -29,6 +29,8 @@ options {
        nta-recheck 9s;
        validate-except { corp; };
 
+       disable-algorithms "digest-alg-unsupported.example." { ED448; };
+       disable-ds-digests "digest-alg-unsupported.example." { "SHA1"; "SHA-1"; };
        disable-ds-digests "ds-unsupported.example." {"SHA1"; "SHA-1"; "SHA256"; "SHA-256"; "SHA384"; "SHA-384"; };
        disable-algorithms "badalg.secure.example." { ECDSAP256SHA256; };
 
index 82c8ecfffc85c2ffad53275a59a0fa54f26f2611..7f1188830bc776d79be366a1a5dabf7a94ab0ed8 100644 (file)
@@ -25,6 +25,8 @@ options {
        dnssec-validation auto;
        bindkeys-file "managed.conf";
        minimal-responses no;
+       disable-algorithms "digest-alg-unsupported.example." { ED448; };
+       disable-ds-digests "digest-alg-unsupported.example." { "SHA1"; "SHA-1"; };
        disable-ds-digests "ds-unsupported.example." {"SHA1"; "SHA-1"; "SHA256"; "SHA-256"; "SHA384"; "SHA-384"; };
        disable-algorithms "badalg.secure.example." { ECDSAP256SHA256; };
 };
index 4b9e93cc5aa512132ce00b1d52810b0606156af8..d90ffb05319729e155027d9d9ba66707b04d2e1c 100644 (file)
@@ -26,6 +26,8 @@ options {
        bindkeys-file "managed.conf";
        dnssec-accept-expired yes;
        minimal-responses no;
+       disable-algorithms "digest-alg-unsupported.example." { ED448; };
+       disable-ds-digests "digest-alg-unsupported.example." { "SHA1"; "SHA-1"; };
        disable-ds-digests "ds-unsupported.example." {"SHA1"; "SHA-1"; "SHA256"; "SHA-256"; "SHA384"; "SHA-384"; };
        disable-algorithms "badalg.secure.example." { ECDSAP256SHA256; };
 };
index 9cda7eb456555c942eed7107fa0490732b17f920..1a8d917ca86f5c7c9efe2ce92e3866c09d598baf 100644 (file)
@@ -21,6 +21,8 @@ options {
        pid-file "named.pid";
        listen-on { 10.53.0.4; };
        listen-on-v6 { none; };
+       disable-algorithms "digest-alg-unsupported.example." { ED448; };
+       disable-ds-digests "digest-alg-unsupported.example." { "SHA1"; "SHA-1"; };
        disable-ds-digests "ds-unsupported.example." {"SHA1"; "SHA-1"; "SHA256"; "SHA-256"; "SHA384"; "SHA-384"; };
        disable-algorithms "badalg.secure.example." { ECDSAP256SHA256; };
 };
index cd85e8e7ff085be0cb97649b94fdac5ced57e241..9306e0e6d6c50230939e03fa823e8cca9eeba533 100644 (file)
@@ -3701,6 +3701,16 @@ n=$((n + 1))
 test "$ret" -eq 0 || echo_i "failed"
 status=$((status + ret))
 
+echo_i "checking both EDE code 1 and 2 for unsupported digest on one DNSKEY and alg on the other ($n)"
+ret=0
+dig_with_opts @10.53.0.4 a.digest-alg-unsupported.example >dig.out.ns4.test$n || ret=1
+grep "; EDE: 1 (Unsupported DNSKEY Algorithm): (ED448 digest-alg-unsupported.example/DNSKEY)" dig.out.ns4.test$n >/dev/null || ret=1
+grep "; EDE: 2 (Unsupported DS Digest Type): (SHA-1 digest-alg-unsupported.example/DNSKEY)" dig.out.ns4.test$n >/dev/null || ret=1
+grep "flags:.*ad.*QUERY" dig.out.ns4.test$n >/dev/null && ret=1
+n=$((n + 1))
+test "$ret" -eq 0 || echo_i "failed"
+status=$((status + ret))
+
 echo_i "checking that unsupported DNSKEY algorithm is in DNSKEY RRset ($n)"
 ret=0
 dig_with_opts +noauth +noadd +nodnssec +adflag @10.53.0.3 dnskey-unsupported-2.example DNSKEY >dig.out.test$n
index bd7cd111c221bad906b5ad599946054d08034e96..c7e4d9df7e9e546412b21b55bef6462fafe561cf 100644 (file)
@@ -83,6 +83,7 @@ pytestmark = pytest.mark.extra_artifacts(
         "ns3/dnskey-unsupported.example.db",
         "ns3/dnskey-unsupported.example.db.tmp",
         "ns3/dynamic.example.db",
+        "ns3/digest-alg-unsupported.example.db",
         "ns3/enabled.managed.db",
         "ns3/enabled.trusted.db",
         "ns3/example.bk",