]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
dnssec: do not publish CDS records when -Psync is in the future
authorTony Finch <dot@dotat.at>
Tue, 14 Jan 2020 19:23:31 +0000 (19:23 +0000)
committerMark Andrews <marka@isc.org>
Tue, 21 Jan 2020 05:39:31 +0000 (16:39 +1100)
This is a bug I encountered when trying to schedule an algorithm
rollover. My plan, for a zone whose maximum TTL is 48h, was to sign
with the new algorithm and schedule a change of CDS records for more
than 48 hours in the future, roughly like this:

    $ dnssec-keygen -a 13 -fk -Psync now+50h $zone
    $ dnssec-keygen -a 13 $zone
    $ dnssec-settime -Dsync now+50h $zone_ksk_old

However the algorithm 13 CDS was published immediately, which could
have made the zone bogus.

To reveal the bug using the `smartsign` test, this change just adds a
KSK with all its times in the future, so it should not affect the
existing checks at all. But the final check (that there are no CDS or
CDSNSKEY records after -Dsync) fails with the old `syncpublish()`
logic, because the future key's sync records appear early. With the
new `syncpublish()` logic the future key does not affect the test, as
expected, and it now passes.

bin/tests/system/smartsign/tests.sh
lib/dns/dnssec.c

index 59aa0b17f0e599af72768a2dc8fc4d7e1283421d..534aa117a9b46582de98326b1bd83a5aafdbc0ba 100644 (file)
@@ -55,6 +55,9 @@ cksk4=`$REVOKE $cksk3`
 echo_i "setting up sync key"
 cksk5=`$KEYGEN -q -a rsasha1 -fk -P now+1mo -A now+1mo -Psync now $czone`
 
+echo_i "and future sync key"
+cksk6=`$KEYGEN -q -a rsasha1 -fk -P now+1mo -A now+1mo -Psync now+1mo $czone`
+
 echo_i "generating parent keys"
 pzsk=`$KEYGEN -q -a rsasha1 $pzone`
 pksk=`$KEYGEN -q -a rsasha1 -fk $pzone`
@@ -348,6 +351,7 @@ awk 'BEGIN { r=1 } $2 == "CDS" { r=0 } END { exit r }' $cfile.signed || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
+# this also checks that the future sync record is not yet published
 echo_i "checking sync record deletion"
 ret=0
 $SETTIME -P now -A now -Dsync now ${cksk5} > /dev/null
index df8d8e7c415cf06358c66aa027daea6d7e06e027..f448113193a765714fe48b15336979708f4f6bbe 100644 (file)
@@ -648,6 +648,7 @@ syncpublish(dst_key_t *key, isc_stdtime_t now) {
        isc_stdtime_t when;
        dst_key_state_t state;
        int major, minor;
+       bool publish;
 
        /*
         * Is this an old-style key?
@@ -670,18 +671,16 @@ syncpublish(dst_key_t *key, isc_stdtime_t now) {
        }
 
        /* If no kasp state, check timings. */
+       publish = false;
        result = dst_key_gettime(key, DST_TIME_SYNCPUBLISH, &when);
-       if (result != ISC_R_SUCCESS) {
-               return (false);
+       if (result == ISC_R_SUCCESS && when < now) {
+               publish = true;
        }
        result = dst_key_gettime(key, DST_TIME_SYNCDELETE, &when);
-       if (result != ISC_R_SUCCESS) {
-               return (true);
-       }
-       if (when <= now) {
-               return (false);
+       if (result == ISC_R_SUCCESS && when < now) {
+               publish = false;
        }
-       return (true);
+       return (publish);
 }
 
 /*%<