Onion routing is a network anonymity technique in which a message is wrapped in several layers of encryption and forwarded through a chain of relays, each of which removes exactly one layer and learns only the previous and the next hop. In privacy engineering, it is the reference design for unlinkability between sender and recipient: no single relay, and no observer watching a single link, can connect who is talking to whom.
The idea was developed in the mid-1990s at the U.S. Naval Research Laboratory and became widely deployed through the Tor network, the second-generation design whose client is distributed as Tor Browser. The same layered principle also appears in newer constructions such as mixnets and relay-based schemes like Oblivious HTTP, which use fewer hops and different trust assumptions.
How onion routing hides the path of a message
Onion routing hides the communication path by giving each relay only local knowledge. The client selects a route, usually three relays in Tor, and negotiates a separate symmetric key with each one. It then encrypts the payload for the exit relay, encrypts that result for the middle relay, and finally encrypts everything for the entry relay, producing the nested structure that gives the technique its name.
In modern deployments the client builds a circuit telescopically: it performs an authenticated key exchange with the first relay, extends the circuit through it to the second, and then through both to the third. Tor uses the ntor handshake based on Curve25519 for this step, which provides forward secrecy, so recorded traffic cannot be decrypted later even if a relay’s long-term key is stolen. Data then travels in fixed-size cells of 514 bytes, which hides message length at the cell level.
The table below summarizes what each position in a typical three-hop circuit can observe.
| Position | Knows the sender | Knows the destination | Sees the content |
|---|---|---|---|
| Entry or guard relay | Yes, its IP address | No | No, only encrypted cells |
| Middle relay | No | No | No, only encrypted cells |
| Exit relay | No | Yes | Only if the application layer is unencrypted |
| Local network observer | Yes | No, only the guard | No |
The critical property is that the entry relay and the exit relay never share their views unless they collude or are observed by the same adversary. That separation is the entire security argument, and it explains why the choice of relays matters so much.
Variants and generations of onion routing
Onion routing has evolved from a research prototype into several distinct families of anonymous communication. They share layered encryption but differ in latency, in whether they delay or reorder traffic, and in which adversary they resist.
| Variant | Latency | Traffic handling | Typical use |
|---|---|---|---|
| First-generation onion routing | Low | Precomputed onions, no forward secrecy | Research prototype, now historical |
| Tor circuits | Low, roughly 0.3 to 2 s added | Telescoping circuits, stream multiplexing | Web browsing, messaging, onion services |
| Garlic routing (I2P) | Low to moderate | Several messages bundled per layer, unidirectional tunnels | Internal hidden network services |
| Mixnets | Seconds to hours | Batching, delays and reordering, cover traffic | Email, voting, metadata-resistant messaging |
| Oblivious HTTP | Very low | Single relay plus encrypted request to a gateway | Private telemetry and DNS-like lookups |
Onion services, formerly called hidden services, extend the model so that the server also stays anonymous. Both parties build circuits to a rendezvous point, so neither learns the network location of the other, and the service is addressed by a self-authenticating name derived from its public key.
Onion routing compared with related privacy technologies
Onion routing protects network metadata, which places it in a different category from techniques that protect stored data. It is often grouped with other privacy-enhancing technologies, but its threat model and guarantees are specific.
| Technology | What it protects | Trust required | Main limitation |
|---|---|---|---|
| Onion routing | Link between sender and recipient | No single relay is trusted | Vulnerable to end-to-end traffic correlation |
| Single-hop VPN or proxy | IP address from the destination | Full trust in one provider | The provider sees both ends |
| Oblivious HTTP | Client identity from the gateway | Relay and gateway do not collude | Only suitable for request and response |
| End-to-end encryption | Message content | Trust in endpoint keys | Metadata remains visible |
| Anonymization of datasets | Identity of records at rest | Trust in the release process | Re-identification through quasi-identifiers |
The most frequent design error is to treat onion routing as a replacement for end-to-end encryption. It is not: the exit relay sees plaintext unless the application uses TLS or another encrypted protocol, so the two mechanisms should be combined.
Threat model and known attacks
Low-latency onion routing explicitly does not defend against a global passive adversary, meaning an observer who can watch traffic entering and leaving the network at the same time. Such an observer can match timing and volume patterns, an attack known as traffic correlation or end-to-end confirmation. Practical defenses therefore focus on reducing the probability that one party controls both ends.
- Guard relays: each client keeps a small, long-lived set of entry relays, which limits exposure to malicious entries over time.
- Path diversity rules: relays in the same family or the same /16 IPv4 network are not chosen for one circuit.
- Website fingerprinting: a local observer can classify visited sites from cell timing and direction; padding defenses reduce but do not eliminate this.
- Sybil attacks: an adversary may run many relays; directory authorities and bandwidth measurement limit their weight.
- Application leaks: browser plugins, DNS requests outside the circuit or identifying cookies defeat the network layer entirely.
Because of these limits, anonymity depends on the size of the user population. A network with few users offers a small anonymity set, and unusual traffic patterns make a person stand out even when every layer of encryption holds.
Applying onion routing in system design
Engineers adopt onion routing when metadata itself is sensitive: who contacts a whistleblowing platform, which patients look up a clinic, or which journalists reach a source. The decision table below links common requirements with an appropriate configuration.
| Requirement | Recommended approach | Reason |
|---|---|---|
| Anonymous submissions to an organization | Host an onion service | Both server and sender stay unlocatable, and no exit relay is involved |
| Private browsing of public websites | Tor Browser with default settings | Uniform fingerprint and enforced circuit isolation |
| Hiding one request from one operator | Oblivious HTTP | Lower latency is sufficient when collusion is unlikely |
| Resistance to global observers | Mixnet with cover traffic | Delays and batching break timing correlation |
Good practice includes circuit isolation per destination or identity, refusing fallback to direct connections, and documenting the residual risk in a privacy impact assessment. A threat modeling framework such as LINDDUN helps express linkability and identifiability threats that onion routing is meant to mitigate.
Stripped to the essentials
Imagine sending a letter inside three sealed envelopes, each addressed to a different courier. The first courier knows who handed over the package but only sees the next courier’s name. The last courier knows where the letter goes but has no idea who wrote it. No single courier knows the whole story.
Onion routing does the same with internet traffic. Your data is wrapped in layers of encryption and passed through several volunteer computers, each peeling off one layer. The key takeaway: it hides who is talking to whom, but it does not automatically hide what you say, so websites should still use encrypted connections.
Where it is applied
A regional investigative newsroom wants sources to submit documents without revealing their identity, even to the newsroom’s own hosting provider. The security team deploys a document submission platform as an onion service, publishes its onion address in print and on its regular website, and advises sources to use Tor Browser from a network not linked to their employer.
Each submission travels through the source’s three-hop circuit and the service’s own circuit, meeting at a rendezvous relay. Server logs record no client IP addresses, because every connection arrives from the local Tor process. Over a year the platform receives several hundred submissions, and a review of logs and server data shows no network data that could identify a source. The team still strips metadata from uploaded files, since onion routing protects only the connection, not the content of the documents.