|
@@ -712,10 +712,13 @@ circuit_note_clock_jumped(int seconds_elapsed)
|
|
|
circuit_expire_all_dirty_circs();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * sure we're connected to the next hop, and pass it the onion skin using
|
|
|
- * a create cell. Return -1 if we want to warn and tear down the circuit,
|
|
|
- * else return 0.
|
|
|
+
|
|
|
+ * skin and identity digest for the next hop. If we're already connected,
|
|
|
+ * pass the onion skin to the next hop using a create cell; otherwise
|
|
|
+ * launch a new OR connection, and <b>circ</b> will notice when the
|
|
|
+ * connection succeeds or fails.
|
|
|
+ *
|
|
|
+ * Return -1 if we want to warn and tear down the circuit, else return 0.
|
|
|
*/
|
|
|
int
|
|
|
circuit_extend(cell_t *cell, circuit_t *circ)
|
|
@@ -753,6 +756,28 @@ circuit_extend(cell_t *cell, circuit_t *circ)
|
|
|
onionskin = cell->payload+RELAY_HEADER_SIZE+4+2;
|
|
|
id_digest = cell->payload+RELAY_HEADER_SIZE+4+2+ONIONSKIN_CHALLENGE_LEN;
|
|
|
|
|
|
+
|
|
|
+ * an empty fingerprint for the first hop (e.g. for a bridge relay),
|
|
|
+ * but we don't want to let people send us extend cells for empty
|
|
|
+ * fingerprints -- a) because it opens the user up to a mitm attack,
|
|
|
+ * and b) because it lets an attacker force the relay to hold open a
|
|
|
+ * new TLS connection for each extend request. */
|
|
|
+ if (tor_digest_is_zero(id_digest)) {
|
|
|
+ log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
|
|
|
+ "Client asked me to extend without specifying an id_digest.");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * extend cell came from. There isn't any reason for that, and it can
|
|
|
+ * assist circular-path attacks. */
|
|
|
+ if (!memcmp(id_digest, TO_OR_CIRCUIT(circ)->p_conn->identity_digest,
|
|
|
+ DIGEST_LEN)) {
|
|
|
+ log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
|
|
|
+ "Client asked me to extend back to the previous hop.");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
n_conn = connection_or_get_by_identity_digest(id_digest);
|
|
|
|
|
|
|