diff options
author | David Goulet <dgoulet@torproject.org> | 2017-04-06 14:58:13 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-08 20:29:33 -0400 |
commit | 77b279c35c5ecf83c045f9c1d613544d958aef81 (patch) | |
tree | c7250d13e536263afc63bda00e17815b25f8464b /src/or/hs_circuit.c | |
parent | 27dd1a716c63bcdda31f24ed08d259b4a91aa1c3 (diff) | |
download | tor-77b279c35c5ecf83c045f9c1d613544d958aef81.tar.gz tor-77b279c35c5ecf83c045f9c1d613544d958aef81.zip |
prop224: Add service replay cache
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_circuit.c')
-rw-r--r-- | src/or/hs_circuit.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c index ee43406c0d..d9e96c6330 100644 --- a/src/or/hs_circuit.c +++ b/src/or/hs_circuit.c @@ -794,6 +794,7 @@ hs_circ_handle_introduce2(const hs_service_t *service, const uint8_t *payload, size_t payload_len) { int ret = -1; + time_t elapsed; hs_cell_introduce2_data_t data; tor_assert(service); @@ -817,6 +818,22 @@ hs_circ_handle_introduce2(const hs_service_t *service, goto done; } + /* Check whether we've seen this REND_COOKIE before to detect repeats. */ + if (replaycache_add_test_and_elapsed( + service->state.replay_cache_rend_cookie, + data.rendezvous_cookie, sizeof(data.rendezvous_cookie), + &elapsed)) { + /* A Tor client will send a new INTRODUCE1 cell with the same REND_COOKIE + * as its previous one if its intro circ times out while in state + * CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT. If we received the first + * INTRODUCE1 cell (the intro-point relay converts it into an INTRODUCE2 + * cell), we are already trying to connect to that rend point (and may + * have already succeeded); drop this cell. */ + log_info(LD_REND, "We received an INTRODUCE2 cell with same REND_COOKIE " + "field %ld seconds ago. Dropping cell.", elapsed); + goto done; + } + /* At this point, we just confirmed that the full INTRODUCE2 cell is valid * so increment our counter that we've seen one on this intro point. */ ip->introduce2_count++; |