A Complete Technical Deep Dive into The Onion Router
- How to Use This Book
- Conventions and Scope
Part I: Foundations
Chapter 1: Why Anonymity and Tor
- The Problem of Network Surveillance
- What Tor Protects
- Threat Models and Adversaries
- What Tor Does Not Protect
- Anonymity Sets and Metrics
- Why Circuits? Why Three Hops?
- The Tor Ecosystem at a Glance
- History in One Paragraph
Chapter 2: Networking Foundations
- The Internet Protocol Stack
- IP Addresses and Ports
- TCP: Reliable Byte Streams
- TLS: Encryption for the Transport
- SOCKS: The Proxy Protocol Tor Clients Speak
- DNS: Name Resolution and Its Privacy Implications
- UDP, ICMP and Tor’s Limitations
- Summarizing the Network Stack View of Tor
Chapter 3: Cryptographic Foundations
- Symmetric Encryption
- Asymmetric Encryption and Public Key Cryptography
- Elliptic Curves and Curve25519
- Hash Functions
- Message Authentication Codes (MACs) and AEAD
- Key Derivation Functions (KDFs)
- Digital Signatures
- Diffie-Hellman Key Exchange
- Perfect Forward Secrecy (PFS)
- Randomness
- Putting the Primitives Together: A Hybrid Encryption Pattern
- Which Primitives Does Tor Use Where?
Chapter 4: Threat Modeling and Anonymity Systems
- Adversarial Models in Anonymity Research
- The Honest Majority Assumption and Its Limits
- Attacks on Anonymity Networks
- Architectural Patterns for Anonymity
- The Threat Model Summary for Tor
Chapter 5: The History of Onion Routing
- 1981: Chaum’s Untraceable Electronic Mail
- The 1990s: Anonymous Remailers and Mixmaster
- 1996-1997: The First Onion Routing Design
- 2000-2002: The Second Generation Redesign at NRL
- 2004: The Tor Paper
- 2004-2010: Growth, Onion Services and Censorship Circumvention
- 2010-Present: Modern Tor, v3 Onion Services and Ongoing Research
- Lessons from History
Chapter 6: Tor Design Goals and System Architecture
- Design Goals
- The Tor Network: Major Components
- The Overall Architecture
- Data Flow: A User’s Request Through Tor
- Terminology Table
- How the Book Builds on This Architecture
Part II: The Tor Network
Chapter 7: Relays, Exits, Authorities and HSDirs
- What Is a Relay?
- Relay Identity and Keys
- Relay Descriptors
- The Different Roles of a Relay
- Guard Relays
- Exit Relays
- Directory Authorities in Depth
- Hidden Service Directories
- Bridges
- How Relay Types Interact
Chapter 8: The Directory System and Consensus
- The Documents of the Directory System
- The Consensus: What It Is and Why It Matters
- How the Consensus Is Built
- The Role of Directory Caches
- Verification and Trust: The Chain of Trust
- Consensus Format: An Example
- Directory Protocol: How Clients Download Documents
- What Can Go Wrong in the Directory System?
Chapter 9: Relay Discovery, Path Selection and Guards
- The Building Blocks of Path Selection
- Guard Selection
- Middle Relay Selection
- Exit Relay Selection
- Circuit Purpose and Path Length
- Bandwidth Weighting and Path Stability
- Avoiding Bad Paths
- Internal Circuits vs Exit Circuits
- Bridges and Path Selection in Censored Environments
- Putting It All Together: Building a Path
Chapter 10: Bootstrapping a Tor Client
- The Bootstrap State Machine
- Bootstrap in Detail
- Bootstrap Status Events
- Bootstrap Failures and Recovery
- Bootstrap Time and Performance
- What Happens After Bootstrap
Part III: Circuits and Protocols
Chapter 11: The Cell and the OR Connection
- The Cell Format
- The Cell Command Set
- The OR Connection
- The Channel Abstraction in the Source Code
- Cell Flow: A Simple Example
- Why Fixed Size Cells Matter
Chapter 12: Circuit Construction and the ntor Handshake
- The Telescoping Circuit Model
- The ntor Handshake
- ntor-v3
- Circuit Construction in Detail: A Sequence Diagram
- Key Derivation for Circuit Layers
- Circuit IDs and Circuit State
- Circuit Failure and Replacement
- Putting It Together: From Path to Circuit
Chapter 13: Relay Cells, Layered Encryption and Data Flow
- The RELAY Cell
- Layered Encryption of Relay Cells
- The Encryption Primitives
- A Simple Educational Example of Layered Encryption
- Stream Multiplexing
- Flow Control
- DNS Resolution Through the Circuit
- Circuit Teardown
- From Cells to Applications
Part IV: Traffic and Applications
Chapter 14: Streams, Multiplexing and Flow Control
- Streams: The Abstraction Between Applications and Circuits
- Stream States and Lifecycle
- Mapping Streams to Circuits
- Circuit Multiplexing and the Circuitmux
- Flow Control in Depth
- Performance Considerations
- Security Considerations
Chapter 15: DNS Resolution, Exit Policies and Traffic Classification
- DNS Resolution in Tor
- DNS Privacy and the DNSPort
- Exit Policies
- Exit Policy and Path Selection
- Exit Relay Risks and Responsibilities
- Traffic Classification and Censorship
- The Future of DNS in Tor
Chapter 16: The Tor Browser Bundle
- What Is Tor Browser?
- How Tor Browser Integrates with the Tor Client
- Fingerprinting Resistance
- Security Levels
- Identity Management
- Tor Browser and the Tor Network
Part V: Onion Services
Chapter 17: Onion Services: Design and Cryptography
- The Goal of Onion Services
- The Participants in an Onion Service Connection
- v2 vs v3 Onion Services
- The v3 Onion Address
- The v3 Key Hierarchy
- Onion Service Descriptors
- Introduction Points
- Client Authorization
- The Onion Service Protocol at a Glance
Chapter 18: The Onion Service Rendezvous Protocol
- The Basic Idea
- Step-by-Step Protocol
- The hs-ntor Handshake in Detail
- Security Properties of the Rendezvous Protocol
- Rendezvous Failures and Recovery
- From Rendezvous to Communication
Part VI: Security and Threats
Chapter 19: Traffic Analysis and Correlation
- The Fundamental Attack: End-to-End Correlation
- Timing Attacks
- Passive Correlation and Statistical Methods
- Correlation Through the Middle
- The Limits of Traffic Analysis Defenses
Chapter 20: Website Fingerprinting and Countermeasures
- How Website Fingerprinting Works
- Types of Website Fingerprinting Attacks
- Tor’s Defenses Against Website Fingerprinting
- The Tradeoff Between Privacy and Performance
Chapter 21: Sybil Attacks, Malicious Relays and DoS
- Sybil Attacks
- Malicious Relays
- Denial of Service Attacks
- Censorship and Censorship Circumvention
Chapter 22: Operational Security and Best Practices
- Opsec for Tor Users
- Opsec for Relay Operators
- The Human Factor
- Summary of Threats and Defenses
Part VII: Implementation and Code
Chapter 23: The Tor Codebase
- Overview
- Repository and Build System
- Directory Structure
- Source File Map
- Key Data Structures
- Key Functions and Execution Paths
- Testing and Debugging
- Contributing to Tor
Chapter 24: Educational Implementations
- Introduction
- Implementation 1: Layered Onion Encryption
- Implementation 2: Circuit Establishment and Cell Relay
- Implementation 3: Ntor Handshake (Rust)
- Implementation 4: Onion Service Rendezvous (Go)
Chapter 25: Building and Running Tor
- Building Tor from Source
- Running a Tor Relay
- Contributing to Tor