summaryrefslogtreecommitdiff
path: root/src/or
AgeCommit message (Collapse)Author
2018-05-14Add a missing return after marking a stream for bad connected cellNick Mathewson
Fixes bug 26072; bugfix on 0.2.4.7-alpha.
2018-05-09Having a ControlPort open doesn't mean we are a clientDavid Goulet
The any_client_port_set() returns true if the ControlPort is set which is wrong because we can have that port open but still not behave as a tor client (like many relays for instance). Fixes #26062 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-05-02Stop logging stack contents when reading a zero-length bandwidth fileteor
When directory authorities read a zero-byte bandwidth file, they log a warning with the contents of an uninitialised buffer. Log a warning about the empty file instead. Fixes bug 26007; bugfix on 0.2.2.1-alpha.
2018-04-10Merge remote-tracking branch 'ahf-github/bugs/24854_029_2' into maint-0.2.9Nick Mathewson
2018-04-09Lift the list of default directory servers into their own file.Alexander Færøy
This patch lifts the list of default directory authorities from config.c into their own auth_dirs.inc file, which is then included in config.c using the C preprocessor. Patch by beastr0. See: https://bugs.torproject.org/24854
2018-03-27Fix CID 1430932Taylor Yu
Coverity found a null pointer reference in nodelist_add_microdesc(). This is almost certainly impossible assuming that the routerstatus_t returned by router_get_consensus_status_by_descriptor_digest() always corresponds to an entry in the nodelist. Fixes bug 25629.
2018-03-01Spec conformance on protover: always reject ranges where lo>hiNick Mathewson
2018-03-01Forbid UINT32_MAX as a protocol versionNick Mathewson
The C code and the rust code had different separate integer overflow bugs here. That suggests that we're better off just forbidding this pathological case. Also, add tests for expected behavior on receiving a bad protocol list in a consensus. Fixes another part of 25249.
2018-03-01Forbid "-0" as a protocol version.Nick Mathewson
Fixes part of 24249; bugfix on 0.2.9.4-alpha.
2018-03-01Add another NULL-pointer fix for protover.c.Nick Mathewson
This one can only be exploited if you can generate a correctly signed consensus, so it's not as bad as 25074. Fixes bug 25251; also tracked as TROVE-2018-004.
2018-03-01Correctly handle NULL returns from parse_protocol_list when voting.Nick Mathewson
In some cases we had checked for it, but in others we had not. One of these cases could have been used to remotely cause denial-of-service against directory authorities while they attempted to vote. Fixes TROVE-2018-001.
2018-02-16Merge remote-tracking branch 'dgoulet/ticket24902_029_05' into maint-0.2.9Nick Mathewson
2018-02-16stop calling channel_mark_client in response to a create_fastRoger Dingledine
since all it does is produce false positives this commit should get merged into 0.2.9 and 0.3.0 *and* 0.3.1, even though the code in the previous commit is already present in 0.3.1. sorry for the mess.
2018-02-16backport to make channel_is_client() accurateRoger Dingledine
This commit takes a piece of commit af8cadf3a9 and a piece of commit 46fe353f25, with the goal of making channel_is_client() be based on what sort of connection handshake the other side used, rather than seeing whether the other side ever sent a create_fast cell to us.
2018-02-13Merge remote-tracking branch 'dgoulet/bug25223_029_01' into ticket24902_029_05David Goulet
2018-02-13dos: Add extra safety asserts in cc_stats_refill_bucket()David Goulet
Never allow the function to set a bucket value above the allowed circuit burst. Closes #25202 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-13dos: Don't set consensus param if we aren't a public relayDavid Goulet
We had this safeguard around dos_init() but not when the consensus changes which can modify consensus parameters and possibly enable the DoS mitigation even if tor wasn't a public relay. Fixes #25223 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-13dirserv: Improve returned message when relay is rejectedDavid Goulet
Explicitly inform the operator of the rejected relay to set a valid email address in the ContactInfo field and contact bad-relays@ mailing list. Fixes #25170 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-12Merge branch 'bug23318-redux_029' into maint-0.2.9Nick Mathewson
2018-02-09dos: Exclude known relays from client connection countDavid Goulet
This is to avoid positively identifying Exit relays if tor client connection comes from them that is reentering the network. One thing to note is that this is done only in the DoS subsystem but we'll still add it to the geoip cache as a "client" seen. This is done that way so to avoid as much as possible changing the current behavior of the geoip client cache since this is being backported. Closes #25193 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-08Merge branch 'ticket25183_029_01' into ticket24902_029_05David Goulet
2018-02-08test: Add unit tests for addressset.cDavid Goulet
This also adds one that tests the integration with the nodelist. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-08Add an address_set to the nodelist.Nick Mathewson
This set is rebuilt whenever a consensus arrives. In between consensuses, it is add-only.
2018-02-05geoip: Make geoip_client_cache_total_allocation() return the counterDavid Goulet
The HT_FOREACH() is insanely heavy on the CPU and this is part of the fast path so make it return the nice memory size counter we added in 4d812e29b9b1ec88. Fixes #25148 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-02dos: We can put less token than the current amountDavid Goulet
Becasue the circuit creation burst and rate can change at runtime it is possible that between two refill of a bucket, we end up setting the bucket value to less than there currently is. Fixes #25128 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-02Merge branch 'ticket25122_029_02' into ticket24902_029_05David Goulet
2018-02-02geoip: Add clientmap_entry_new() functionDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-02geoip: Increment and decrement functions for the geoip client cacheDavid Goulet
These functions protect againts over and underflow. They BUG() in case we overflow the counter. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-02geoip: Hook the client history cache into the OOM handlerDavid Goulet
If the cache is using 20% of our maximum allowed memory, clean 10% of it. Same behavior as the HS descriptor cache. Closes #25122 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-31channel_tls_get_remote_addr_method now returns real_addr.Fernando Fernandez Mancera
The accurate address of a connection is real_addr, not the addr member. channel_tls_get_remote_addr_method() now returns real_addr instead. Fixes #24952; bugfix on 707c1e2 in 0.2.4.11-alpha. Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2018-01-31dos: Make sure cc_stats_refill_bucket can't overflow while calculatingteor
Debug log the elapsed time in cc_stats_refill_bucket Part of #25094. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Make circuit rate limit per second, not tenths anymoreDavid Goulet
Because this touches too many commits at once, it is made into one single commit. Remove the use of "tenths" for the circuit rate to simplify things. We can only refill the buckets at best once every second because of the use of approx_time() and our token system is set to be 1 token = 1 circuit so make the rate a flat integer of circuit per second. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30test: Add unit tests for the DoS subsystemGeorge Kadianakis
Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Clear connection tracked flag if geoip entry is removedDavid Goulet
Imagine this scenario. We had 10 connections over the 24h lifetime of a geoip cache entry. The lifetime of the entry has been reached so it is about to get freed but 2 connections remain for it. After the free, a third connection comes in thus making us create a new geoip entry for that address matching the 2 previous ones that are still alive. If they end up being closed, we'll have a concurrent count desynch from what the reality is. To mitigate this probably very rare scenario in practice, when we free a geoip entry and it has a concurrent count above 0, we'll go over all connections matching the address and clear out the tracked flag. So once they are closed, we don't try to decrement the count. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Add a heartbeat logDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Add the DoSRefuseSingleHopClientRendezvous optionDavid Goulet
This option refuses any ESTABLISH_RENDEZVOUS cell arriving from a client connection. Its default value is "auto" for which we can turn it on or off with a consensus parameter. Default value is 0. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Add the connection DoS mitigation subsystemDavid Goulet
Defend against an address that has reached the concurrent connection count threshold. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Apply defense for circuit creation DoSDavid Goulet
If the client address was detected as malicious, apply a defense which is at this commit to return a DESTROY cell. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Detect circuit creation denial of serviceDavid Goulet
Add a function that notifies the DoS subsystem that a new CREATE cell has arrived. The statistics are updated accordingly and the IP address can also be marked as malicious if it is above threshold. At this commit, no defense is applied, just detection with a circuit creation token bucket system. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Track new and closed OR client connectionsDavid Goulet
Implement a basic connection tracking that counts the number of concurrent connections when they open and close. This commit also adds the circuit creation mitigation data structure that will be needed at later commit to keep track of the circuit rate. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30geoip: Remember client stats if DoS mitigation is enabledDavid Goulet
Make the geoip cache track client address if the DoS subsystem is enabled. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30dos: Initial code of Denial of Service mitigationDavid Goulet
This commit introduces the src/or/dos.{c|h} files that contains the code for the Denial of Service mitigation subsystem. It currently contains basic functions to initialize and free the subsystem. They are used at this commit. The torrc options and consensus parameters are defined at this commit and getters are implemented. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-25geoip: Add a lookup function for client map entryDavid Goulet
The upcoming DoS mitigation subsytem needs to keep information on a per-IP basis which is also what the geoip clientmap does. For another subsystem to access that clientmap, this commit adds a lookup function that returns the entry. For this, the clientmap_entry_t had to be moved to the header file. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-19hs: Use hs_service_max_rdv_failures consensus param, defaulting to 2Roger Dingledine
2018-01-19turn MAX_REND_FAILURES into a functionRoger Dingledine
no actual changes in behavior
2018-01-19MAX_REND_FAILURES is 1, but we would try three timesRoger Dingledine
Fix an "off by 2" error in counting rendezvous failures on the onion service side. While we thought we would stop the rendezvous attempt after one failed circuit, we were actually making three circuit attempts before giving up. Fixes bug 24895; bugfix on 0.0.6.
2018-01-08Add 7 other fallback dirs from teor's testsNick Mathewson
These are from "fallback_dirs_2018_01_06_2323_UTC_44aa1adf35_AU.inc"
2018-01-08Update the fallback_dirs.inc file: part 1Nick Mathewson
This takes the updated fallback_dirs_2018_01_06_CA.inc from pastly's scan.
2018-01-05Merge branch 'teor_ticket24681_028' into maint-0.2.9Nick Mathewson
2018-01-05fix a wide lineNick Mathewson