Back to home
๐Ÿ“„ articleยท Approx. 9 minutes

By Dark Web 101

Onion Routing Explained โ€” How Tor Keeps You Anonymous

The technology behind the dark web, explained layer by layer โ€” no computer science degree required.


The Problem Tor Solves

When you visit a website normally, your connection is a straight line. Your ISP sees the destination. The website sees your IP address. (For a broader overview of what the dark web is and how it differs from the regular internet, see What Is the Dark Web?.) Any network observer in between โ€” a government, a corporation, a hacker on the same Wi-Fi โ€” can log what you are doing and when.

Tor breaks that straight line into pieces so that no single observer can see both ends of the connection. Your ISP knows you are using Tor, but not what you are accessing. The destination knows someone is connecting via Tor, but not who. The relays in between each see only the hop before and after them โ€” never the full picture.

This is onion routing: wrapping your traffic in layers of encryption, like the layers of an onion, and peeling off one layer at each hop.

A Brief History

Onion routing was not invented by anarchists or criminals. It was developed in the mid-1990s at the U.S. Naval Research Laboratory by Paul Syverson, Michael Reed, and David Goldschlag. The military needed a way to protect intelligence communications online โ€” if only spies used the system, the traffic itself would be suspicious, so the system needed civilian users to provide cover traffic.

The Tor Project was founded in 2006 as a nonprofit and has been funded by a mix of U.S. government grants (State Department, DARPA, NSF), private foundations (EFF, Open Technology Fund), and individual donations. The code is open source and has been audited repeatedly.

How Onion Routing Works, Step by Step

1. Your Client Fetches the Tor Consensus

Before building any circuit, the Tor client on your machine downloads a consensus document โ€” a signed list of all known Tor relays and their properties (bandwidth, flags, keys, exit policies). This document is produced every hour by the directory authorities, a small set of trusted servers hardcoded into the Tor software.

There are currently 9 directory authorities maintained by independent operators across multiple countries. For the network to function, a majority must agree on the state of the network.

2. Circuit Construction

When you open Tor Browser, the client selects three relays to form a circuit:

PositionNameRole
1st hopGuard (Entry) RelayYour machine connects directly to this relay. It knows your real IP address but not your destination.
2nd hopMiddle RelayA pass-through node. It knows only the guard and the exit โ€” not your IP or your destination.
3rd hopExit RelayThe final hop. It connects to the destination website on your behalf. It sees the traffic content (if unencrypted) and the destination, but not your IP.

The client builds the circuit incrementally using a process called telescoping:

  1. Establish an encrypted connection to the guard relay using a TLS handshake and then a Tor-specific key exchange.
  2. Through the guard, extend the circuit to the middle relay. The guard cannot read this inner handshake โ€” it just passes bytes.
  3. Through the guard and middle, extend to the exit relay. Neither previous relay can read this innermost handshake.

At the end, your client shares a unique symmetric encryption key with each of the three relays.

3. Layered Encryption โ€” The "Onion"

When you send a request (say, loading a web page), your Tor client encrypts it three times, in reverse order:

Layer 3: Encrypt with exit relay's key    โ†’ outermost peel for exit
Layer 2: Encrypt result with middle relay's key โ†’ middle peel
Layer 1: Encrypt result with guard relay's key  โ†’ innermost peel

The result is a nested "onion" of ciphertext. As the packet travels:

  1. Guard relay decrypts layer 1, sees instructions to forward to the middle relay. Cannot read the inner layers.
  2. Middle relay decrypts layer 2, sees instructions to forward to the exit relay. Cannot read layer 3.
  3. Exit relay decrypts layer 3, revealing the original request. Forwards it to the destination website.

Responses travel back in reverse โ€” each relay adds its encryption layer, and your client peels all three off.

4. Circuit Rotation

Tor circuits are not permanent. By default:

  • A new circuit is created every 10 minutes for new connections.
  • Existing streams (an active page load, for example) stick to their current circuit until they finish.
  • You can manually request a new circuit via the Tor Browser "New Circuit for this Site" option.

This limits the window during which a compromised relay could observe your traffic patterns.

Relay Types in Detail

Guard (Entry) Relays

Guard relays are the most security-critical position in the circuit because they see your real IP address. Tor uses a guard selection algorithm that picks a small number of guards and sticks with them for 2โ€“3 months. This seems counterintuitive โ€” why not rotate constantly?

The reasoning: if you picked a random entry relay every time, and an adversary ran even a small fraction of relays, you would eventually pick one of theirs. By sticking with a fixed guard, you either get unlucky once (and are consistently exposed) or you stay safe indefinitely. Statistically, this reduces the probability of compromise over time.

Middle Relays

Middle relays are the easiest and lowest-risk relays to operate. They see only encrypted traffic flowing between the guard and exit. Running a middle relay is one of the safest ways to contribute to the Tor network.

Exit Relays

Exit relays are the most legally and operationally complex. Because they make the final connection to the destination, the destination website sees the exit relay's IP address as the source. This means exit relay operators occasionally receive abuse complaints or legal inquiries meant for Tor users.

Exit relays publish an exit policy declaring which ports and destinations they are willing to connect to. Some allow all traffic; others restrict to common ports like 80 (HTTP) and 443 (HTTPS).

Bridge Relays

Bridges are unlisted entry relays. They do not appear in the public consensus, making them harder for censors to block. Users in countries that block Tor (China, Iran, Russia, Turkmenistan) use bridges combined with pluggable transports (for more on alternative approaches, see VPN vs Tor) โ€” protocols that disguise Tor traffic to look like ordinary web browsing, video calls, or random noise.

Common pluggable transports include:

  • obfs4 โ€” the most widely used; makes traffic look like random bytes
  • Snowflake โ€” uses WebRTC to tunnel through volunteer proxies
  • meek โ€” tunnels traffic through cloud CDNs (Azure, Google) so that blocking Tor means blocking the entire CDN

How .onion Hidden Services Work

When you visit a .onion address, the traffic never leaves the Tor network. There is no exit relay. Instead, both the client and the server build circuits into the Tor network and meet at a rendezvous point.

Here is the simplified process:

  1. The hidden service picks introduction points. It builds circuits to several relays and publishes their addresses (signed with its key) to a distributed hash table (the Hidden Service Directory).
  2. Your client looks up the .onion address in the directory and finds the introduction points.
  3. Your client picks a rendezvous point โ€” a random relay โ€” and builds a circuit to it.
  4. Your client sends a message through an introduction point to the hidden service, saying: "Meet me at this rendezvous point. Here is a one-time secret."
  5. The hidden service builds a circuit to the rendezvous point and presents the one-time secret.
  6. The rendezvous relay connects the two circuits. Data flows between client and server โ€” both hidden behind three-hop circuits. The rendezvous point cannot read the traffic (it is encrypted end-to-end) and does not know the identity of either party.

This means a .onion service has six hops of encryption between client and server (three on each side), which is why onion sites are noticeably slower than regular websites.

Directory Authorities

The directory authority system is the backbone of Tor's decentralized trust model. Every hour, the 9 directory authorities:

  1. Each independently measure relay bandwidth and check relay status.
  2. Vote on which relays should receive flags like Stable, Fast, Guard, Exit, HSDir.
  3. Produce a consensus document signed by a majority.

Clients download this consensus to know which relays exist and which roles they can serve. If a majority of directory authorities were compromised, an attacker could manipulate the relay list โ€” but compromising 5 of 9 independently operated servers across multiple jurisdictions is a high bar.

Known Weaknesses and Attacks

Tor is not magic. It has real, studied limitations.

Traffic Correlation (End-to-End Timing) Attacks

The most serious theoretical attack: if an adversary can observe both your connection to the guard relay and the exit relay's connection to the destination, they can correlate the timing and volume of packets to link sender and destination. This requires a global passive adversary (think: a nation-state with taps on major internet exchanges).

Tor does not protect against this attack. No practical low-latency anonymity network does. This is the fundamental trade-off: Tor provides usable speeds by forwarding packets quickly, but this means timing information is preserved.

Malicious Exit Nodes

A malicious exit relay can:

  • Read unencrypted (HTTP) traffic
  • Inject content into unencrypted pages
  • Log destination IP addresses and correlate them with traffic patterns

Mitigation: Always use HTTPS. The exit relay cannot break TLS encryption โ€” it just passes the ciphertext through.

Sybil Attacks

An adversary floods the network with relays they control, increasing the odds of being selected as guard, middle, and exit for a given circuit. The Tor Project actively monitors for Sybil attacks and removes suspicious relay groups.

Browser Exploits

The Tor Browser is based on Firefox ESR and inherits its vulnerabilities. In 2013 and 2015, the FBI used Firefox zero-day exploits to deanonymize users of illegal hidden services. Keeping Tor Browser updated is critical.

User Behavior

The most common cause of deanonymization is the user themselves: logging into a personal account over Tor, enabling JavaScript for untrusted sites, torrenting through Tor (which leaks your IP via the BitTorrent protocol), or posting identifiable information. For a comprehensive guide to avoiding these mistakes, see How to Stay Anonymous Online.

Summary

ConceptKey Point
Onion routingWraps traffic in multiple encryption layers; each relay peels one
CircuitsThree hops: guard, middle, exit โ€” rotated every 10 minutes
Guard selectionSticky for 2โ€“3 months to reduce statistical compromise risk
Hidden servicesSix total hops; client and server meet at a rendezvous point
Main weaknessTraffic correlation by a global adversary; Tor does not prevent this
Your jobUse HTTPS, keep Tor updated, do not leak identity at the application layer

Tor is not perfect, and the Tor Project does not claim it is. But for the vast majority of threat models โ€” hiding from ISPs, advertisers, local network observers, and most government agencies โ€” it remains the most battle-tested anonymity tool available.

Related reading:

// end of transmission โœ…

Want to go deeper? ๐Ÿ” Read our complete guide to the dark web ๐Ÿ“–, browse verified .onion links on Deepr (open in Tor Browser), or check our privacy tools ๐Ÿ› ๏ธ.

Return home ๐Ÿ