]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add isc_nm_xfr_allowed() function
authorArtem Boldariev <artem@boldariev.com>
Thu, 26 Aug 2021 12:07:20 +0000 (15:07 +0300)
committerArtem Boldariev <artem@boldariev.com>
Tue, 5 Oct 2021 08:23:47 +0000 (11:23 +0300)
The intention of having this function is to have a predicate to check
if a zone transfer could be performed over the given handle. In most
cases we can assume that we can do zone transfers over any stream
transport except DoH, but this assumption will not work for zone
transfers over DoT (XoT), as the RFC9103 requires ALPN to happen,
which might not be the case for all deployments of DoT.

lib/isc/include/isc/netmgr.h
lib/isc/netmgr/netmgr-int.h
lib/isc/netmgr/netmgr.c
lib/isc/netmgr/tlsdns.c

index b198713092bcfefd228cf80833ae2e16345a57d7..313429469661b2e9ec6ecc8969904d0d1c247688 100644 (file)
@@ -597,6 +597,15 @@ isc_nm_bad_request(isc_nmhandle_t *handle);
  *  \li 'handle' is a valid netmgr handle object.
  */
 
+bool
+isc_nm_xfr_allowed(isc_nmhandle_t *handle);
+/*%<
+ * Check if it is possible to do a zone transfer over the given handle.
+ *
+ * Requires:
+ * \li 'handle' is a valid connection handle.
+ */
+
 void
 isc_nm_task_enqueue(isc_nm_t *mgr, isc_task_t *task, int threadid);
 /*%<
index 963476b64c8596d6d5819866fdbd688374ce6367..8fc2b4fcd19514229394b7c4d8b3e9ac856d285a 100644 (file)
@@ -1580,6 +1580,16 @@ isc__nm_async_tlsdnsread(isc__networker_t *worker, isc__netievent_t *ev0);
  * Callback handlers for asynchronous TLSDNS events.
  */
 
+bool
+isc__nm_tlsdns_xfr_allowed(isc_nmsocket_t *sock);
+/*%<
+ * Check if it is possible to do a zone transfer over the given TLSDNS
+ * socket.
+ *
+ * Requires:
+ * \li 'sock' is a valid TLSDNS socket.
+ */
+
 #if HAVE_LIBNGHTTP2
 void
 isc__nm_tls_send(isc_nmhandle_t *handle, const isc_region_t *region,
index b67a94e24660d065d5357cff0c90eca085a5d51f..8aa9acb7d38c31e2d467c4a49cc23a9a86ccc4d6 100644 (file)
@@ -3394,6 +3394,30 @@ isc_nm_bad_request(isc_nmhandle_t *handle) {
        }
 }
 
+bool
+isc_nm_xfr_allowed(isc_nmhandle_t *handle) {
+       isc_nmsocket_t *sock;
+
+       REQUIRE(VALID_NMHANDLE(handle));
+       REQUIRE(VALID_NMSOCK(handle->sock));
+
+       sock = handle->sock;
+
+       switch (sock->type) {
+       case isc_nm_tcpdnssocket:
+               return (true);
+       case isc_nm_tlsdnssocket:
+               return (isc__nm_tlsdns_xfr_allowed(sock));
+       default:
+               return (false);
+       }
+
+       INSIST(0);
+       ISC_UNREACHABLE();
+
+       return (false);
+}
+
 #ifdef NETMGR_TRACE
 /*
  * Dump all active sockets in netmgr. We output to stderr
index 165d8be2e9d7a56aee7d8698323f8a712e49385f..0d2828d4bfd4ee964294497f2610e44b6c1c3c71 100644 (file)
@@ -2029,3 +2029,26 @@ isc__nm_async_tlsdnscancel(isc__networker_t *worker, isc__netievent_t *ev0) {
 
        isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
 }
+
+/* Zone transfers/updates over TLS are allowed only when "dot" ALPN
+ * was negotiated.
+ *
+ * Per the XoT spec, we must also check that the TLS version is >=
+ * 1.3. The check could be added here. However, we still need to
+ * support platforms where no cryptographic library with TLSv1.3
+ * support is available. As a result of this we cannot be too strict
+ * regarding the minimal TLS protocol version in order to make it
+ * possible to do encrypted zone transfers over TLSv1.2, as it would
+ * not be right to leave users on these platforms without means for
+ * encrypted zone transfers using BIND only.
+ *
+ * The ones requiring strict compatibility with the specification
+ * could disable TLSv1.2 in the configuration file.
+ */
+bool
+isc__nm_tlsdns_xfr_allowed(isc_nmsocket_t *sock) {
+       REQUIRE(VALID_NMSOCK(sock));
+       REQUIRE(sock->type == isc_nm_tlsdnssocket);
+
+       return (sock->tls.alpn_negotiated);
+}