]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Disable recursion for non-IN classes
authorEvan Hunt <each@isc.org>
Tue, 3 Mar 2026 22:00:38 +0000 (14:00 -0800)
committerMichał Kępień <michal@isc.org>
Thu, 7 May 2026 11:21:59 +0000 (13:21 +0200)
Force recursion off, and set allow-recursion/allow-recursion-on ACLs
to none, for views with a class other than IN. Log a configuration
warning if recursion is explicitly enabled for a non-IN view.

This addresses YWH-PGM40640-74 and YWH-PGM40640-75 by preventing any
attempt at recursive processing in a class-CHAOS view, ensuring that
server addresses used for recursive queries and received in recursive
responses are of the expected format.

Fixes: isc-projects/bind9#5780
Fixes: isc-projects/bind9#5781
(cherry picked from commit 7becff1a14684a68208c92b3b0315c045c05ad75)

bin/named/server.c
bin/tests/system/allow_query/tests.sh
bin/tests/system/checkconf/tests.sh
bin/tests/system/resolver/tests.sh
lib/bind9/check.c

index 72ab7c956a1233e45b5a5d0fe71724ad53c4ad94..307f10cee3c0bfeca0f4b17c525c61ed6fdb552c 100644 (file)
@@ -4515,6 +4515,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
        obj = NULL;
        result = named_config_get(maps, "max-cache-size", &obj);
        INSIST(result == ISC_R_SUCCESS);
+
        /*
         * If "-T maxcachesize=..." is in effect, it overrides any other
         * "max-cache-size" setting found in configuration, either implicit or
@@ -5224,34 +5225,15 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
        }
 
        /*
-        * We have default hints for class IN if we need them.
+        * We have default root hints for class IN if we need them.
+        * Each view gets its own rootdb so a priming response only
+        * writes into that view's copy.  Other classes don't support
+        * recursion and don't need hints.
         */
        if (view->rdclass == dns_rdataclass_in && view->hints == NULL) {
                dns_view_sethints(view, named_g_server->in_roothints);
        }
 
-       /*
-        * If we still have no hints, this is a non-IN view with no
-        * "hints zone" configured.  Issue a warning, except if this
-        * is a root server.  Root servers never need to consult
-        * their hints, so it's no point requiring users to configure
-        * them.
-        */
-       if (view->hints == NULL) {
-               dns_zone_t *rootzone = NULL;
-               (void)dns_view_findzone(view, dns_rootname, &rootzone);
-               if (rootzone != NULL) {
-                       dns_zone_detach(&rootzone);
-                       need_hints = false;
-               }
-               if (need_hints) {
-                       isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
-                                     NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
-                                     "no root hints for view '%s'",
-                                     view->name);
-               }
-       }
-
        /*
         * Configure the view's transports (DoT/DoH)
         */
@@ -5379,7 +5361,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
        obj = NULL;
        result = named_config_get(maps, "recursion", &obj);
        INSIST(result == ISC_R_SUCCESS);
-       view->recursion = cfg_obj_asboolean(obj);
+       view->recursion = (view->rdclass == dns_rdataclass_in &&
+                          cfg_obj_asboolean(obj));
 
        obj = NULL;
        result = named_config_get(maps, "qname-minimization", &obj);
@@ -5479,14 +5462,14 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
        CHECK(configure_view_acl(vconfig, config, NULL, "allow-query-cache-on",
                                 NULL, actx, named_g_mctx, &view->cacheonacl));
 
