]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Apply XFR-out quota after ACL is checked
authorAram Sargsyan <aram@isc.org>
Tue, 31 Mar 2026 13:00:00 +0000 (13:00 +0000)
committerMichał Kępień <michal@isc.org>
Thu, 7 May 2026 11:21:59 +0000 (13:21 +0200)
Unauthorized clients can consume XFR-out quota and block authorized
XFR clients. Apply the quota after ACL is checked.

(cherry picked from commit 5615e6c47a2cd00d82d48b568cc55a4b89daa330)

lib/ns/xfrout.c

index d022a689991ea596a16ae242aed5e7e2ced4a2ef..bc936e1ed0dc3eac481faeeac7cee8fca59d37e5 100644 (file)
@@ -757,16 +757,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 cleanup;
-       }
 
        /*
         * Interpret the question section.
@@ -938,6 +928,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 cleanup;
+       }
+
        /*
         * Look up the requesting server in the peer table.
         */
@@ -1194,6 +1196,7 @@ cleanup:
        }
        /* 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,