From f2b1eb1f052c99e0be096b98888e9854cf57a64c Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 19 Jun 2019 11:09:14 -0400 Subject: [PATCH 1/3] hs: Disallow single hop client circuit when introducing This will effectively also deny any bridge to be used as a single hop to the introduction point since bridge do not authenticate like clients. Fixes #24963 Signed-off-by: David Goulet --- changes/ticket24963 | 5 +++++ src/feature/hs/hs_intropoint.c | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 changes/ticket24963 diff --git a/changes/ticket24963 b/changes/ticket24963 new file mode 100644 index 0000000000..50adcfaaf4 --- /dev/null +++ b/changes/ticket24963 @@ -0,0 +1,5 @@ + o Minor feature (onion service): + - Disallow single hop clients to introduce directly at the introduction + point. We've removed Tor2web a while back and rendezvous are blocked at + the relays. This is to remove load off the network from spammy clients. + Close ticket 24963. diff --git a/src/feature/hs/hs_intropoint.c b/src/feature/hs/hs_intropoint.c index 9333060e7e..447f73b602 100644 --- a/src/feature/hs/hs_intropoint.c +++ b/src/feature/hs/hs_intropoint.c @@ -10,6 +10,7 @@ #include "core/or/or.h" #include "app/config/config.h" +#include "core/or/channel.h" #include "core/or/circuitlist.h" #include "core/or/circuituse.h" #include "core/or/relay.h" @@ -546,6 +547,14 @@ circuit_is_suitable_for_introduce1(const or_circuit_t *circ) return 0; } + /* Disallow single hop client circuit. */ + if (channel_is_client(circ->p_chan)) { + log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL, + "Single hop client was rejected while trying to introduce. " + "Closing circuit."); + return 0; + } + return 1; } From f14ce4bce6cb1772ce4dbba79acbed27b3a40b31 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 23 Jul 2019 12:36:40 -0400 Subject: [PATCH 2/3] Allow NULL circ->p_chan in circuit_is_suitable_for_introduce1() This shouldn't be possible while Tor is running, but the tests can hit this code. Rather than force the tests to add a dummy channel object, let's just tolerate their incompletely built circuits. --- src/feature/hs/hs_intropoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/feature/hs/hs_intropoint.c b/src/feature/hs/hs_intropoint.c index 447f73b602..6383d3ed22 100644 --- a/src/feature/hs/hs_intropoint.c +++ b/src/feature/hs/hs_intropoint.c @@ -548,7 +548,7 @@ circuit_is_suitable_for_introduce1(const or_circuit_t *circ) } /* Disallow single hop client circuit. */ - if (channel_is_client(circ->p_chan)) { + if (circ->p_chan && channel_is_client(circ->p_chan)) { log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL, "Single hop client was rejected while trying to introduce. " "Closing circuit."); From df12ff3deaa7ad4a5eb2098f4ed9d12ee4084d6d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 23 Jul 2019 12:42:33 -0400 Subject: [PATCH 3/3] Add a test for disallowing single-hop introductions. Code from dgoulet. --- src/test/test_hs_intropoint.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/test_hs_intropoint.c b/src/test/test_hs_intropoint.c index 732836fb5b..0cdb1fef27 100644 --- a/src/test/test_hs_intropoint.c +++ b/src/test/test_hs_intropoint.c @@ -16,6 +16,7 @@ #include "lib/crypt_ops/crypto_rand.h" #include "core/or/or.h" +#include "core/or/channel.h" #include "core/or/circuitlist.h" #include "core/or/circuituse.h" #include "ht.h" @@ -693,6 +694,17 @@ test_introduce1_suitable_circuit(void *arg) tt_int_op(ret, OP_EQ, 0); } + /* Single hop circuit should not be allowed. */ + { + circ = or_circuit_new(0, NULL); + circ->p_chan = tor_malloc_zero(sizeof(channel_t)); + circ->p_chan->is_client = 1; + ret = circuit_is_suitable_for_introduce1(circ); + tor_free(circ->p_chan); + circuit_free_(TO_CIRCUIT(circ)); + tt_int_op(ret, OP_EQ, 0); + } + done: ; } @@ -927,4 +939,3 @@ struct testcase_t hs_intropoint_tests[] = { END_OF_TESTCASES }; -