Recommended resources
The freely available resources this lesson will direct you to.
Hello! Welcome to the first lesson in our module on achieving anonymity.
Over the past few modules, we've focused on securing the physical hardware and firmware of your ThinkPad. Now, we shift our attention to the software and network layers, starting with the cornerstone of online anonymity: the Tor network.
This lesson addresses the first learning outcome of this module: to explain the fundamental principles of onion routing and how the Tor network provides anonymity. We will explore the core problem Tor was designed to solve, dissect its layered encryption model, and understand the process of building a private communication circuit. This foundational knowledge is crucial for making informed decisions about your anonymity and for understanding the tools, like Whonix, that we'll implement later.
1. The Problem: The Transparency of the Internet
By default, your internet traffic is not anonymous. When you connect to a website, your computer establishes a direct connection with the server hosting that site. An observer monitoring the network (like an Internet Service Provider, a government agency, or an administrator on a local network) can easily see key pieces of information, known as metadata:
- Your IP Address (Source): The unique address of your device on the internet.
- The Server's IP Address (Destination): The address of the website you are visiting.
- The Port and Protocol: Indicating the type of service being used (e.g., port 443 for HTTPS).
- Timing and Volume: The amount of data you send and receive, and when you do it.
While HTTPS encrypts the content of your communication, it does not hide this metadata. An adversary can't read your email, but they know you are connecting to your email provider. This "who is talking to whom" information can be just as revealing as the content itself.
Tor is designed to break this link between source and destination, making traffic analysis significantly more difficult.
2. The Core Concept: Onion Routing
The fundamental principle behind Tor is onion routing. Instead of a direct connection, your traffic is relayed through a series of at least three volunteer-operated servers, called relays or nodes.
The "onion" metaphor comes from the use of layered encryption. Before your data leaves your computer, it is wrapped in several layers of encryption, one for each relay in the path.
To get a clear, high-level overview of this process, please read the following introductory sections from an excellent visual guide on Tor.
How Does Tor Really Work? The Definitive Visual Guide ...
This article from Skerritt Blog, 'How Does Tor Really Work?', provides a very accessible introduction to the concept of onion routing. It uses helpful analogies to explain the core ideas without getting lost in technical jargon at the outset.
Please read the first three main sections of the article. Start from the beginning ('What is Tor?'), continue through the 'Overview', and stop after the 'Onion Routing' section (before 'How Is a Circuit Created?'). Focus on understanding the onion analogy and what each node in the path knows.
As you've just read, each relay in the path peels off one layer of encryption to discover the address of the next relay. It then forwards the remaining encrypted data. This process is visualized in the diagram below.

