]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Disable TLS renegotiation by default
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 25 Mar 2021 15:57:44 +0000 (16:57 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 25 Mar 2021 15:58:56 +0000 (16:58 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdistdist/docs/reference/config.rst
pdns/libssl.cc
pdns/libssl.hh

index 54e3f0f2f7fc4b307acc37919504205a0badfce9..de3fbe701b3c579b0a038a99b86e1ee2b5d54e2e 100644 (file)
@@ -227,6 +227,10 @@ static void parseTLSConfig(TLSConfig& config, const std::string& context, boost:
   if (vars->count("releaseBuffers")) {
     config.d_releaseBuffers = boost::get<bool>((*vars)["releaseBuffers"]);
   }
+
+  if (vars->count("enableRenegotiation")) {
+    config.d_enableRenegotiation = boost::get<bool>((*vars)["enableRenegotiation"]);
+  }
 }
 
 #endif // defined(HAVE_DNS_OVER_TLS) || defined(HAVE_DNS_OVER_HTTPS)
index ace0a17b32eeb45a5f78b041957cb1a71fc1b277..8a0b3e8ff41211c76a16b52ab81fa678c91d6f99 100644 (file)
@@ -105,7 +105,7 @@ Listen Sockets
     ``url`` now defaults to ``/dns-query`` instead of ``/``, and does exact matching instead of accepting sub-paths. Added ``tcpListenQueueSize`` parameter.
 
   .. versionchanged:: 1.6.0
-    ``exactPathMatching`` and ``releaseBuffers`` options added.
+    ``exactPathMatching``, ``releaseBuffers`` and ``enableRenegotiation`` options added.
     ``internalPipeBufferSize`` now defaults to 1048576 on Linux.
 
   Listen on the specified address and TCP port for incoming DNS over HTTPS connections, presenting the specified X.509 certificate.
@@ -145,6 +145,7 @@ Listen Sockets
   * ``internalPipeBufferSize=0``: int - Set the size in bytes of the internal buffer of the pipes used internally to pass queries and responses between threads. Requires support for ``F_SETPIPE_SZ`` which is present in Linux since 2.6.35. The actual size might be rounded up to a multiple of a page size. 0 means that the OS default size is used. The default value is 0, except on Linux where it is 1048576 since 1.6.0.
   * ``exactPathMatching=true``: bool - Whether to do exact path matching of the query path against the paths configured in ``urls`` (true, the default since 1.5.0) or to accepts sub-paths (false, and was the default before 1.5.0).
   * ``releaseBuffers=true``: bool - Whether OpenSSL should release its I/O buffers when a connection goes idle, saving roughly 35 kB of memory per connection.
+  * ``enableRenegotiation=false``: bool - Whether secure TLS renegotiation should be enabled. Disabled by default since it increases the attack surface and is seldom used for DNS.
 
 .. function:: addTLSLocal(address, certFile(s), keyFile(s) [, options])
 
@@ -153,7 +154,7 @@ Listen Sockets
   .. versionchanged:: 1.5.0
     ``sessionTimeout`` and ``tcpListenQueueSize`` options added.
   .. versionchanged:: 1.6.0
-    ``maxInFlight`` and ``releaseBuffers`` options added.
+    ``maxInFlight``, ``releaseBuffers`` and ``enableRenegotiation`` options added.
 
   Listen on the specified address and TCP port for incoming DNS over TLS connections, presenting the specified X.509 certificate.
 
@@ -185,6 +186,7 @@ Listen Sockets
   * ``tcpListenQueueSize=SOMAXCONN``: int - Set the size of the listen queue. Default is ``SOMAXCONN``.
   * ``maxInFlight=0``: int - Maximum number of in-flight queries. The default is 0, which disables out-of-order processing.
   * ``releaseBuffers=true``: bool - Whether OpenSSL should release its I/O buffers when a connection goes idle, saving roughly 35 kB of memory per connection.
+  * ``enableRenegotiation=false``: bool - Whether secure TLS renegotiation should be enabled (OpenSSL only, the GnuTLS provider does not support it). Disabled by default since it increases the attack surface and is seldom used for DNS.
 
 .. function:: setLocal(address[, options])
 
index 9b43c91050e2847566ad6f1382f291d0e52b18c4..0e0dd0a73effe80eba4fb43e58829836652f617d 100644 (file)
@@ -678,6 +678,12 @@ std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)> libssl_init_server_context(const TLS
 #endif /* SSL_OP_PRIORITIZE_CHACHA */
   }
 
+  if (!config.d_enableRenegotiation) {
+#ifdef SSL_OP_NO_RENEGOTIATION
+    sslOptions |= SSL_OP_NO_RENEGOTIATION;
+#endif
+  }
+
   SSL_CTX_set_options(ctx.get(), sslOptions);
   if (!libssl_set_min_tls_version(ctx, config.d_minTLSVersion)) {
     throw std::runtime_error("Failed to set the minimum version to '" + libssl_tls_version_to_string(config.d_minTLSVersion));
index c95ea99f0c2770fe079432594353eb8709dbd580..2e9046d2eb4d0e3a245de7b840e0b3ddee2ec703 100644 (file)
@@ -34,6 +34,8 @@ public:
   /* whether OpenSSL will release I/O buffers when the connection
      becomes idle, saving memory */
   bool d_releaseBuffers{true};
+  /* whether so-called secure renegotiation should be allowed for TLS < 1.3 */
+  bool d_enableRenegotiation{false};
 };
 
 struct TLSErrorCounters