Onion routing

On this page 7

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.

PositionKnows the senderKnows the destinationSees the content
Entry or guard relayYes, its IP addressNoNo, only encrypted cells
Middle relayNoNoNo, only encrypted cells
Exit relayNoYesOnly if the application layer is unencrypted
Local network observerYesNo, only the guardNo
Knowledge held by each relay in a three-hop circuit

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.

VariantLatencyTraffic handlingTypical use
First-generation onion routingLowPrecomputed onions, no forward secrecyResearch prototype, now historical
Tor circuitsLow, roughly 0.3 to 2 s addedTelescoping circuits, stream multiplexingWeb browsing, messaging, onion services
Garlic routing (I2P)Low to moderateSeveral messages bundled per layer, unidirectional tunnelsInternal hidden network services
MixnetsSeconds to hoursBatching, delays and reordering, cover trafficEmail, voting, metadata-resistant messaging
Oblivious HTTPVery lowSingle relay plus encrypted request to a gatewayPrivate telemetry and DNS-like lookups
Main variants of layered-encryption anonymity systems

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 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.

TechnologyWhat it protectsTrust requiredMain limitation
Onion routingLink between sender and recipientNo single relay is trustedVulnerable to end-to-end traffic correlation
Single-hop VPN or proxyIP address from the destinationFull trust in one providerThe provider sees both ends
Oblivious HTTPClient identity from the gatewayRelay and gateway do not colludeOnly suitable for request and response
End-to-end encryptionMessage contentTrust in endpoint keysMetadata remains visible
Anonymization of datasetsIdentity of records at restTrust in the release processRe-identification through quasi-identifiers
How onion routing differs from neighboring approaches

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.

RequirementRecommended approachReason
Anonymous submissions to an organizationHost an onion serviceBoth server and sender stay unlocatable, and no exit relay is involved
Private browsing of public websitesTor Browser with default settingsUniform fingerprint and enforced circuit isolation
Hiding one request from one operatorOblivious HTTPLower latency is sufficient when collusion is unlikely
Resistance to global observersMixnet with cover trafficDelays and batching break timing correlation
Choosing an onion routing configuration

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.