This design has a critical consequence for anonymity: no single point in the path knows the full story.
- The Entry Relay (or Guard) sees your real IP address but does not know the final destination of your traffic. It only knows the address of the Middle Relay.
- The Middle Relay knows it's receiving traffic from the Entry Relay and sending it to the Exit Relay. It knows neither the true origin (your IP) nor the final destination.
- The Exit Relay knows the final destination (the website you're visiting) but does not know your real IP address. It only knows the traffic came from the Middle Relay.
3. The Tor Design: Building a Secure Circuit
Now that we have the high-level concept, let's look at the technical design. The most authoritative source is the original design paper for the second-generation onion router, which we now call Tor.
Your background in statistics and multi-agent systems will be useful here. Think of the Tor network as a distributed system where the design must account for a specific threat model—an adversary with certain capabilities—and make explicit trade-offs between security, usability, and performance.
Tor: The Second-Generation Onion Router
We will now read selected sections from the foundational paper, 'Tor: The Second-Generation Onion Router' by Dingledine, Mathewson, and Syverson. This will provide a rigorous understanding of Tor's design goals, threat model, and the mechanics of circuit construction.
Please read the following three sections from the paper: Section 3, 'Design goals and assumptions': Focus on the balance Tor strikes between security, deployability, and usability. Section 3.1, 'Threat Model': Pay close attention to the distinction between traffic analysis and traffic confirmation attacks. Section 4.2, 'Circuits and streams', specifically the subsection 'Constructing a circuit': This is the most technical part. Focus on understanding the incremental, hop-by-hop construction and the role of the Diffie-Hellman handshake.
Let's summarize and connect the key points from that reading.
Design Goals and Threat Model
As you read, Tor's design is a pragmatic compromise. It doesn't aim for theoretical perfection against a "global passive adversary" who can see all internet traffic at once. Instead, it aims to defend against a more realistic adversary who can observe some parts of the network, run their own relays, and try to link your activities.
The key distinction is between:
- Traffic Analysis: An adversary trying to discover who is talking to whom by analyzing traffic patterns. Tor is designed to prevent this.
- Traffic Confirmation (or End-to-End Correlation): An adversary who already suspects you are talking to a specific server and wants to confirm it by correlating the timing and volume of traffic entering the Tor network from your IP with traffic leaving an exit node to the server. Tor offers limited protection against this.
Circuit Construction and Forward Secrecy
Section 4.2 of the paper details the elegant process of building a circuit. Here's the crucial mechanism:
- Your client (the Onion Proxy, or OP) chooses a path of three relays (let's call them R1, R2, R3).
- It establishes a connection with R1 and performs a Diffie-Hellman key exchange. This creates a shared secret key,
K1, known only to your client and R1. This key is ephemeral and used for a symmetric cipher like AES. - Your client then tells R1 to extend the circuit to R2. This request is sent through the encrypted tunnel to R1.
- R1 forwards the request to R2, and your client performs another Diffie-Hellman exchange through R1 to establish a shared secret key,
K2, with R2. R1 cannot see this handshake orK2. - This process is repeated for R3, establishing key
K3.
This incremental construction, where each handshake is tunneled inside the previously established part of the circuit, is the core of onion routing.
A vital property this provides is Perfect Forward Secrecy. Because the keys (K1, K2, K3) are ephemeral and negotiated for each circuit, an adversary who later compromises a relay and steals its long-term keys cannot go back and decrypt previously recorded Tor traffic.
4. The Tor Ecosystem
A few final components are necessary for the network to function:
- Directory Authorities: The network needs a way to know which relays are online, their capabilities, and their addresses. This is handled by a small number of hard-coded, trusted directory authorities. They periodically vote on the current state of the network and publish a signed consensus document that all clients download. This prevents an adversary from easily tricking your client into using only malicious relays.
- Guard Nodes: As you read in the Skerritt blog post, the first node in the circuit (the Entry Relay) is in a privileged position since it sees your real IP. To mitigate the risk of an adversary running a relay and getting chosen as your entry point, Tor clients practice "guard pinning." They select a small, stable set of fast, reliable relays as guards and use them as their entry point for several months. This dramatically reduces the probability of connecting to a malicious entry node on any given day.
Conclusion
In this lesson, we've established a solid foundation for understanding how Tor works.
Key Takeaways:
- Tor provides anonymity by obscuring the link between the source and destination of internet traffic.
- It achieves this through onion routing, where traffic is sent through a 3-hop circuit of volunteer relays.
- Layered encryption ensures that no single relay knows both the user's IP address and the final destination.
- Circuits are built incrementally, using a Diffie-Hellman key exchange at each hop to establish ephemeral keys, providing perfect forward secrecy.
- The Tor network relies on a threat model that primarily defends against traffic analysis, not targeted end-to-end correlation attacks.
- The ecosystem is supported by directory authorities for network consensus and uses guard nodes to protect against malicious entry points.
You now have the theoretical framework to understand not just Tor's strengths, but also its weaknesses.
Preview of the Next Lesson:
Building on today's lesson, our next session will be dedicated to a more in-depth analysis of Tor's limitations and vulnerabilities. We will explore attacks like traffic correlation, the dangers of malicious exit nodes, and other ways that anonymity can be compromised.