]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
prop224: Handle client RENDEZVOUS_ESTABLISHED cell
authorDavid Goulet <dgoulet@torproject.org>
Fri, 21 Jul 2017 18:20:37 +0000 (14:20 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Thu, 24 Aug 2017 17:03:28 +0000 (13:03 -0400)
Client now handles a RENDEZVOUS_ESTABLISHED cell when it arrives on the
rendezvous circuit. This new function applies for both the legacy system and
prop224.

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/or/hs_client.c
src/or/hs_client.h
src/or/rendcommon.c

index 8865bb5fb5abe5f3d07a3c3f320571c28cf9326f..2674e2c1e7ecad9cb9cf65b74ad0a608079a3b00 100644 (file)
@@ -538,3 +538,45 @@ hs_client_circuit_has_opened(origin_circuit_t *circ)
   }
 }
 
+/* Called when we receive a RENDEZVOUS_ESTABLISHED cell. Change the state of
+ * the circuit to CIRCUIT_PURPOSE_C_REND_READY. Return 0 on success else a
+ * negative value and the circuit marked for close. */
+int
+hs_client_receive_rendezvous_acked(origin_circuit_t *circ,
+                                   const uint8_t *payload, size_t payload_len)
+{
+  tor_assert(circ);
+  tor_assert(payload);
+
+  (void) payload_len;
+
+  if (TO_CIRCUIT(circ)->purpose != CIRCUIT_PURPOSE_C_ESTABLISH_REND) {
+    log_warn(LD_PROTOCOL, "Got a RENDEZVOUS_ESTABLISHED but we were not "
+                          "expecting one. Closing circuit.");
+    goto err;
+  }
+
+  log_info(LD_REND, "Received an RENDEZVOUS_ESTABLISHED. This circuit is "
+                    "now ready for rendezvous.");
+  circuit_change_purpose(TO_CIRCUIT(circ), CIRCUIT_PURPOSE_C_REND_READY);
+
+  /* Set timestamp_dirty, because circuit_expire_building expects it to
+   * specify when a circuit entered the _C_REND_READY state. */
+  TO_CIRCUIT(circ)->timestamp_dirty = time(NULL);
+
+  /* From a path bias point of view, this circuit is now successfully used.
+   * Waiting any longer opens us up to attacks from malicious hidden services.
+   * They could induce the client to attempt to connect to their hidden
+   * service and never reply to the client's rend requests */
+  pathbias_mark_use_success(circ);
+
+  /* If we already have the introduction circuit built, make sure we send
+   * the INTRODUCE cell _now_ */
+  connection_ap_attach_pending(1);
+
+  return 0;
+ err:
+  circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_TORPROTOCOL);
+  return -1;
+}
+
index a716fc02e40531bdf7c63172de00af53e9298cab..0f82a830f424a6c38d4a7e8f4b85b8520c52a085 100644 (file)
@@ -27,5 +27,9 @@ int hs_client_send_introduce1(origin_circuit_t *intro_circ,
 
 void hs_client_circuit_has_opened(origin_circuit_t *circ);
 
+int hs_client_receive_rendezvous_acked(origin_circuit_t *circ,
+                                       const uint8_t *payload,
+                                       size_t payload_len);
+
 #endif /* TOR_HS_CLIENT_H */
 
index a6b59881adb2bd0ab3a502189c3f50992cdf8de2..7e5ba6b6f6eadf3bd05475bd3076b6628c8b73cc 100644 (file)
@@ -19,6 +19,7 @@
 #include "rendcommon.h"
 #include "rendmid.h"
 #include "hs_intropoint.h"
+#include "hs_client.h"
 #include "rendservice.h"
 #include "rephist.h"
 #include "router.h"
@@ -797,7 +798,7 @@ rend_process_relay_cell(circuit_t *circ, const crypt_path_t *layer_hint,
       break;
     case RELAY_COMMAND_RENDEZVOUS_ESTABLISHED:
       if (origin_circ)
-        r = rend_client_rendezvous_acked(origin_circ,payload,length);
+        r = hs_client_receive_rendezvous_acked(origin_circ,payload,length);
       break;
     default:
       tor_fragile_assert();