From 0de71bf8eb5031b1c6539ea48627a938e200b5da Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 31 Oct 2013 16:44:14 -0400 Subject: [PATCH 1/2] Implement proposal 221: Stop sending CREATE_FAST This makes FastFirstHopPK an AUTOBOOL; makes the default "auto"; and makes the behavior of "auto" be "look at the consensus." --- changes/prop221 | 6 ++++++ doc/tor.1.txt | 8 +++++--- src/or/circuitbuild.c | 8 +++++--- src/or/config.c | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 changes/prop221 diff --git a/changes/prop221 b/changes/prop221 new file mode 100644 index 0000000000..b2bf44bc37 --- /dev/null +++ b/changes/prop221 @@ -0,0 +1,6 @@ + o Minor features: + - Stop sending the CREATE_FAST cells by default; instead, use a + parameter in the consensus to decide whether to use + CREATE_FAST. This can improve security on connections where + Tor's circuit handshake is stronger than the available TLS + connection security levels. Implements proposal 221. diff --git a/doc/tor.1.txt b/doc/tor.1.txt index b9ee296140..51d2aab2db 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -1115,15 +1115,17 @@ The following options are useful only for clients (that is, if the node "foo". Disabled by default since attacking websites and exit relays can use it to manipulate your path selection. (Default: 0) -[[FastFirstHopPK]] **FastFirstHopPK** **0**|**1**:: +[[FastFirstHopPK]] **FastFirstHopPK** **0**|**1**|**auto**:: When this option is disabled, Tor uses the public key step for the first hop of creating circuits. Skipping it is generally safe since we have already used TLS to authenticate the relay and to establish forward-secure - keys. Turning this option off makes circuit building slower. + + keys. Turning this option off makes circuit building a little + slower. Setting this option to "auto" takes advice from the authorities + in the latest consensus about whether to use this feature. + + Note that Tor will always use the public key step for the first hop if it's operating as a relay, and it will never use the public key step if it - doesn't yet know the onion key of the first hop. (Default: 1) + doesn't yet know the onion key of the first hop. (Default: auto) [[TransPort]] **TransPort** \['address':]__port__|**auto** [_isolation flags_]:: Open this port to listen for transparent proxy connections. Set this to diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 43d2ffe4db..26c1e89822 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -600,16 +600,18 @@ should_use_create_fast_for_circuit(origin_circuit_t *circ) if (!circ->cpath->extend_info->onion_key) return 1; /* our hand is forced: only a create_fast will work. */ - if (!options->FastFirstHopPK) - return 0; /* we prefer to avoid create_fast */ if (public_server_mode(options)) { /* We're a server, and we know an onion key. We can choose. * Prefer to blend our circuit into the other circuits we are * creating on behalf of others. */ return 0; } + if (options->FastFirstHopPK == -1) { + /* option is "auto", so look at the consensus. */ + return networkstatus_get_param(NULL, "usecreatefast", 1, 0, 1); + } - return 1; + return options->FastFirstHopPK; } /** Return true if circ is the type of circuit we want to count diff --git a/src/or/config.c b/src/or/config.c index 18f1c29501..491b2cd875 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -236,7 +236,7 @@ static config_var_t option_vars_[] = { OBSOLETE("FallbackNetworkstatusFile"), V(FascistFirewall, BOOL, "0"), V(FirewallPorts, CSV, ""), - V(FastFirstHopPK, BOOL, "1"), + V(FastFirstHopPK, AUTOBOOL, "auto"), V(FetchDirInfoEarly, BOOL, "0"), V(FetchDirInfoExtraEarly, BOOL, "0"), V(FetchServerDescriptors, BOOL, "1"), From 5de88dda0acda6914bacd1e14c2e037798c5d9d9 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 31 Oct 2013 16:53:31 -0400 Subject: [PATCH 2/2] circuit_build_failed: distinguish "got DESTROY" case Roger spotted this on tor-dev in his comments on proposal 221. We etect DESTROY vs everything else, since arma likes network timeout indicating failure but not overload indicating failure. --- src/or/circuituse.c | 9 +++++---- src/or/command.c | 1 + src/or/or.h | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 25997ebdbe..5fe65eba05 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1382,10 +1382,11 @@ circuit_build_failed(origin_circuit_t *circ) failed_at_last_hop = 1; } if (circ->cpath && - circ->cpath->state != CPATH_STATE_OPEN) { - /* We failed at the first hop. If there's an OR connection - * to blame, blame it. Also, avoid this relay for a while, and - * fail any one-hop directory fetches destined for it. */ + circ->cpath->state != CPATH_STATE_OPEN && + ! circ->base_.received_destroy) { + /* We failed at the first hop for some reason other than a DESTROY cell. + * If there's an OR connection to blame, blame it. Also, avoid this relay + * for a while, and fail any one-hop directory fetches destined for it. */ const char *n_chan_id = circ->cpath->extend_info->identity_digest; int already_marked = 0; if (circ->base_.n_chan) { diff --git a/src/or/command.c b/src/or/command.c index 699b02fb47..51d07b0485 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -499,6 +499,7 @@ command_process_destroy_cell(cell_t *cell, channel_t *chan) log_debug(LD_OR,"Received for circID %u.",(unsigned)cell->circ_id); reason = (uint8_t)cell->payload[0]; + circ->received_destroy = 1; if (!CIRCUIT_IS_ORIGIN(circ) && cell->circ_id == TO_OR_CIRCUIT(circ)->p_circ_id) { diff --git a/src/or/or.h b/src/or/or.h index eff5a6d2b4..ad91f7da29 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2799,6 +2799,9 @@ typedef struct circuit_t { * allowing n_streams to add any more cells. (OR circuit only.) */ unsigned int streams_blocked_on_p_chan : 1; + /** True iff this circuit has received a DESTROY cell in either direction */ + unsigned int received_destroy : 1; + uint8_t state; /**< Current status of this circuit. */ uint8_t purpose; /**< Why are we creating this circuit? */