]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Apply XFR-out quota after ACL is checked
authorAram Sargsyan <aram@isc.org>
Thu, 16 Apr 2026 15:17:46 +0000 (15:17 +0000)
committerAram Sargsyan <aram@isc.org>
Thu, 16 Apr 2026 15:18:39 +0000 (15:18 +0000)
Unauthorized clients can consume XFR-out quota and block authorized
XFR clients. Apply the quota after ACL is checked.

(cherry picked from commit e8268b76a8a1cde039131234b04b197ee7b46220)

lib/ns/xfrout.c

index 271b462d64ec138ba50dacebdcf1496a1160ff6c..4f57d4c176546ce4fa8d63d19433f31890d2a345 100644 (file)
@@ -764,16 +764,6 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
 
        ns_client_log(client, DNS_LOGCATEGORY_XFER_OUT, NS_LOGMODULE_XFER_OUT,
                      ISC_LOG_DEBUG(6), "%s request", mnemonic);
-       /*
-        * Apply quota.
-        */
-       result = isc_quota_attach(&client->sctx->xfroutquota, &quota);
-       if (result != ISC_R_SUCCESS) {
-               isc_log_write(XFROUT_COMMON_LOGARGS, ISC_LOG_WARNING,
-                             "%s request denied: %s", mnemonic,
-                             isc_result_totext(result));
-               goto failure;
-       }
 
        /*
         * Interpret the question section.
@@ -945,6 +935,18 @@ got_soa:
                FAILC(DNS_R_FORMERR, "attempted AXFR over UDP");
        }
 
+       /*
+        * Apply quota after ACL is checked, so that unauthorized clients
+        * can not starve the authorized clients.
+        */
+       result = isc_quota_attach(&client->sctx->xfroutquota, &quota);
+       if (result != ISC_R_SUCCESS) {
+               isc_log_write(XFROUT_COMMON_LOGARGS, ISC_LOG_WARNING,
+                             "%s request denied: %s", mnemonic,
+                             isc_result_totext(result));
+               goto failure;
+       }
+
        /*
         * Look up the requesting server in the peer table.
         */
@@ -1218,6 +1220,7 @@ failure:
        }
        /* XXX kludge */
        if (xfr != NULL) {
+               /* The quota will be released in xfrout_ctx_destroy(). */
                xfrout_fail(xfr, result, "setting up zone transfer");
        } else if (result != ISC_R_SUCCESS) {
                ns_client_log(client, DNS_LOGCATEGORY_XFER_OUT,