diff --git a/backport-0001-CVE-2024-1737.patch b/backport-0001-CVE-2024-1737.patch new file mode 100644 index 0000000000000000000000000000000000000000..6bc6202df82ae518220b76db6c5536b1219aedf3 --- /dev/null +++ b/backport-0001-CVE-2024-1737.patch @@ -0,0 +1,94 @@ +From fdabf4b9570a60688f9f7d1e88d885f7a3718bca Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= +Date: Fri, 1 Mar 2024 08:26:07 +0100 +Subject: [PATCH 1/3] Add a limit to the number of RRs in RRSets + +Previously, the number of RRs in the RRSets were internally unlimited. +As the data structure that holds the RRs is just a linked list, and +there are places where we just walk through all of the RRs, adding an +RRSet with huge number of RRs inside would slow down processing of said +RRSets. + +The fix for end-of-life branches make the limit compile-time only for +simplicity and the limit can be changed at the compile time by adding +following define to CFLAGS: + + -DDNS_RDATASET_MAX_RECORDS= + +(cherry picked from commit c5c4d00c38530390c9e1ae4c98b65fbbadfe9e5e) + +Conflict:NA +Reference:https://gitlab.isc.org/isc-projects/bind9/-/commit/5360c90612abf51deb4a80b30e1da84fd61212a5 + +--- + configure | 2 +- + configure.ac | 2 +- + lib/dns/rdataslab.c | 12 ++++++++++++ + 3 files changed, 14 insertions(+), 2 deletions(-) + +diff --git a/configure b/configure +index ed2d486..bdfd59f 100755 +--- a/configure ++++ b/configure +@@ -12295,7 +12295,7 @@ fi + + XTARGETS= + if test "$enable_developer" = "yes"; then : +- STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1" ++ STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DDNS_RDATASET_MAX_RECORDS=5000" + test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes + test "${enable_querytrace+set}" = set || enable_querytrace=yes + test "${with_cmocka+set}" = set || with_cmocka=yes +diff --git a/configure.ac b/configure.ac +index cb8e841..5be8c76 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -94,7 +94,7 @@ AC_ARG_ENABLE([developer], + + XTARGETS= + AS_IF([test "$enable_developer" = "yes"], +- [STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1" ++ [STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DDNS_RDATASET_MAX_RECORDS=5000" + test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes + test "${enable_querytrace+set}" = set || enable_querytrace=yes + test "${with_cmocka+set}" = set || with_cmocka=yes +diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c +index 1d5e88f..dda9038 100644 +--- a/lib/dns/rdataslab.c ++++ b/lib/dns/rdataslab.c +@@ -110,6 +110,10 @@ fillin_offsets(unsigned char *offsetbase, unsigned int *offsettable, + } + #endif /* if DNS_RDATASET_FIXED */ + ++#ifndef DNS_RDATASET_MAX_RECORDS ++#define DNS_RDATASET_MAX_RECORDS 100 ++#endif /* DNS_RDATASET_MAX_RECORDS */ ++ + isc_result_t + dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, + isc_region_t *region, unsigned int reservelen) { +@@ -154,6 +158,10 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, + return (ISC_R_SUCCESS); + } + ++ if (nitems > DNS_RDATASET_MAX_RECORDS) { ++ return (DNS_R_TOOMANYRECORDS); ++ } ++ + if (nitems > 0xffff) { + return (ISC_R_NOSPACE); + } +@@ -520,6 +528,10 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab, + #endif /* if DNS_RDATASET_FIXED */ + INSIST(ocount > 0 && ncount > 0); + ++ if (ocount + ncount > DNS_RDATASET_MAX_RECORDS) { ++ return (DNS_R_TOOMANYRECORDS); ++ } ++ + #if DNS_RDATASET_FIXED + oncount = ncount; + #endif /* if DNS_RDATASET_FIXED */ +-- +2.33.0 + diff --git a/backport-0002-CVE-2024-1737.patch b/backport-0002-CVE-2024-1737.patch new file mode 100644 index 0000000000000000000000000000000000000000..d20c9f25269ccb4ae698ed3399cd66907a5267ec --- /dev/null +++ b/backport-0002-CVE-2024-1737.patch @@ -0,0 +1,123 @@ +From dfcadc2085c8844b5836aff2b5ea51fb60c34868 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= +Date: Wed, 29 May 2024 08:43:39 +0200 +Subject: [PATCH 2/3] Add a limit to the number of RR types for single name + +Previously, the number of RR types for a single owner name was limited +only by the maximum number of the types (64k). As the data structure +that holds the RR types for the database node is just a linked list, and +there are places where we just walk through the whole list (again and +again), adding a large number of RR types for a single owner named with +would slow down processing of such name (database node). + +Add a hard-coded limit (100) to cap the number of the RR types for a single +owner. The limit can be changed at the compile time by adding following +define to CFLAGS: + + -DDNS_RBTDB_MAX_RTYPES= + +Conflict:Context Adaptation +Reference:https://gitlab.isc.org/isc-projects/bind9/-/commit/5360c90612abf51deb4a80b30e1da84fd61212a5 + +--- + configure | 2 +- + configure.ac | 2 +- + lib/dns/rbtdb.c | 17 +++++++++++++++++ + 3 files changed, 19 insertions(+), 2 deletions(-) + +diff --git a/configure b/configure +index bdfd59f..be0f60e 100755 +--- a/configure ++++ b/configure +@@ -12295,7 +12295,7 @@ fi + + XTARGETS= + if test "$enable_developer" = "yes"; then : +- STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DDNS_RDATASET_MAX_RECORDS=5000" ++ STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DDNS_RDATASET_MAX_RECORDS=5000 -DDNS_RBTDB_MAX_RTYPES=5000" + test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes + test "${enable_querytrace+set}" = set || enable_querytrace=yes + test "${with_cmocka+set}" = set || with_cmocka=yes +diff --git a/configure.ac b/configure.ac +index 5be8c76..92b0234 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -94,7 +94,7 @@ AC_ARG_ENABLE([developer], + + XTARGETS= + AS_IF([test "$enable_developer" = "yes"], +- [STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DDNS_RDATASET_MAX_RECORDS=5000" ++ [STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DDNS_RDATASET_MAX_RECORDS=5000 -DDNS_RBTDB_MAX_RTYPES=5000" + test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes + test "${enable_querytrace+set}" = set || enable_querytrace=yes + test "${with_cmocka+set}" = set || with_cmocka=yes +diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c +index d86ed64..be77250 100644 +--- a/lib/dns/rbtdb.c ++++ b/lib/dns/rbtdb.c +@@ -6196,6 +6196,10 @@ update_recordsandxfrsize(bool add, rbtdb_version_t *rbtversion, + RWUNLOCK(&rbtversion->rwlock, isc_rwlocktype_write); + } + ++#ifndef DNS_RBTDB_MAX_RTYPES ++#define DNS_RBTDB_MAX_RTYPES 100 ++#endif /* DNS_RBTDB_MAX_RTYPES */ ++ + /* + * write lock on rbtnode must be held. + */ +@@ -6217,6 +6221,7 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + rbtdb_rdatatype_t negtype, sigtype; + dns_trust_t trust; + int idx; ++ uint32_t ntypes; + + /* + * Add an rdatasetheader_t to a node. +@@ -6280,6 +6285,7 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + set_ttl(rbtdb, topheader, 0); + mark_header_ancient(rbtdb, topheader); + } ++ ntypes = 0; + goto find_header; + } + /* +@@ -6302,8 +6308,10 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + * check for an extant non-ancient NODATA ncache + * entry which covers the same type as the RRSIG. + */ ++ ntypes = 0; + for (topheader = rbtnode->data; topheader != NULL; + topheader = topheader->next) { ++ ntypes++; + if ((topheader->type == + RBTDB_RDATATYPE_NCACHEANY) || + (newheader->type == sigtype && +@@ -6347,8 +6355,10 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + } + } + ++ ntypes = 0; + for (topheader = rbtnode->data; topheader != NULL; + topheader = topheader->next) { ++ ntypes++; + if (prio_type(topheader->type)) { + prioheader = topheader; + } +@@ -6733,6 +6743,13 @@ find_header: + /* + * No rdatasets of the given type exist at the node. + */ ++ ++ if (ntypes > DNS_RBTDB_MAX_RTYPES) { ++ free_rdataset(rbtdb, rbtdb->common.mctx, ++ newheader); ++ return (ISC_R_QUOTA); ++ } ++ + newheader->down = NULL; + + if (prio_type(newheader->type)) { +-- +2.33.0 + diff --git a/backport-0003-CVE-2024-1737.patch b/backport-0003-CVE-2024-1737.patch new file mode 100644 index 0000000000000000000000000000000000000000..d9646f4cdd0ef42850f735d0cc1969967457d0d8 --- /dev/null +++ b/backport-0003-CVE-2024-1737.patch @@ -0,0 +1,56 @@ +From b27c6bcce894786a8e082eafd59eccbf6f2731cb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= +Date: Mon, 17 Jun 2024 11:40:40 +0200 +Subject: [PATCH] Expand the list of the priority types and move it to db_p.h + +Add HTTPS, SVCB, SRV, PTR, NAPTR, DNSKEY and TXT records to the list of +the priority types that are put at the beginning of the slabheader list +for faster access and to avoid eviction when there are more types than +the max-types-per-name limit. + +Conflict:NA +Reference:https://gitlab.isc.org/isc-projects/bind9/-/commit/b27c6bcce894786a8e082eafd59eccbf6f2731cb + +--- + lib/dns/rbtdb.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c +index be77250..ca654e6 100644 +--- a/lib/dns/rbtdb.c ++++ b/lib/dns/rbtdb.c +@@ -974,6 +974,8 @@ prio_type(rbtdb_rdatatype_t type) { + case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_soa): + case dns_rdatatype_a: + case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_a): ++ case dns_rdatatype_mx: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_mx): + case dns_rdatatype_aaaa: + case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_aaaa): + case dns_rdatatype_nsec: +@@ -986,6 +988,22 @@ prio_type(rbtdb_rdatatype_t type) { + case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_ds): + case dns_rdatatype_cname: + case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_cname): ++ case dns_rdatatype_dname: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_dname): ++ case dns_rdatatype_svcb: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_svcb): ++ case dns_rdatatype_https: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_https): ++ case dns_rdatatype_dnskey: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_dnskey): ++ case dns_rdatatype_srv: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_srv): ++ case dns_rdatatype_txt: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_txt): ++ case dns_rdatatype_ptr: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_ptr): ++ case dns_rdatatype_naptr: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_naptr): + return (true); + } + return (false); +-- +2.33.0 + diff --git a/backport-0004-CVE-2024-1737.patch b/backport-0004-CVE-2024-1737.patch new file mode 100644 index 0000000000000000000000000000000000000000..9c38683dbb7e25a7049cf8f1b38a329203eeb1d2 --- /dev/null +++ b/backport-0004-CVE-2024-1737.patch @@ -0,0 +1,179 @@ +From 57cd34441a1b4ecc9874a4a106c2c95b8d7a3120 Mon Sep 17 00:00:00 2001 +From: =?utf-8?b?T25kxZllaiBTdXLDvQ==?= +Date: Mon, 17 Jun 2024 11:40:40 +0200 +Subject: Be smarter about refusing to add many RR types to the database + +Instead of outright refusing to add new RR types to the cache, be a bit +smarter: + +1. If the new header type is in our priority list, we always add either + positive or negative entry at the beginning of the list. + +2. If the new header type is negative entry, and we are over the limit, + we mark it as ancient immediately, so it gets evicted from the cache + as soon as possible. + +3. Otherwise add the new header after the priority headers (or at the + head of the list). + +4. If we are over the limit, evict the last entry on the normal header + list. + +(cherry picked from commit 57cd34441a1b4ecc9874a4a106c2c95b8d7a3120) + +Conflict:NA +Reference:https://gitlab.isc.org/isc-projects/bind9/-/commit/57cd34441a1b4ecc9874a4a106c2c95b8d7a3120 + +--- + lib/dns/rbtdb.c | 68 +++++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 57 insertions(+), 11 deletions(-) + +diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c +index ca654e6..a6da874 100644 +--- a/lib/dns/rbtdb.c ++++ b/lib/dns/rbtdb.c +@@ -6218,6 +6218,26 @@ update_recordsandxfrsize(bool add, rbtdb_version_t *rbtversion, + #define DNS_RBTDB_MAX_RTYPES 100 + #endif /* DNS_RBTDB_MAX_RTYPES */ + ++static bool ++overmaxtype(dns_rbtdb_t *rbtdb, uint32_t ntypes) { ++ UNUSED(rbtdb); ++ ++ if (DNS_RBTDB_MAX_RTYPES == 0) { ++ return (false); ++ } ++ ++ return (ntypes >= DNS_RBTDB_MAX_RTYPES); ++} ++ ++static bool ++prio_header(rdatasetheader_t *header) { ++ if (NEGATIVE(header) && prio_type(RBTDB_RDATATYPE_EXT(header->type))) { ++ return (true); ++ } ++ ++ return (prio_type(header->type)); ++} ++ + /* + * write lock on rbtnode must be held. + */ +@@ -6229,7 +6249,7 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + rbtdb_changed_t *changed = NULL; + rdatasetheader_t *topheader = NULL, *topheader_prev = NULL; + rdatasetheader_t *header = NULL, *sigheader = NULL; +- rdatasetheader_t *prioheader = NULL; ++ rdatasetheader_t *prioheader = NULL, *expireheader = NULL; + unsigned char *merged = NULL; + isc_result_t result; + bool header_nx; +@@ -6239,7 +6259,7 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + rbtdb_rdatatype_t negtype, sigtype; + dns_trust_t trust; + int idx; +- uint32_t ntypes; ++ uint32_t ntypes = 0; + + /* + * Add an rdatasetheader_t to a node. +@@ -6303,7 +6323,6 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + set_ttl(rbtdb, topheader, 0); + mark_header_ancient(rbtdb, topheader); + } +- ntypes = 0; + goto find_header; + } + /* +@@ -6314,6 +6333,7 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + topheader = topheader->next) { + if (topheader->type == sigtype) { + sigheader = topheader; ++ break; + } + } + negtype = RBTDB_RDATATYPE_VALUE(covers, 0); +@@ -6326,10 +6346,8 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + * check for an extant non-ancient NODATA ncache + * entry which covers the same type as the RRSIG. + */ +- ntypes = 0; + for (topheader = rbtnode->data; topheader != NULL; + topheader = topheader->next) { +- ntypes++; + if ((topheader->type == + RBTDB_RDATATYPE_NCACHEANY) || + (newheader->type == sigtype && +@@ -6373,11 +6391,15 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + } + } + +- ntypes = 0; + for (topheader = rbtnode->data; topheader != NULL; + topheader = topheader->next) { +- ntypes++; +- if (prio_type(topheader->type)) { ++ if (IS_CACHE(rbtdb) && ACTIVE(topheader, now)) { ++ ++ntypes; ++ expireheader = topheader; ++ } else if (!IS_CACHE(rbtdb)) { ++ ++ntypes; ++ } ++ if (prio_header(topheader)) { + prioheader = topheader; + } + if (topheader->type == newheader->type || +@@ -6761,8 +6783,7 @@ find_header: + /* + * No rdatasets of the given type exist at the node. + */ +- +- if (ntypes > DNS_RBTDB_MAX_RTYPES) { ++ if (!IS_CACHE(rbtdb) && overmaxtype(rbtdb, ntypes)) { + free_rdataset(rbtdb, rbtdb->common.mctx, + newheader); + return (ISC_R_QUOTA); +@@ -6770,7 +6791,7 @@ find_header: + + newheader->down = NULL; + +- if (prio_type(newheader->type)) { ++ if (prio_header(newheader)) { + /* This is a priority type, prepend it */ + newheader->next = rbtnode->data; + rbtnode->data = newheader; +@@ -6783,6 +6804,31 @@ find_header: + newheader->next = rbtnode->data; + rbtnode->data = newheader; + } ++ ++ if (IS_CACHE(rbtdb) && overmaxtype(rbtdb, ntypes)) { ++ if (expireheader == NULL) { ++ expireheader = newheader; ++ } ++ if (NEGATIVE(newheader) && ++ !prio_header(newheader)) ++ { ++ /* ++ * Add the new non-priority negative ++ * header to the database only ++ * temporarily. ++ */ ++ expireheader = newheader; ++ } ++ ++ set_ttl(rbtdb, expireheader, 0); ++ mark_header_ancient(rbtdb, expireheader); ++ /* ++ * FIXME: In theory, we should mark the RRSIG ++ * and the header at the same time, but there is ++ * no direct link between those two header, so ++ * we would have to check the whole list again. ++ */ ++ } + } + } + +-- +2.33.0 + diff --git a/backport-CVE-2024-1975.patch b/backport-CVE-2024-1975.patch new file mode 100644 index 0000000000000000000000000000000000000000..1b0b3245ef18deee23b309602e005c97419709a4 --- /dev/null +++ b/backport-CVE-2024-1975.patch @@ -0,0 +1,268 @@ +From bef3d2cca3552100bbe44790c8c1a4f5bef06798 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= +Date: Thu, 16 May 2024 12:10:41 +0200 +Subject: [PATCH] Remove support for SIG(0) message verification + +Conflict:Case adaptation and some documents are not incorporated. +Reference:https://downloads.isc.org/isc/bind9/9.18.28/patches/0003-CVE-2024-1975.patch + +--- + bin/tests/system/tsiggss/authsock.pl | 5 ++ + bin/tests/system/tsiggss/tests.sh | 12 ++-- + bin/tests/system/upforwd/tests.sh | 9 ++- + doc/arm/general.rst | 6 +- + lib/dns/message.c | 99 ++-------------------------- + lib/ns/client.c | 7 ++ + 6 files changed, 33 insertions(+), 105 deletions(-) + +diff --git a/bin/tests/system/tsiggss/authsock.pl b/bin/tests/system/tsiggss/authsock.pl +index ab3833d..0b231ee 100644 +--- a/bin/tests/system/tsiggss/authsock.pl ++++ b/bin/tests/system/tsiggss/authsock.pl +@@ -31,6 +31,10 @@ if (!defined($path)) { + exit(1); + } + ++# Enable output autoflush so that it's not lost when the parent sends TERM. ++select STDOUT; ++$| = 1; ++ + unlink($path); + my $server = IO::Socket::UNIX->new(Local => $path, Type => SOCK_STREAM, Listen => 8) or + die "unable to create socket $path"; +@@ -53,6 +57,7 @@ if ($timeout != 0) { + } + + while (my $client = $server->accept()) { ++ printf("accept()\n"); + $client->recv(my $buf, 8, 0); + my ($version, $req_len) = unpack('N N', $buf); + +diff --git a/bin/tests/system/tsiggss/tests.sh b/bin/tests/system/tsiggss/tests.sh +index 632bb87..4b8a903 100644 +--- a/bin/tests/system/tsiggss/tests.sh ++++ b/bin/tests/system/tsiggss/tests.sh +@@ -116,7 +116,7 @@ status=$((status+ret)) + + echo_i "testing external update policy (CNAME) with auth sock ($n)" + ret=0 +-$PERL ./authsock.pl --type=CNAME --path=ns1/auth.sock --pidfile=authsock.pid --timeout=120 > /dev/null 2>&1 & ++$PERL ./authsock.pl --type=CNAME --path=ns1/auth.sock --pidfile=authsock.pid --timeout=120 > authsock.log 2>&1 & + sleep 1 + test_update $n testcname.example.nil. CNAME "86400 CNAME testdenied.example.nil" "testdenied" || ret=1 + n=$((n+1)) +@@ -130,17 +130,19 @@ n=$((n+1)) + if [ "$ret" -ne 0 ]; then echo_i "failed"; fi + status=$((status+ret)) + +-echo_i "testing external policy with SIG(0) key ($n)" ++echo_i "testing external policy with unsupported SIG(0) key ($n)" + ret=0 +-$NSUPDATE -k ns1/Kkey.example.nil.*.private < /dev/null 2>&1 || ret=1 ++$NSUPDATE -d -k ns1/Kkey.example.nil.*.private <nsupdate.out${n} 2>&1 || true ++debug + server 10.53.0.1 ${PORT} + zone example.nil + update add fred.example.nil 120 cname foo.bar. + send + END + output=`$DIG $DIGOPTS +short cname fred.example.nil.` +-[ -n "$output" ] || ret=1 +-[ $ret -eq 0 ] || echo_i "failed" ++# update must have failed - SIG(0) signer is not supported ++[ -n "$output" ] && ret=1 ++grep -F "signer=key.example.nil" authsock.log >/dev/null && ret=1 + n=$((n+1)) + if [ "$ret" -ne 0 ]; then echo_i "failed"; fi + status=$((status+ret)) +diff --git a/bin/tests/system/upforwd/tests.sh b/bin/tests/system/upforwd/tests.sh +index 8062d68..fa64d22 100644 +--- a/bin/tests/system/upforwd/tests.sh ++++ b/bin/tests/system/upforwd/tests.sh +@@ -221,18 +221,21 @@ fi + + if test -f keyname + then +- echo_i "checking update forwarding to with sig0 ($n)" ++ echo_i "checking update forwarding to with sig0 (expected to fail) ($n)" + ret=0 + keyname=`cat keyname` +- $NSUPDATE -k $keyname.private -- - <nsupdate.out.$n 2>&1 && ret=1 + $DIG -p ${PORT} unsigned.example2 A @10.53.0.1 > dig.out.ns1.test$n +- grep "status: NOERROR" dig.out.ns1.test$n > /dev/null || ret=1 ++ grep "status: NOERROR" dig.out.ns1.test$n > /dev/null && ret=1 + if [ $ret != 0 ] ; then echo_i "failed"; fi + status=`expr $status + $ret` + n=`expr $n + 1` +diff --git a/doc/arm/general.rst b/doc/arm/general.rst +index 225576b..794767d 100644 +--- a/doc/arm/general.rst ++++ b/doc/arm/general.rst +@@ -534,10 +534,8 @@ than a non-authoritative response. This is considered a feature. + [2] CLASS ANY queries are not supported. This is considered a + feature. + +-[3] When receiving a query signed with a SIG(0), the server is +-only able to verify the signature if it has the key in its local +-authoritative data; it cannot do recursion or validation to +-retrieve unknown keys. ++[3] [#rfc2931] Support for SIG(0) message verification was removed ++ as part of the mitigation of CVE-2024-1975. + + [4] Compliance is with loading and serving of A6 records only. A6 records were moved + to the experimental category by :rfc:`3363`. +diff --git a/lib/dns/message.c b/lib/dns/message.c +index 500705e..339574a 100644 +--- a/lib/dns/message.c ++++ b/lib/dns/message.c +@@ -3331,113 +3331,26 @@ dns_message_dumpsig(dns_message_t *msg, char *txt1) { + + isc_result_t + dns_message_checksig(dns_message_t *msg, dns_view_t *view) { +- isc_buffer_t b, msgb; ++ isc_buffer_t msgb; + + REQUIRE(DNS_MESSAGE_VALID(msg)); + +- if (msg->tsigkey == NULL && msg->tsig == NULL && msg->sig0 == NULL) { ++ if (msg->tsigkey == NULL && msg->tsig == NULL) { + return (ISC_R_SUCCESS); + } + + INSIST(msg->saved.base != NULL); + isc_buffer_init(&msgb, msg->saved.base, msg->saved.length); + isc_buffer_add(&msgb, msg->saved.length); +- if (msg->tsigkey != NULL || msg->tsig != NULL) { + #ifdef SKAN_MSG_DEBUG +- dns_message_dumpsig(msg, "dns_message_checksig#1"); ++ dns_message_dumpsig(msg, "dns_message_checksig#1"); + #endif /* ifdef SKAN_MSG_DEBUG */ +- if (view != NULL) { +- return (dns_view_checksig(view, &msgb, msg)); +- } else { +- return (dns_tsig_verify(&msgb, msg, NULL, NULL)); +- } ++ if (view != NULL) { ++ return (dns_view_checksig(view, &msgb, msg)); + } else { +- dns_rdata_t rdata = DNS_RDATA_INIT; +- dns_rdata_sig_t sig; +- dns_rdataset_t keyset; +- isc_result_t result; +- +- result = dns_rdataset_first(msg->sig0); +- INSIST(result == ISC_R_SUCCESS); +- dns_rdataset_current(msg->sig0, &rdata); +- +- /* +- * This can occur when the message is a dynamic update, since +- * the rdata length checking is relaxed. This should not +- * happen in a well-formed message, since the SIG(0) is only +- * looked for in the additional section, and the dynamic update +- * meta-records are in the prerequisite and update sections. +- */ +- if (rdata.length == 0) { +- return (ISC_R_UNEXPECTEDEND); +- } +- +- result = dns_rdata_tostruct(&rdata, &sig, msg->mctx); +- if (result != ISC_R_SUCCESS) { +- return (result); +- } +- +- dns_rdataset_init(&keyset); +- if (view == NULL) { +- result = DNS_R_KEYUNAUTHORIZED; +- goto freesig; +- } +- result = dns_view_simplefind(view, &sig.signer, +- dns_rdatatype_key /* SIG(0) */, 0, +- 0, false, &keyset, NULL); +- +- if (result != ISC_R_SUCCESS) { +- /* XXXBEW Should possibly create a fetch here */ +- result = DNS_R_KEYUNAUTHORIZED; +- goto freesig; +- } else if (keyset.trust < dns_trust_secure) { +- /* XXXBEW Should call a validator here */ +- result = DNS_R_KEYUNAUTHORIZED; +- goto freesig; +- } +- result = dns_rdataset_first(&keyset); +- INSIST(result == ISC_R_SUCCESS); +- for (; result == ISC_R_SUCCESS; +- result = dns_rdataset_next(&keyset)) { +- dst_key_t *key = NULL; +- +- dns_rdata_reset(&rdata); +- dns_rdataset_current(&keyset, &rdata); +- isc_buffer_init(&b, rdata.data, rdata.length); +- isc_buffer_add(&b, rdata.length); +- +- result = dst_key_fromdns(&sig.signer, rdata.rdclass, &b, +- view->mctx, &key); +- if (result != ISC_R_SUCCESS) { +- continue; +- } +- if (dst_key_alg(key) != sig.algorithm || +- dst_key_id(key) != sig.keyid || +- !(dst_key_proto(key) == DNS_KEYPROTO_DNSSEC || +- dst_key_proto(key) == DNS_KEYPROTO_ANY)) +- { +- dst_key_free(&key); +- continue; +- } +- result = dns_dnssec_verifymessage(&msgb, msg, key); +- dst_key_free(&key); +- if (result == ISC_R_SUCCESS) { +- break; +- } +- } +- if (result == ISC_R_NOMORE) { +- result = DNS_R_KEYUNAUTHORIZED; +- } +- +- freesig: +- if (dns_rdataset_isassociated(&keyset)) { +- dns_rdataset_disassociate(&keyset); +- } +- dns_rdata_freestruct(&sig); +- return (result); ++ return (dns_tsig_verify(&msgb, msg, NULL, NULL)); + } + } +- + #define INDENT(sp) \ + do { \ + unsigned int __i; \ +diff --git a/lib/ns/client.c b/lib/ns/client.c +index 264d11d..0f8eb94 100644 +--- a/lib/ns/client.c ++++ b/lib/ns/client.c +@@ -2063,6 +2063,13 @@ ns__client_request(isc_nmhandle_t *handle, isc_result_t eresult, + ns_client_log(client, DNS_LOGCATEGORY_SECURITY, + NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3), + "request is signed by a nonauthoritative key"); ++ } else if (result == DNS_R_NOTVERIFIEDYET && ++ client->message->sig0 != NULL) ++ { ++ ns_client_log(client, DNS_LOGCATEGORY_SECURITY, ++ NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3), ++ "request has a SIG(0) signature but its support " ++ "was removed (CVE-2024-1975)"); + } else { + char tsigrcode[64]; + isc_buffer_t b; +-- +2.33.0 + diff --git a/backport-CVE-2024-4076.patch b/backport-CVE-2024-4076.patch new file mode 100644 index 0000000000000000000000000000000000000000..6ccf3330faf73a2061d379a18118dd9aee4c34c5 --- /dev/null +++ b/backport-CVE-2024-4076.patch @@ -0,0 +1,27 @@ +From bef3d2cca3552100bbe44790c8c1a4f5bef06798 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= +Date: Thu, 16 May 2024 12:10:41 +0200 +Subject: [PATCH] Remove support for SIG(0) message verification + +Conflict:NA +Reference:https://downloads.isc.org/isc/bind9/9.18.28/patches/0004-CVE-2024-4076.patch + +--- + lib/ns/query.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/ns/query.c b/lib/ns/query.c +index 6f41178..520203f 100644 +--- a/lib/ns/query.c ++++ b/lib/ns/query.c +@@ -5237,6 +5237,7 @@ qctx_freedata(query_ctx_t *qctx) { + ns_client_releasename(qctx->client, &qctx->zfname); + dns_db_detachnode(qctx->zdb, &qctx->znode); + dns_db_detach(&qctx->zdb); ++ qctx->zversion = NULL; + } + + if (qctx->event != NULL && !qctx->client->nodetach) { +-- +2.33.0 + diff --git a/backport-optimize-the-slabheader-placement-for-certain-RRtype.patch b/backport-optimize-the-slabheader-placement-for-certain-RRtype.patch new file mode 100644 index 0000000000000000000000000000000000000000..1fbde4ce9f919d840eba2d2908ce58a5c7c1ee14 --- /dev/null +++ b/backport-optimize-the-slabheader-placement-for-certain-RRtype.patch @@ -0,0 +1,98 @@ +From 8ef414a7f38a04cfc11df44adaedaf3126fa3878 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= +Date: Mon, 29 Jan 2024 16:36:30 +0100 +Subject: [PATCH] Optimize the slabheader placement for certain RRTypes + +Mark the infrastructure RRTypes as "priority" types and place them at +the beginning of the rdataslab header data graph. The non-priority +types either go right after the priority types (if any). + +(cherry picked from commit 3ac482be7fd058d284e89873021339579fad0615) + +Conflict:NA +Reference:https://gitlab.isc.org/isc-projects/bind9/-/commit/8ef414a7f38a04cfc11df44adaedaf3126fa3878 + +--- + lib/dns/rbtdb.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 42 insertions(+), 2 deletions(-) + +diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c +index ab4caae..d86ed64 100644 +--- a/lib/dns/rbtdb.c ++++ b/lib/dns/rbtdb.c +@@ -967,6 +967,30 @@ set_ttl(dns_rbtdb_t *rbtdb, rdatasetheader_t *header, dns_ttl_t newttl) { + } + } + ++static bool ++prio_type(rbtdb_rdatatype_t type) { ++ switch (type) { ++ case dns_rdatatype_soa: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_soa): ++ case dns_rdatatype_a: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_a): ++ case dns_rdatatype_aaaa: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_aaaa): ++ case dns_rdatatype_nsec: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_nsec): ++ case dns_rdatatype_nsec3: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_nsec3): ++ case dns_rdatatype_ns: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_ns): ++ case dns_rdatatype_ds: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_ds): ++ case dns_rdatatype_cname: ++ case RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_cname): ++ return (true); ++ } ++ return (false); ++} ++ + /*% + * These functions allow the heap code to rank the priority of each + * element. It returns true if v1 happens "sooner" than v2. +@@ -6183,6 +6207,7 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + rbtdb_changed_t *changed = NULL; + rdatasetheader_t *topheader = NULL, *topheader_prev = NULL; + rdatasetheader_t *header = NULL, *sigheader = NULL; ++ rdatasetheader_t *prioheader = NULL; + unsigned char *merged = NULL; + isc_result_t result; + bool header_nx; +@@ -6324,6 +6349,9 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, const dns_name_t *nodename, + + for (topheader = rbtnode->data; topheader != NULL; + topheader = topheader->next) { ++ if (prio_type(topheader->type)) { ++ prioheader = topheader; ++ } + if (topheader->type == newheader->type || + topheader->type == negtype) { + break; +@@ -6705,9 +6733,21 @@ find_header: + /* + * No rdatasets of the given type exist at the node. + */ +- newheader->next = rbtnode->data; + newheader->down = NULL; +- rbtnode->data = newheader; ++ ++ if (prio_type(newheader->type)) { ++ /* This is a priority type, prepend it */ ++ newheader->next = rbtnode->data; ++ rbtnode->data = newheader; ++ } else if (prioheader != NULL) { ++ /* Append after the priority headers */ ++ newheader->next = prioheader->next; ++ prioheader->next = newheader; ++ } else { ++ /* There were no priority headers */ ++ newheader->next = rbtnode->data; ++ rbtnode->data = newheader; ++ } + } + } + +-- +2.33.0 + diff --git a/bind.spec b/bind.spec index a2bac1a213eab23bbb69765d7db2301acd58dc18..8cfb596a866aab805fb89c886a1010e664ed8617 100644 --- a/bind.spec +++ b/bind.spec @@ -30,7 +30,7 @@ Summary: The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) serv Name: bind License: MPLv2.0 Version: 9.16.23 -Release: 22 +Release: 23 Epoch: 32 Url: https://www.isc.org/downloads/bind/ # @@ -239,6 +239,13 @@ Patch6156:backport-CVE-2023-4408.patch Patch6157:backport-CVE-2023-50387-CVE-2023-50868.patch Patch6158:backport-Replace-netievent-lock-free-queue-with-simple-locked.patch +Patch6159:backport-CVE-2024-1975.patch +Patch6160:backport-CVE-2024-4076.patch +Patch6161:backport-optimize-the-slabheader-placement-for-certain-RRtype.patch +Patch6162:backport-0001-CVE-2024-1737.patch +Patch6163:backport-0002-CVE-2024-1737.patch +Patch6164:backport-0003-CVE-2024-1737.patch +Patch6165:backport-0004-CVE-2024-1737.patch Patch9000:bugfix-limit-numbers-of-test-threads.patch @@ -1248,6 +1255,12 @@ fi; %endif %changelog +* Fri Aug 02 2024 chengyechun - 32:9.16.23-23 +- Type:CVE +- CVE:CVE-2024-1975,CVE-2024-4076,CVE-2024-1737 +- SUG:NA +- DESC:fix CVE-2024-1975 CVE-2024-4076 CVE-2024-1737 + * Thu Mar 21 2024 chengyechun - 32:9.16.23-22 - Type:bugfix - CVE: