Building Private, Anonymous, and Resilient Services on the Tor Network
Introduction
Chapter 1: Landscapes of the Invisible Web
- The Internet’s Layers: Surface Web
- The Deep Web: Everything Behind Login Forms
- The Dark Web: Purpose-Built Anonymity Networks
- Anonymity vs Pseudonymity vs Privacy
- Why Self-Host in the First Place
- Legitimate Use Cases and Real-World Motivations
Chapter 2: Origins and Design Philosophy
- DARPA’s Purple Gang and Early Onion Routing
- Pathway, Mixmaster, and Cryptographic Precursors
- The Tor Project is Born: 2002 to Open Source
- Funding, Governance, and the Modern Tor Project
- Design Goals: Anonymity, Resistance, Usability
- The Political and Social Context
Chapter 3: The Tor Network Architecture
- What is a Tor Node: Client, Relay, Bridge, Authority
- Directory Authorities: The Seven Guardians
- Directory Caches and Consensus Distribution
- Guard Relays and Stable Path Building
- Middle Relays: The Workhorse Tier
- Exit Relays: Touchpoints with the Clearnet
- Onion Services: Servers on the Tor Network
Chapter 4: The Tor Protocol Stack
- The Transport Layer: TCP and TLS Handshakes
- Onion Skin Encryption: Layered Keys
- Link Keys and Circuit Keys
- Key Exchange Protocols: NTor and Older Schemes
- Cell Types and Protocol Messages
- Version Negotiation and Authentication
Chapter 5: Circuit Construction and Routing
- Guard Node Selection and Persistence
- Relay Weighting: Bandwidth, Flags, and History
- Building a Three-Hop Circuit Step by Step
- Exit Node Selection Policies
- Circuit Lifetimes, Expiry, and Refresh
- Path Isolation and Connection Mapping
Chapter 6: Onion Services: Concept and Evolution
- From Hidden Services to Onion Services: Naming Changes
- v2 vs v3: Architecture and Security Improvements
- The Rendezvous Protocol: Meeting in the Middle
- Introduction Points and Rendezvous Points
- Service Identifiers and Public Keys
- Onion Addresses: Encoding, Structure, and Validation
Chapter 7: The v3 Onion Service Protocol
- Private Key Generation and Descriptor Signing
- Publishing Onion Service Descriptors
- Introducing Points: Registration and Maintenance
- Client Discovery: Hash-Based Directory Lookup
- Rendezvous Point Selection and Negotiation
- End-to-End Circuit Establishment
- Descriptor Refresh and Fault Tolerance
Chapter 8: Threat Models and Attack Surfaces
- Tor’s Formal Threat Model: What It Promises
- Passive Network Observers and Local ISPs
- Global Adversaries and Correlation Attacks
- Malicious Relays: Observation and Manipulation
- Endpoint Compromise and Application Leaks
- The Limits of Network-Layer Anonymity
Chapter 9: Traffic Analysis and Correlation Attacks
- Passive Correlation: Timing and Volume
- Active Attacks: Padding and Probe Techniques
- Statistical Fingerprinting and Machine Learning
- Network-Wide Correlation at Scale
- Defenses: Padding, Guard Diversity, Path Length
- Theoretical Guarantees vs Practical Risk
Chapter 10: Fingerprinting and Side Channels
- Browser Fingerprinting and Tor Browser Countermeasures
- TLS Fingerprinting and JA3 Identifiers
- JavaScript Tracking and DOM Fingerprinting
- Application-Level Metadata Leaks
- Timing Side Channels in Web Applications
- Weeping Cryptography and Hidden Data
Chapter 11: Sybil Attacks, Censorship, and Bridges
- Sybil Relays and Identity Fabrication
- Directory Authority Consensus and Weighting
- ISP-Level Blocking and Keyword Filtering
- Bridges: Unlisted Entry Points
- Pluggable Transports: obfs4 and WebTunnel
Chapter 12: Infrastructure Planning and Design
- Jurisdiction and Legal Environment
- Hosting Options: Colocation, VPS, Home Hosting
- Hardware Requirements and Sizing
- Network Topology: Isolation and Segmentation
- Power, Connectivity, and Redundancy
Chapter 13: Operating System Hardening and Security
- OS Selection: Debian, Alpine, or Specialized Distributions
- Minimal Installation and Surface Reduction
- Kernel Parameters and Sysctl Hardening
- User, Group, and Permission Design
- Full Disk Encryption and Key Management
- Intrusion Detection and Log Integrity
Chapter 14: Network Configuration and Firewalls
- Firewall Fundamentals: iptables and nftables
- Default-Deny Policies and Minimal Open Ports
- Blocking All Exit Relay Traffic
- DNS Resolution Without Information Leakage
- Network Interface Isolation
- Detecting and Blocking Direct Access Attempts
Chapter 15: Tor Installation and Core Configuration
- Installing Tor: Package Managers and Compiling
- The torrc File: Structure and Directives
- Configuring HiddenServiceDir and HiddenServicePort
- Running Tor as a Systemd Service
- Validating Circuit and Service Status
Chapter 16: Deploying Your First Onion Service
- Minimal Web Server: Nginx Bound to Loopback
- First Hidden Service Configuration
- Testing with Tor Browser from a Remote Machine
- Verifying No Direct IP Accessibility
- Checking Descriptor Publication
- Troubleshooting First-Time Deployments
Chapter 17: Architectural Pattern: Single-Host Minimal Service
- Single Machine Topology Diagram
- Nginx Configuration for Loopback Binding
- Tor Hidden Service Configuration
- Systemd Service Units
- SSL/TLS Considerations for Onion Services
- Backup and Recovery Procedure
Chapter 18: Architectural Pattern: Hardened Network Segmentation
- Three-Tier Network Topology
- DMZ Host: Tor and Reverse Proxy
- Application Tier Isolation
- Database Tier and Access Controls
- Internal Firewall Rules Between Zones
- End-to-End Request Flow Diagram
Chapter 19: Architectural Pattern: Containerized Multi-Service
- Docker Networking and Host vs Container Mode
- Tor in a Container vs on the Host
- Docker Compose for Multi-Service Stacks
- Reverse Proxy Routing to Multiple Onion Services
- Persistent Volumes and Secrets Management
- Build, Deploy, and Update Workflow
Chapter 20: Private and Authorized Onion Services
- Private Onion Services Concept
- Client Authorization and ClientAuthFile
- Generating and Distributing Authorization Tokens
- Combining Tor with Web-Based Authentication
- Multi-Factor Authentication over Tor
- Managing Revocation and Key Rotation
Chapter 21: Application-Specific Deployments
- File Hosting: Nextcloud and FileBrowser
- Messaging: Matrix, XMPP, and IRC over Tor
- REST and GraphQL APIs behind Onion Services
- Remote Administration: SSH and Web Consoles
- Personal Cloud and Sync Services
- Monitoring and Observability Stacks
Chapter 22: Performance, Scaling, and Optimization
- Tor Latency Characteristics and Benchmarks
- Bandwidth Limits and Congestion Behavior
- Caching and CDN Considerations
- Load Balancing Multiple Onion Services
- Database Performance Behind Tor
- When to Leave Tor Behind for Internal Traffic
Chapter 23: Operations, Monitoring, and Maintenance
- Update Cadence and Security Patches
- Onion Service Key Rotation
- Log Aggregation and Alerting
- Backup Strategies: Encrypted and Offsite
- Incident Response and Breach Containment
- Operational Security Procedures
Chapter 24: Troubleshooting, Diagnostics, and Failure Modes
- Verifying Onion Service Reachability
- Descriptor Publication Failures
- Circuit Construction Problems
- Backend Connectivity Issues
- HiddenServiceDir Permission Errors
- Network-Level Issues
- Application-Level Issues
- Verifying No IP Address Leakage
- Debugging Client-Side Access Issues
Chapter 25: Future Directions and Emerging Technologies
- Post-Quantum Cryptography and Proposal 353
- Quantum-Safe Onion Service Addresses
- Network Growth and Resilience
- Decentralized Alternatives and Complementary Technologies
- Browser Fingerprinting Evolutions
- Machine Learning and Traffic Analysis
- Regulatory and Legal Landscape
- Practical Skills for the Next Decade