]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix TROVE-2023-004: Remote crash when compiled against OpenSSL
authorAlexander Færøy <ahf@torproject.org>
Thu, 2 Nov 2023 18:38:43 +0000 (14:38 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Fri, 3 Nov 2023 12:52:38 +0000 (08:52 -0400)
Fixes #40874

Signed-off-by: David Goulet <dgoulet@torproject.org>
changes/ticket40874 [new file with mode: 0644]
src/feature/relay/relay_handshake.c
src/lib/tls/tortls_openssl.c

diff --git a/changes/ticket40874 b/changes/ticket40874
new file mode 100644 (file)
index 0000000..e1091f6
--- /dev/null
@@ -0,0 +1,3 @@
+  o Major bugfixes (TROVE-2023-004, relay):
+    - Mitigate an issue when Tor compiled with OpenSSL can crash during
+      handshake with a remote relay. Fixes bug 40874; bugfix on 0.2.7.2-alpha.
index be7dba721a73ed37aa14669b81e0166cea79ee7b..75546cdd909f225c0a20b8c1203ab8519694f580 100644 (file)
@@ -414,6 +414,7 @@ connection_or_compute_authenticate_cell_body(or_connection_t *conn,
       log_fn(LOG_PROTOCOL_WARN, LD_OR, "Somebody asked us for an older TLS "
          "authentication method (AUTHTYPE_RSA_SHA256_TLSSECRET) "
          "which we don't support.");
+      goto err;
     }
   } else {
     char label[128];
index 77de2d6a1112e6b765c3a04645f7490c56bfc176..f3257d5f24832f2ef1eec015bd0c7c0223b7de78 100644 (file)
@@ -1649,9 +1649,35 @@ tor_tls_get_tlssecrets,(tor_tls_t *tls, uint8_t *secrets_out))
   const size_t client_random_len = SSL_get_client_random(ssl, NULL, 0);
   const size_t master_key_len = SSL_SESSION_get_master_key(session, NULL, 0);
 
-  tor_assert(server_random_len);
-  tor_assert(client_random_len);
-  tor_assert(master_key_len);
+  if (BUG(! server_random_len)) {
+    log_warn(LD_NET, "Missing server randomness after handshake "
+                     "using %s (cipher: %s, server: %s) from %s",
+                     SSL_get_version(ssl),
+                     SSL_get_cipher_name(ssl),
+                     tls->isServer ? "true" : "false",
+                     ADDR(tls));
+    return -1;
+  }
+
+  if (BUG(! client_random_len)) {
+    log_warn(LD_NET, "Missing client randomness after handshake "
+                     "using %s (cipher: %s, server: %s) from %s",
+                     SSL_get_version(ssl),
+                     SSL_get_cipher_name(ssl),
+                     tls->isServer ? "true" : "false",
+                     ADDR(tls));
+    return -1;
+  }
+
+  if (BUG(! master_key_len)) {
+    log_warn(LD_NET, "Missing master key after handshake "
+                     "using %s (cipher: %s, server: %s) from %s",
+                     SSL_get_version(ssl),
+                     SSL_get_cipher_name(ssl),
+                     tls->isServer ? "true" : "false",
+                     ADDR(tls));
+    return -1;
+  }
 
   len = client_random_len + server_random_len + strlen(TLSSECRET_MAGIC) + 1;
   tor_assert(len <= sizeof(buf));