From 23775c6006ecf68d1da6b08488dd8242173bbd4d Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 29 Nov 2024 17:20:39 +1100 Subject: [PATCH 1/2] Do not sign non DNSKEY RRset with revoked keys It does not make sense to sign RRsets other than DNSKEY with revoked keys. --- bin/dnssec/dnssec-signzone.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index eece8554f9..bb707b85d2 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -673,6 +673,10 @@ signset(dns_diff_t *del, dns_diff_t *add, dns_dbnode_t *node, dns_name_t *name, for (key = ISC_LIST_HEAD(keylist); key != NULL; key = ISC_LIST_NEXT(key, link)) { + if (REVOKE(key->key) && set->type != dns_rdatatype_dnskey) { + continue; + } + if (nowsignedby[key->index]) { continue; } From 30ef6dde059a4c7d0cb8b12a572af7e1dfc450df Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 2 Dec 2024 18:30:41 +1100 Subject: [PATCH 2/2] Check dnssec-signzone behaviour with revoked keys Only DNSKEY records should be signed with a revoked key. --- bin/tests/system/dnssec/tests.sh | 29 ++++++++++++++++++++++ bin/tests/system/dnssec/tests_sh_dnssec.py | 1 + 2 files changed, 30 insertions(+) diff --git a/bin/tests/system/dnssec/tests.sh b/bin/tests/system/dnssec/tests.sh index 839384217b..d94c267074 100644 --- a/bin/tests/system/dnssec/tests.sh +++ b/bin/tests/system/dnssec/tests.sh @@ -4517,5 +4517,34 @@ n=$((n + 1)) if [ "$ret" -ne 0 ]; then echo_i "failed"; fi status=$((status + ret)) +echo_i "checking that records other than DNSKEY are not signed by a revoked key by dnssec-signzone ($n)" +ret=0 +( + cd signer || exit 0 + key1=$(${KEYGEN} -a "${DEFAULT_ALGORITHM}" -f KSK revoke.example) + key2=$(${KEYGEN} -a "${DEFAULT_ALGORITHM}" -f KSK revoke.example) + key3=$(${KEYGEN} -a "${DEFAULT_ALGORITHM}" revoke.example) + rkey=$(${REVOKE} "$key2") + cat >>revoke.example.db <>revoke.example.db + "${SIGNER}" -o revoke.example revoke.example.db >signer.out.$n +) || ret=1 +keycount=$(grep -c "RRSIG.DNSKEY ${DEFAULT_ALGORITHM_NUMBER} " signer/revoke.example.db.signed) +cdscount=$(grep -c "RRSIG.CDS ${DEFAULT_ALGORITHM_NUMBER} " signer/revoke.example.db.signed) +soacount=$(grep -c "RRSIG.SOA ${DEFAULT_ALGORITHM_NUMBER} " signer/revoke.example.db.signed) +[ $keycount -eq 3 ] || ret=1 +[ $cdscount -eq 2 ] || ret=1 +[ $soacount -eq 1 ] || ret=1 +n=$((n + 1)) +if [ "$ret" -ne 0 ]; then echo_i "failed"; fi +status=$((status + ret)) + echo_i "exit status: $status" [ $status -eq 0 ] || exit 1 diff --git a/bin/tests/system/dnssec/tests_sh_dnssec.py b/bin/tests/system/dnssec/tests_sh_dnssec.py index bc2dd05ed3..b0e9a55871 100644 --- a/bin/tests/system/dnssec/tests_sh_dnssec.py +++ b/bin/tests/system/dnssec/tests_sh_dnssec.py @@ -151,6 +151,7 @@ "signer/general/signer.out.*", "signer/nsec3param.out", "signer/prepub.db", + "signer/revoke.example.db", "signer/signer.err.*", "signer/signer.out.*", ]