Part C Β· The deep and dark web
Chapter 18 Β· Tor in depth: relays, circuits and onion services
Learning outcomes
- You can explain how onion routing separates who you are from where you go: layered encryption, the three-relay circuit, and what the guard, middle and exit each can and cannot see.
- You can describe the network's machinery: relay types and why guards are "sticky", directory authorities and the hourly consensus, bridges and pluggable transports (obfs4, Snowflake).
- You can explain what Tor Browser adds over plain Tor, and how onion services v3 work β introduction points, rendezvous points, and the self-authenticating 56-character address.
- You can read Tor Metrics honestly β users, relays, onion counts β with dates and caveats.
- You can state Tor's threat model precisely: what it protects against, what it does not, and why that boundary sets up Chapter 20. In the technical tier you can run Tor Browser and host an onion service for your own lab page.
Concepts
The design problem, and the circuit that solves it
Chapter 4 taught the idea you need here: public-key encryption lets two parties share secrets without meeting. Tor's designers used it for one specific purpose β to make sure that no single computer ever knows both who is talking and what they are talking to.[4]
When you connect to a website through Tor, your software builds a circuit: a chain of three volunteer computers called relays. Your traffic is wrapped in three layers of encryption β like a letter sealed inside three envelopes. The first relay (the guard) removes the outer envelope and sees only: a message from you, addressed onward. The second (the middle) removes the next envelope and sees only: a message from the guard. The third (the exit) removes the last envelope and sees the destination β but it never saw your address. The website, finally, sees a visitor: the exit relay. Your address appears nowhere in the second half of the journey; your destination appears nowhere in the first half.
Two consequences follow. First, circuits are rebuilt constantly β Tor gives each new site a fresh path, so the newspaper you read at 9 a.m. cannot be tied to the clinic site you visit at 9:05 by anyone watching a single relay. Second, the design only works because thousands of strangers volunteer their computers; your traffic needs a crowd to hide in.
In plain words: the exit relay can read anything you send unencrypted β Tor hides who you are, not what you send. With HTTPS, the exit sees only the site's address. That is why encryption at the application layer still matters on Tor.
What the exit sees, in the two cases:
HTTP (plain): exit sees your request in the clear β URLs, form
fields, cookies, content. Tor has hidden your IP,
not your words. Never send credentials over http://
through Tor β or anywhere.
HTTPS (TLS): exit sees: "someone is talking to example.com"
(the address needed to carry the connection) and
encrypted bytes. Content, paths, cookies: all stay
between you and the site end-to-end.
Exit policies. Exit operators publish which ports and protocols they are willing to carry β many block email submission or file-sharing ports to reduce abuse. This shapes the network: fewer exits mean exit capacity is precious, and abuse complaints land at the exit operator's door, which is why running an exit is the most legally exposed volunteer role (the Legal & ethics box returns to this).[5]
For a defender, the exit's view is also a monitoring point: traffic leaving the Tor network toward your systems looks like it comes from exit-relay addresses β a fact every SOC (Security Operations Centre) should recognise (Chapter 32) and every abuse desk handles daily.
The relays: guards, middles, exits β and stickiness
On 17 October 2026, the network's consensus listed roughly 8,900β9,400 relays, of which about 4,000 carried the Guard flag (eligible to be first hops) and around 2,700 were exits.[6] All are volunteers β universities, companies, individuals β donating bandwidth. The middle relay is the quiet workhorse; the interesting roles are the two ends.
The guard is the only relay that ever sees your address. Because that position is powerful, Tor does something clever: it does not pick a new guard for every connection. Your client chooses a small set of guards and keeps them for weeks β the Tor Project describes client guard rotation on a 4-to-8-week cycle.[7] Why? If you rolled fresh dice on every circuit, a hostile relay operator would eventually be your guard β and once your guard and your exit are both hostile, your anonymity is in danger (Chapter 20 explains exactly how). With sticky guards, you roll the dice a few times a year, not a few times a minute. The probability of catastrophe stays small and bounded β probability reasoning as a security control.
The exit is the legally exposed volunteer. It carries the traffic out to the ordinary internet, so complaints about that traffic β from copyright notices to worse β arrive at the exit's door. The community's answers: published exit policies, clear abuse-response documentation, and lists that let site operators distinguish exit traffic from attackers. India has no law against running any relay; the practical risk for exit operators is administrative noise, not prosecution (the legal box covers this).
Directory authorities and the consensus: the network's map
How does your Tor client know which relays exist? It consults a consensus β a single signed document listing every relay, its capabilities, and how much traffic it should carry. The consensus is produced hourly by a small fixed set of trusted servers called directory authorities β nine of them in the consensus inspected for this chapter, run by long-standing members of the community in different countries.[6] Your client fetches the consensus, checks the signatures, and only then builds circuits.
In plain words: nine trusted servers take a vote every hour on the list of all relays, and publish one signed list that every client verifies. The vote's integrity β not any single server β is the network's source of truth.
The directory protocol in five steps:[8]
- Relays announce themselves to the authorities, with keys and claimed bandwidth.
- Authorities measure. Each authority independently probes relays (reachability, bandwidth) β claims are not trusted.
- Hourly vote. Each authority publishes its view: which relays exist, which deserve flags (Guard, Exit, HSDir, Stable, Fastβ¦), what weights clients should give them.
- Consensus. A majority-agreed document is computed and signed; clients verify signatures from a majority of the authority keys, which are hard-coded into the software itself.
- Clients build circuits only from the consensus β with weights that spread load and diversity requirements that avoid same-subnet paths.
Why hard-coded authorities? The consensus is the one place Tor accepts centralisation β a small, public, accountable trust anchor rather than a hidden one. Anyone can audit it live: the consensus-health page shows each authority's vote, disagreements and all.[6] For investigators, the same page is ground truth for "what did the network look like on date X".
Bridges and pluggable transports: surviving the blockade
Chapter 16 explained why censors block Tor; here is the machinery that answers them. A bridge is a guard that is not listed in the public consensus β invisible to a censor working from the relay list. Tor's support pages describe how users request bridges when the network is unreachable.[9] A pluggable transport then disguises the traffic itself, so the censor cannot recognise it even on the wire:
- obfs4 scrambles Tor's traffic into bytes that look like random noise β nothing to signature-match.
- Snowflake is the volunteer masterpiece: anyone can run a tiny proxy in their browser; a censored user's traffic passes through an ordinary-looking WebRTC connection β the technology of video calls β to those volunteers, and onward into Tor. At the time of writing, over 127,000 Snowflake proxies were listed as available.[10]
- meek-azure and WebTunnel camouflage traffic as connections to big hosting services, harder to block without collateral damage.[10]
This is the system that held the line in Russia in December 2021: the censor blocked relays, then listed bridges, and the network kept rotating in bridges and transports the censor had not yet found.[1] The arms race never ends β that is the honest reading β but each round costs the censor more and the network less.
Tor Browser: hardening the human at the keyboard
Routing through Tor with an ordinary browser leaks like a bucket with holes: the browser's font list, screen size, add-ons and behaviour can single you out (Chapter 20's fingerprinting section explains the attack), and a stray request can bypass the proxy entirely. Tor Browser exists to close those holes:[11] every user is engineered to look roughly like every other user (a uniform fingerprint, one of the hardest problems in the field); each site gets its own isolated circuits and storage, so trackers cannot stitch your visits together; and the connection runs through the network by default, with no configuration to forget.
Its security slider is a risk dial. Standard enables the web's active code (JavaScript) for maximum compatibility. Safer and Safest progressively disable it on more sites, closing the largest attack surface β malicious web code β at the cost of some functionality. The trade is deliberate: the more hostile your environment, the higher you set it. SecureDrop's source guide, for instance, tells sources to set Safest before submitting.[12]
Onion services v3: both ends hidden
Everything so far hides you from the site. Onion services reverse the lens and hide the site as well β no hosting address to find, no domain to seize. That is why the BBC's mirror cannot simply be cut off (Chapter 16), and why a market is hard to locate but never impossible to find through human error (Chapters 21, 25).
The address does something quietly remarkable: it is the site's identity. A version-3 onion address is derived from the service's public key, so the 56 characters both name and authenticate the site. A lookalike address cannot impersonate the real one, because it would need the key. This is why every chapter of this book repeats the same instruction β take onion addresses from the organisation's own HTTPS pages: the address itself guarantees that what you reach is what the address-holder runs.[13]
In plain words: the 56 characters of an onion address are mathematically derived from the site's secret key. That is why the address cannot be faked β and why the key file behind it must never leak.
Anatomy of a version-3 address:[13]
bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion
βββ 56 characters, base32 βββββββββββββββββββββββββββββββββββββββ
decoded = [ public-key portion of the service's Ed25519 key ]
+ [ checksum bytes (type + key, hashed) ]
+ [ version byte (0x03) ]
So: the address NAMES the key, and the key PROVES the service.
First contact runs a key-blindness handshake so the long-term
key is never exposed directly on the wire.
Consequences worth memorising. The address is self-authenticating: change one character and it is not a "similar" site, it is a different identity β the defence against lookalike phishing from Chapter 14. The hostname file on the operator's side sits next to the private key; the official setup documentation warns plainly that leaked keys let anyone impersonate the service.[14] And because descriptors are stored across many HSDir relays, no single hostile relay can silently take over a service's discovery β a design lesson written after the attacks Chapter 20 documents.
Tor Metrics: reading the network honestly
Chapter 14 established the discipline; here is the fuller toolkit. Tor Metrics publishes, with methods and caveats: users by country (estimated from directory requests β roughly three million mean daily users in October 2026, India around 134,000); relays and bridges by type and flag; onion services (roughly 590,000β700,000 unique v3 addresses seen per day, extrapolated); and annotated events such as the February 2026 Iran shutdown period visible in country data.[15] Every chart exports its raw data, so a professional cites exact values with dates instead of screenshots. Read all of it as estimates with error bars β the honest practitioner quotes the date, the method and the caveat together, and re-checks before relying on any figure.
The threat model: what Tor promises, and what it does not
Tor's own documentation is refreshingly blunt about its guarantees.[9] It protects against: a local observer (your internet provider, campus network, or a coffee-shop attacker) learning where you go; websites learning who you are (they see an exit); and observers linking your different activities to each other. It does not protect against: an unencrypted site's content being visible to the exit; a global adversary who can watch both ends of your traffic and correlate it; malware or exploits on your own device; and β most common of all β you: logging into your real-name account, reusing a pseudonym, or leaking a detail in a post. Anonymity is a system property, and the human is part of the system.
That boundary line is not a footnote; it is the outline of Chapter 20, where each non-guarantee becomes an attack class with published research behind it. A professional knows both halves: the tool is strong, and the tool is not magic.
Worked walk-through: one request, four witnesses
Follow one real action end to end: Aisha, in Mumbai, uses Tor Browser to open https://portal.example-bank.example/statement. Four parties could observe parts of this. What does each learn?
Her internet provider. Sees encrypted bytes flowing to one relay address β the guard. Learns: Aisha uses Tor (the guard is publicly listed) and how much she transfers. Learns nothing about the destination. If Aisha were in a place where Tor use itself is risky, she would need a bridge and a transport so even this observer sees only an innocuous connection.
The guard. Knows Aisha's address, carries her bytes. Because the payload is multi-layer encrypted, it cannot read the destination. If the guard is hostile, it still knows only half the secret.
The middle. Relays between guard and exit. Sees neither end β the design's quiet hero.
The exit and the bank. The exit opens a connection to the bank's address β so the exit (and any observer near the bank) knows someone via Tor visited the bank's portal. But the URL path, the login, and the statement are inside HTTPS: unreadable to the exit. The bank sees the exit's address, and whatever Aisha's account reveals β the bank knows its own customer, which is the point of logging in.
Now the variant that shows onion services in action: if Aisha instead reads the same bank's public news mirror at its .onion address, there is no exit at all. The meeting happens inside Tor; her provider sees only the guard; the bank's server sees a Tor client, not her address; and the address itself proves she reached the genuine mirror.
Party | HTTP site | HTTPS site | Onion mirror
-------------------+----------------------+---------------------+---------------------
Provider (ISP) | Aisha uses Tor | Aisha uses Tor | Aisha uses Tor
Guard | Aisha β (encrypted) | (same) | (same)
Middle | neither end | neither end | neither end
Exit | full content + site | site's address only | β (no exit exists)
Bank / site | exit's address | exit's address | a Tor client
| | + her login/session | + no address
Lesson: HTTPS still matters on Tor; onion services remove the exit
entirely; the weakest link is the endpoint and the user.
- Circuit
- The three-relay path (guard β middle β exit) that carries one stream of Tor traffic, rebuilt regularly so activities cannot be linked.
- Relay
- A volunteer computer in the Tor network. Guards are first hops, middles carry traffic, exits connect to the ordinary internet.
- Guard (and stickiness)
- The relay that sees your address; kept for weeks (a 4β8 week rotation) so the risk of a hostile guard stays bounded.
- Exit policy
- The published list of ports and protocols an exit will carry, balancing usefulness against abuse exposure.
- Directory authority
- One of a small fixed set of trusted servers (nine voting in October 2026) that measure relays and vote hourly.
- Consensus
- The signed, hourly document listing all relays and their weights β the network map every client verifies before building circuits.
- Bridge
- An unlisted entry point, used where listed relays are blocked.
- Pluggable transport
- Software that disguises Tor traffic β obfs4 (randomised bytes), Snowflake (looks like a video call via volunteer proxies), meek/WebTunnel (camouflaged as big-service traffic).
- Tor Browser
- The hardened browser: uniform fingerprint, per-site circuit and storage isolation, security slider trading function for safety.
- Onion service v3
- A hidden site whose 56-character address is derived from its public key β the address both names and authenticates it.
- Introduction point / rendezvous point
- The relays that, respectively, carry a client's first contact to an onion service and host the meeting that follows.
- Threat model
- The explicit list of adversaries a tool defends against β and, as important, the ones it does not.
Summary
Tor separates who you are from where you go by wrapping traffic in layered encryption and passing it through three volunteer relays, so the guard learns your address but not your destination, the exit learns the destination but not you, and fresh circuits prevent linking your activities. Roughly nine thousand running relays β some four thousand guards and under three thousand exits in October 2026 β are held together by nine directory authorities voting an hourly signed consensus that every client verifies. Where the network is blocked, unlisted bridges and pluggable transports (obfs4, Snowflake's 127,000 volunteer proxies, meek, WebTunnel) keep readers connected, as Russia's December 2021 blockade demonstrated. Tor Browser hardens the endpoint with uniform fingerprints, per-site isolation and a security slider; onion services v3 hide the server too, with introduction and rendezvous points and a self-authenticating 56-character address derived from the service key. Tor Metrics makes the network measurable β honestly, with dates and caveats. The threat model closes the chapter: Tor defeats local observers and curious websites; it does not defeat unencrypted traffic to the exit, global both-ends adversaries, endpoint compromise, or user error. That last list is Chapter 20's syllabus.
Lab β Core tier: who sees what? (no tools needed)
Objective: internalise the circuit's promise by computing, party by party, who learns what. Reasoning, not tools. All scenarios are hypothetical; perform none of them.
Scenarios
- Dev logs into his webmail over Tor via an
http://mirror (no HTTPS). His guard is honest; an unknown party runs the exit. What does the exit learn? What does the site learn? - Priya visits an HTTPS news site over Tor. Her internet provider and the news site's hosting provider both observe traffic volumes. What can each conclude?
- A researcher opens a newspaper's onion mirror from a country that blocks Tor; she reaches it through a Snowflake bridge. What does her provider see? What does the newspaper learn?
- Sameer uses Tor Browser but logs into his real-name social media inside it. Which of Tor's guarantees still hold, and which did he personally destroy?
- A hostile relay becomes the guard in Meena's circuit for a week. Name what it learns, and what it still cannot learn.
- Onion-service operators X and Y use similar-looking 56-character addresses; X's is genuine, Y's is a lookalike someone shared on a forum. Why can Y never convincingly impersonate X at Y's own address?
Steps
- For each scenario, write one line per observing party: learns / cannot learn.
- For each, name the single defence or design feature that limits the damage (HTTPS, circuit rotation, sticky guards, self-authenticating addresses, security slider, user discipline).
Expected result β answer key
1. Exit reads everything: credentials, mail content. Site sees an exit visitor. Defence: never use http:// β the exit is a stranger; HTTPS is not optional on Tor. 2. Provider: Dev-adjacent? (no β Priya's provider) sees "Tor, some volume". Hosting provider sees "an exit visits us, some volume". Neither links the two halves alone. Defence: design (correlation needs BOTH ends β Ch 20 explains who can). 3. Provider sees an innocuous WebRTC-looking connection to a volunteer proxy β not "Tor". Newspaper sees a Tor client, no address. Defences: bridge + transport; onion service. 4. Network guarantees hold (IP hidden). He destroyed them himself: the account IS his identity. Tor cannot anonymise a login. Defence: identity discipline (Ch 27). 5. Guard learns: her IP, timing, volume. Cannot learn: destinations, content. Sticky guards make this exposure rare and bounded rather than constant. 6. Y's address derives from Y's key. X's address is X's identity. Y can only hope victims don't compare β defence: always take addresses from the org's own HTTPS page.
Lab β Technical tier: run Tor properly, host your own onion service β
Switch to Technical mode for the hands-on lab. Part (b) is the β bonus lab: it runs fully locally, and may optionally be repeated against the author's lab server if available (bonus disclaimer applies).
Objective: (a) use Tor Browser the professional way and read a live circuit; (b) demonstrate onion services from the operator's chair β host your Chapter 5 lab page as an onion service on your own machine.
Part A β Tor Browser and the circuit display
- Install Tor Browser from torproject.org/download and verify the signature per the Tor Project's own instructions.[9]
- Connect, visit an ordinary HTTPS site, open the circuit display, and record: the three relay roles and countries.
- Use "New circuit for this site" (site-information menu), then reload the circuit display: note the new path β rotation is per-site and on demand.
- Move the security slider to Safest and note what changes on a content-heavy site β observe the trade-off directly.
Part B β β host your own onion service (own lab page only)
- On your Chapter 5 lab VM, serve your lab page on loopback:
cd ~/lab-site # your Chapter 5 page python3 -m http.server 8000 # serves on 127.0.0.1:8000
- Install the Tor daemon (e.g.
sudo apt install tor) and add two lines to/etc/tor/torrc, following the official setup documentation:[14]HiddenServiceDir /var/lib/tor/my-lab-site/ HiddenServicePort 80 127.0.0.1:8000
- Restart Tor and read your address:
sudo systemctl restart tor sudo cat /var/lib/tor/my-lab-site/hostname
- Open the hostname (a 56-character
.onion) in Tor Browser β your own page, served over Tor, with no exit relay anywhere in the path (check the circuit display). - Housekeeping, exactly as an operator would: confirm the
hostnamefile sits beside private keys that must never leak; after the exercise, comment out the two torrc lines, restart Tor, and delete the service directory so no service remains running.
Expected output
Part A: circuit shows guard/middle/exit with countries; "New circuit" produces a visibly different path; Safest disables active content on the test site. Part B: hostname file contains a 56-char v3 .onion address; Tor Browser loads YOUR Chapter 5 page at that address; circuit display shows an onion-service meeting (no exit); keys noted and service removed afterwards.
Quiz
Twenty questions: fifteen core and five marked Technical. Pass mark 60 per cent. Every answer carries an explanation.
Further reading
- The 2004 design paper β where all of this began, and still readable[4].
- The Tor Project's own documentation trio β support (using Tor), community (running services and relays), spec (the wire-level truth)[8][14].
- Consensus-health and Tor Metrics β watch the network's hourly vote and its published statistics[6][15].
- The Tor Project and OONI accounts of the December 2021 Russia blockade β this chapter's story, from the participants[1][2].
- The Tor-research survey by Saleh and colleagues β a guided map of the academic literature this chapter compresses[16].
References
- The Tor Project, "Responding to Tor censorship in Russia" (blog), 7 December 2021, with updates through 24 December 2021 β blog.torproject.org.
- OONI, "Russia started blocking Tor" (measurement report), 17 December 2021 β ooni.org.
- Reuters, "Russia blocks privacy service Tor, ratcheting up internet crackdown", 8 December 2021 β reuters.com.
- Dingledine, R., Mathewson, N. and Syverson, P., "Tor: The Second-Generation Onion Router", 13th USENIX Security Symposium, 2004 β usenix.org.
- The Tor Project, community documentation on relay operations and exit policies β community.torproject.org/relay.
- The Tor Project, Consensus Health (consensus of 17 October 2026: 8,940 running relays; 9 voting authorities; authority-flagged relays: 10) β consensus-health.torproject.org.
- The Tor Project, "The lifecycle of a new relay" (guard rotation on a 4β8 week cycle), blog, 11 September 2013 β blog.torproject.org.
- The Tor Project, Tor specifications (directory protocol, onion services v3) β spec.torproject.org.
- The Tor Project, support portal (censorship circumvention, bridges, Tor Browser) β support.torproject.org.
- The Tor Project, Snowflake (127,599 volunteer proxies listed at access date; meek-azure and WebTunnel transports) β snowflake.torproject.org.
- The Tor Project, Tor Browser manual and support (fingerprint defences, security levels) β support.torproject.org.
- SecureDrop documentation, Source Guide: "How To Submit" (security level "Safest") β docs.securedrop.org.
- The Tor Project, community documentation: onion services overview β community.torproject.org/onion-services.
- The Tor Project, "Set up Your Onion Service" (torrc configuration; key-leak warning) β community.torproject.org/onion-services/setup.
- The Tor Project, Tor Metrics (users, relays, onion services; annotated events incl. the February 2026 Iran shutdown period) β metrics.torproject.org (figures read 16β17 October 2026).
- Saleh, M. E., Qadir, S. and Ilyas, M. U., "Shedding Light on the Dark Corners of the Internet: A Survey of Tor Research" β arxiv.org/abs/1803.02816.
Unverified: check source All network figures in this chapter are dated snapshots (16β17 October 2026) of moving estimates β relay counts and authority numbers change; re-read consensus-health and Tor Metrics before quoting them. The Iran-shutdown annotation reflects Tor Metrics' event notes at access date. Figures in this chapter are current as of 19 October 2026 unless noted otherwise.