]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
nsupdate: reject attempts to add NSEC3PARAM with excessive iterations
authorMark Andrews <marka@isc.org>
Fri, 23 Apr 2021 00:03:53 +0000 (10:03 +1000)
committerMark Andrews <marka@isc.org>
Thu, 29 Apr 2021 07:55:35 +0000 (17:55 +1000)
(cherry picked from commit 3fe75d9809902be38e49a409be3e688d78a2db2b)

bin/nsupdate/nsupdate.c
bin/tests/system/nsupdate/tests.sh

index d96071a49fb2609f8fb771e906fc4a4c95e43c7b..b2b45d69e92430724f019ed43e0ad04c95ab9209 100644 (file)
@@ -56,6 +56,7 @@
 #include <dns/masterdump.h>
 #include <dns/message.h>
 #include <dns/name.h>
+#include <dns/nsec3.h>
 #include <dns/rcode.h>
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
@@ -1979,6 +1980,19 @@ parseclass:
                }
        }
 
+       if (!isdelete && rdata->type == dns_rdatatype_nsec3param) {
+               dns_rdata_nsec3param_t nsec3param;
+
+               result = dns_rdata_tostruct(rdata, &nsec3param, NULL);
+               check_result(result, "dns_rdata_tostruct");
+               if (nsec3param.iterations > dns_nsec3_maxiterations()) {
+                       fprintf(stderr,
+                               "NSEC3PARAM has excessive iterations (> %u)\n",
+                               dns_nsec3_maxiterations());
+                       goto failure;
+               }
+       }
+
 doneparsing:
 
        result = dns_message_gettemprdatalist(updatemsg, &rdatalist);
index 463f11f69e1879c376f6d8017dda11fe0da52a9a..9e892747d5f9fb9858f11ee7035cefddb8536e42 100755 (executable)
@@ -1132,6 +1132,10 @@ grep "UPDATE, status: NOERROR" nsupdate.out-$n > /dev/null 2>&1 || ret=1
 grep "UPDATE, status: FORMERR" nsupdate.out-$n > /dev/null 2>&1 || ret=1
 [ $ret = 0 ] || { echo_i "failed"; status=1; }
 
+
+
+n=`expr $n + 1`
+ret=0
 echo_i "check that DS to the zone apex is ignored ($n)"
 $DIG $DIGOPTS +tcp +norec example DS @10.53.0.3 > dig.out.pre.test$n || ret=1
 grep "status: NOERROR" dig.out.pre.test$n > /dev/null || ret=1
@@ -1151,7 +1155,20 @@ grep "status: NOERROR" dig.out.post.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.post.test$n > /dev/null || ret=1
 [ $ret = 0 ] || { echo_i "failed"; status=1; }
 
-if $FEATURETEST --gssapi ; then
+n=`expr $n + 1`
+ret=0
+echo_i "check that excessive NSEC3PARAM iterations are rejected by nsupdate ($n)"
+$NSUPDATE -d <<END > nsupdate.out-$n 2>&1 && ret=1
+server 10.53.0.3 ${PORT}
+zone example
+update add example 0 in NSEC3PARAM 1 0 151 -
+END
+grep "NSEC3PARAM has excessive iterations (> 150)" nsupdate.out-$n || ret=1
+[ $ret = 0 ] || { echo_i "failed"; status=1; }
+
+if ! $FEATURETEST --gssapi ; then
+  echo_i "SKIPPED: GSSAPI tests"
+else
   n=`expr $n + 1`
   ret=0
   echo_i "check krb5-self match ($n)"