aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/connection_edge.c
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-10-12 20:29:11 +0200
committerDavid Goulet <dgoulet@torproject.org>2022-11-28 10:25:06 -0500
commit15efc25fb502474b8a4f2ee8cb03bd5d185a3f47 (patch)
tree498d3fe4c1453f406cd88a7dae81e412e610bfc3 /src/core/or/connection_edge.c
parentbe7afe658e5fc6745a369d6fb3fbc4bb6037da18 (diff)
downloadtor-15efc25fb502474b8a4f2ee8cb03bd5d185a3f47.tar.gz
tor-15efc25fb502474b8a4f2ee8cb03bd5d185a3f47.zip
dns: Make TTLs fuzzy at exit relays
This change mitigates DNS-based website oracles by making the time that a domain name is cached uncertain (+- 4 minutes of what's measurable). Resolves TROVE-2021-009. Fixes #40674
Diffstat (limited to 'src/core/or/connection_edge.c')
-rw-r--r--src/core/or/connection_edge.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c
index b96f4eb211..504980c9fd 100644
--- a/src/core/or/connection_edge.c
+++ b/src/core/or/connection_edge.c
@@ -102,6 +102,7 @@
#include "feature/stats/predict_ports.h"
#include "feature/stats/rephist.h"
#include "lib/buf/buffers.h"
+#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "core/or/cell_st.h"
@@ -498,6 +499,21 @@ clip_dns_ttl(uint32_t ttl)
return MAX_DNS_TTL;
}
+/** Given a TTL (in seconds), determine what TTL an exit relay should use by
+ * first clipping as usual and then adding some randomness which is sampled
+ * uniformly at random from [-FUZZY_DNS_TTL, FUZZY_DNS_TTL]. This facilitates
+ * fuzzy TTLs, which makes it harder to infer when a website was visited via
+ * side-channels like DNS (see "Website Fingerprinting with Website Oracles").
+ *
+ * Note that this can't underflow because FUZZY_DNS_TTL < MIN_DNS_TTL.
+ */
+uint32_t
+clip_dns_fuzzy_ttl(uint32_t ttl)
+{
+ return clip_dns_ttl(ttl) +
+ crypto_rand_uint(1 + 2*FUZZY_DNS_TTL) - FUZZY_DNS_TTL;
+}
+
/** Send a relay end cell from stream <b>conn</b> down conn's circuit, and
* remember that we've done so. If this is not a client connection, set the
* relay end cell's reason for closing as <b>reason</b>.