]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Reject external referrals from forwarders
authorAlessio Podda <alessio@isc.org>
Thu, 7 May 2026 11:34:20 +0000 (13:34 +0200)
committerAlessio Podda <alessio@isc.org>
Tue, 2 Jun 2026 11:40:21 +0000 (13:40 +0200)
Apply the existing name_external() bailiwick check to NS RRsets
processed as referrals in rctx_authority_negative(), and enforce the
same check again in rctx_referral() before caching or following the
delegation.

Also reject referrals from root/global forwarders, where there is no
narrower forward-zone apex for name_external() to enforce.

This prevents a forward-first forwarder from installing a parent
zone-cut above the configured forward zone via an authority-section NS
RRset.

lib/dns/resolver.c

index 258b8bf076cbf7c703f62eb26084b3fe4b18a9c3..dc39d5242bc56dae39035311df1ca803891e2a9a 100644 (file)
@@ -9205,6 +9205,10 @@ rctx_authority_negative(respctx_t *rctx) {
 
                        switch (type) {
                        case dns_rdatatype_ns:
+                               if (name_external(name, dns_rdatatype_ns, rctx))
+                               {
+                                       continue;
+                               }
                                /*
                                 * NS or RRSIG NS.
                                 *
@@ -9387,6 +9391,20 @@ rctx_referral(respctx_t *rctx) {
                return ISC_R_SUCCESS;
        }
 
+       if (name_external(rctx->ns_name, dns_rdatatype_ns, rctx)) {
+               log_formerr(fctx, "external referral");
+               rctx->result = DNS_R_FORMERR;
+               return ISC_R_COMPLETE;
+       }
+
+       if (ISFORWARDER(fctx->addrinfo) &&
+           dns_name_equal(fctx->fwdname, dns_rootname))
+       {
+               log_formerr(fctx, "referral from global forwarder");
+               rctx->result = DNS_R_FORMERR;
+               return ISC_R_COMPLETE;
+       }
+
        /*
         * We already know ns_name is a subdomain of fctx->domain.
         * If ns_name is equal to fctx->domain, we're not making