-       if (strcmp(view->name, "_bind") != 0 &&
-           view->rdclass != dns_rdataclass_chaos)
-       {
-               /* named.conf only */
+       if (view->rdclass != dns_rdataclass_in) {
+               view->recursion = false;
+               dns_acl_none(named_g_mctx, &view->recursionacl);
+               dns_acl_none(named_g_mctx, &view->recursiononacl);
+       } else {
                CHECK(configure_view_acl(vconfig, config, NULL,
                                         "allow-recursion", NULL, actx,
                                         named_g_mctx, &view->recursionacl));
-               /* named.conf only */
                CHECK(configure_view_acl(vconfig, config, NULL,
                                         "allow-recursion-on", NULL, actx,
                                         named_g_mctx, &view->recursiononacl));
index e59a1abe6bde49f2e8bae3d29c4212c3103bf892..46d2a78077dbcc799e58f33e5b999e64eb4b2599 100644 (file)
@@ -703,7 +703,7 @@ $DIG -p ${PORT} @10.53.1.2 d.normal.example a >dig.out.ns3.4.$n || ret=1
 grep 'recursion requested but not available' dig.out.ns3.4.$n >/dev/null || ret=1
 grep 'status: REFUSED' dig.out.ns3.4.$n >/dev/null || ret=1
 grep 'EDE: 18 (Prohibited)' dig.out.ns3.4.$n >/dev/null || ret=1
-nextpart ns3/named.run | grep 'allow-recursion-on did not match' >/dev/null || ret=1
+nextpart ns3/named.run | grep 'allow-query-cache-on did not match' >/dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
index 3bb772e4d50d6bcf02996ce83b86a2b77638a00d..5da8a20ee19c30777a8b9a8d0c1b576599e4730a 100644 (file)
@@ -543,6 +543,7 @@ $CHECKCONF -l good.conf \
   | grep -v "is not implemented" \
   | grep -v "is not recommended" \
   | grep -v "no longer exists" \
+  | grep -v "recursion will be disabled" \
   | grep -v "is obsolete" >checkconf.out$n || ret=1
 diff good.zonelist checkconf.out$n >diff.out$n || ret=1
 if [ $ret -ne 0 ]; then
index 2864aae9501778491bf67d7a678c1bbfaa1e8628..db5a18680d9c4c42c421b819e437926ba40fbe81 100755 (executable)
@@ -979,10 +979,12 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
 n=$((n + 1))
-echo_i "checking NXDOMAIN is returned when querying non existing domain in CH class ($n)"
+echo_i "checking REFUSED is returned when querying non existing domain in CH class ($n)"
 ret=0
-dig_with_opts @10.53.0.1 id.hostname txt ch >dig.ns1.out.${n} || ret=1
-grep "status: NXDOMAIN" dig.ns1.out.${n} >/dev/null || ret=1
+dig_with_opts @10.53.0.1 hostname.chaostest txt ch >dig.ns1.out.1.${n} || ret=1
+grep "status: NOERROR" dig.ns1.out.1.${n} >/dev/null || ret=1
+dig_with_opts @10.53.0.1 id.hostname txt ch >dig.ns1.out.2.${n} || ret=1
+grep "status: REFUSED" dig.ns1.out.2.${n} >/dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
index cefc3eb3ac0008823fd0178bc8f4fc576e327384..13f3212d08dc1af8167e6fd38f10e7b045c0ec89 100644 (file)
@@ -2789,13 +2789,17 @@ check_mirror_zone_notify(const cfg_obj_t *zoptions, const char *znamestr,
  */
 static bool
 check_recursion(const cfg_obj_t *config, const cfg_obj_t *voptions,
-               const cfg_obj_t *goptions, isc_log_t *logctx,
-               cfg_aclconfctx_t *actx, isc_mem_t *mctx) {
+               dns_rdataclass_t vclass, const cfg_obj_t *goptions,
+               isc_log_t *logctx, cfg_aclconfctx_t *actx, isc_mem_t *mctx) {
        dns_acl_t *acl = NULL;
        const cfg_obj_t *obj;
        isc_result_t result;
        bool retval = true;
 
+       if (vclass != dns_rdataclass_in) {
+               return false;
+       }
+
        /*
         * Check the "recursion" option first.
         */
@@ -3380,7 +3384,8 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
         * contradicts the purpose of the former.
         */
        if (ztype == CFG_ZONE_MIRROR &&
-           !check_recursion(config, voptions, goptions, logctx, actx, mctx))
+           !check_recursion(config, voptions, zclass, goptions, logctx, actx,
+                            mctx))
        {
                cfg_obj_log(zoptions, logctx, ISC_LOG_ERROR,
                            "zone '%s': mirror zones cannot be used if "
@@ -5215,6 +5220,17 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions,
 
        cfg_aclconfctx_create(mctx, &actx);
 
+       if (vclass != dns_rdataclass_in) {
+               if (check_recursion(config, voptions, dns_rdataclass_in,
+                                   options, logctx, actx, mctx))
+               {
+                       cfg_obj_log(opts, logctx, ISC_LOG_WARNING,
+                                   "recursion will be disabled for "
+                                   "non-IN view '%s'",
+                                   viewname);
+               }
+       }
+
        if (voptions != NULL) {
                (void)cfg_map_get(voptions, "zone", &zones);
        } else {