Blame SOURCES/bind-9.11-CVE-2021-25214.patch

96aeb7
From 4eff09c6b1e524b0efc393ee948b5c4cdf16ccb8 Mon Sep 17 00:00:00 2001
96aeb7
From: Mark Andrews <marka@isc.org>
96aeb7
Date: Wed, 3 Feb 2021 11:10:20 +1100
96aeb7
Subject: [PATCH] Check SOA owner names in zone transfers
96aeb7
96aeb7
An IXFR containing SOA records with owner names different than the
96aeb7
transferred zone's origin can result in named serving a version of that
96aeb7
zone without an SOA record at the apex.  This causes a RUNTIME_CHECK
96aeb7
assertion failure the next time such a zone is refreshed.  Fix by
96aeb7
immediately rejecting a zone transfer (either an incremental or
96aeb7
non-incremental one) upon detecting an SOA record not placed at the apex
96aeb7
of the transferred zone.
96aeb7
---
96aeb7
 lib/dns/xfrin.c | 14 ++++++++++++++
96aeb7
 1 file changed, 14 insertions(+)
96aeb7
96aeb7
diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c
96aeb7
index 3a3f407289..0ba82e4974 100644
96aeb7
--- a/lib/dns/xfrin.c
96aeb7
+++ b/lib/dns/xfrin.c
96aeb7
@@ -477,6 +477,20 @@ xfr_rr(dns_xfrin_ctx_t *xfr, dns_name_t *name, uint32_t ttl,
96aeb7
 	    dns_rdatatype_ismeta(rdata->type))
96aeb7
 		FAIL(DNS_R_FORMERR);
96aeb7
 
96aeb7
+	/*
96aeb7
+	 * Immediately reject the entire transfer if the RR that is currently
96aeb7
+	 * being processed is an SOA record that is not placed at the zone
96aeb7
+	 * apex.
96aeb7
+	 */
96aeb7
+	if (rdata->type == dns_rdatatype_soa &&
96aeb7
+	    !dns_name_equal(&xfr->name, name)) {
96aeb7
+		char namebuf[DNS_NAME_FORMATSIZE];
96aeb7
+		dns_name_format(name, namebuf, sizeof(namebuf));
96aeb7
+		xfrin_log(xfr, ISC_LOG_DEBUG(3), "SOA name mismatch: '%s'",
96aeb7
+			  namebuf);
96aeb7
+		FAIL(DNS_R_NOTZONETOP);
96aeb7
+	}
96aeb7
+
96aeb7
  redo:
96aeb7
 	switch (xfr->state) {
96aeb7
 	case XFRST_SOAQUERY:
96aeb7
-- 
96aeb7
2.26.3
96aeb7