Follow
Subscribe via Email!

Enter your email address to subscribe to this platform and receive notifications of new posts by email.

Onion Routing Explained: How Layered Encryption Hides Traffic

Onion routing wraps network traffic in multiple layers of encryption across intermediary relays, hiding who communicates with whom in Tor, I2P, and newer peer-to-peer networks.
A computer monitor in a dark room displaying a terminal network traffic graph.

Onion routing is an anonymous communication technique that wraps network messages in multiple layers of encryption and sends them through a chain of intermediary servers called “onion routers”. Each server along the path peels away one encryption layer to uncover the next destination until the final relay removes the last layer and delivers the data. Because every router learns only the node immediately before it and the node immediately after it, no single server can link the sender to the recipient [8, 11]. Beyond Tor, variants of the design power I2P’s garlic routing, peer-to-peer relays, and experimental vehicular networks, though timing analysis and exit-node eavesdropping still limit what low-latency systems can conceal [3, 10, 11].

How Does Onion Routing Work?

Onion routing works by building an encrypted path—called a chain or circuit—across independent relays before sending application data through it. First, a sender pulls a list of available routers and their public keys from a directory node. Using asymmetric cryptography, the sender negotiates a shared secret, or session key, with the first entry node. Through that encrypted link, the sender passes a message that only the second node can decrypt, and then repeats the process to extend the link to a third node. Chains can grow longer, but they stay short in practice to keep speeds usable [11].

Once the circuit is built, data moves through it in fixed-size cells, with each onion router applying its symmetric key to peel off one encryption layer before forwarding the cell downstream [8, 11]. No relay in the chain can tell whether the node behind it is the originator or another intermediary, and only the exit node learns that it is the final hop before the destination. When a website or remote server replies, the relays reverse the steps: the last node adds the first encryption layer, middle nodes wrap more layers on top, and the sender strips them all off [11].

Single-hop anonymizers work differently. In a single-hop setup such as the Anonymizer, one trusted server strips a user’s origin address before passing traffic along, leaving that single server able to see both ends of the connection [8]. That single-point design sits closer to how forward and reverse proxies handle traffic than to multi-hop circuits. By spreading trust over multiple nodes, onion routing hides who is talking to whom from both outside routers and the relays themselves, even when a sender and receiver choose to authenticate to each other [9].

Paul Syverson, Michael G. Reed, and David Goldschlag created onion routing in the mid-1990s at the U.S. Naval Research Laboratory to protect U.S. intelligence communications online, with part of the work funded by DARPA [11]. They introduced the concept in a 1996 paper titled Hiding Routing Information and published an initial design at the first Information Hiding Workshop before deploying a first-step system in mid-1996 [9, 10].

Work on a follow-up architecture—nicknamed “Onion Routing: The Next Generation” by researchers at the time—began in 1996, appeared briefly at ACSAC in December 1996, and took full shape in the Oakland 97 design paper and a 1998 paper in the IEEE Journal on Selected Areas in Communications [9, 11]. The U.S. Navy filed a provisional patent application in 1997 and a non-provisional filing in 1998, and the patent was granted in 2001. That body of work mapped out uses across web browsing, email, remote login, virtual private networks, and electronic cash [11].

Early deployments stayed small. By 1998, multiple independent networks of about a dozen nodes each ran on Solaris, HP/UX, Linux, Windows NT, and BSD, but none were open to the public [9]. The only long-running public deployment of that era was a fragile single-machine proof-of-concept, which still handled roughly 50,000 connections per day from more than 60,000 distinct IP addresses [8].

How Tor Improved the Design

In mid-2002, computer scientists Roger Dingledine and Nick Mathewson joined Paul Syverson to build a new system called Tor, short for The Onion Routing project [8, 9, 11]. On September 20, 2002, a developer signing off as “Roger” posted a pre-alpha call on the OR-dev mailing list telling testers how to fetch tor-0.0.0.tar.gz, point Mozilla at a local HTTP proxy on port 9051, and browse web pages. “The onion routing network is functional and deployed. It’s not terribly diverse yet, but heck, it’s just for show for now,” he wrote [7].

The Naval Research Laboratory released Tor’s code under a free license—free of the patent that restricted earlier versions—and in 2006 Dingledine, Mathewson, and five others founded The Tor Project as a nonprofit backed by the Electronic Frontier Foundation [8, 11]. By May 2004, when Dingledine, Mathewson, and Syverson published Tor: The Second-Generation Onion Router, the alpha network had reached 32 nodes on two continents [8]. Those volunteer relays became the basis for how Tor network routing shields web traffic through encrypted relays.

Tor fixed major gaps in the 1990s protocol. Because older onion routing built each path with a single multiply encrypted onion, a hostile node that logged traffic and later seized downstream relays could force them to decrypt old traffic. Tor switched to telescoping path building, where the client negotiates short-lived session keys hop by hop and deletes them afterward for perfect forward secrecy. It also adopted the SOCKS proxy interface paired with filtering tools like Privoxy instead of writing separate proxies per protocol, multiplexed many TCP streams over one circuit, added end-to-end integrity checks, replaced network flooding with signed directory servers, let nodes publish variable exit policies, added decentralized congestion control, and introduced “leaky-pipe” mid-circuit exits without needing OS kernel patches like Freedom did [8].

Hidden Services and .onion Domains

Onion routing can hide servers as well as clients, protecting a service’s logical and physical location from denial-of-service attacks [9]. Early designs used long-lived “reply onions” to contact hidden servers, but those broke whenever a relay rotated keys or went offline and offered no forward secrecy. Tor replaced reply onions with rendezvous points, letting clients and hidden servers meet inside the network without exposing the server’s address [8].

Users reach these onion services via .onion, a special-use top-level domain absent from the Internet DNS root. Because traffic to a .onion address never leaves the Tor network through an exit relay, it avoids exit-node eavesdropping and SSL-stripping attacks. On September 9, 2015, ICANN, IANA, and the IETF recognized .onion as a special-use domain meeting RFC 6761 after a proposal from Jacob Appelbaum of the Tor Project and Facebook security engineer Alec Muffett [12].

Each .onion name is a base32 string tied to a public key. Older version 2 names used 16 characters from an 80-bit hash before stable Tor releases dropped V2 support in October 2021, while current version 3 addresses use 56 characters encoding a 256-bit ed25519 key, a version number, and a checksum. After CA/Browser Forum Ballot 144 passed, authorities like DigiCert could issue HTTPS certificates for .onion domains, following early sites from DuckDuckGo in July 2013, Facebook in October 2014, Blockchain.info in December 2014, The Intercept in April 2015, and The New York Times from October 2017 to April 2025. Earlier .exit suffixes for picking exit nodes in a URL were disabled by default in Tor 0.2.2.1-alpha and gone by the 0.3 series, while web gateways like Tor2web let standard browsers open .onion pages by sacrificing user anonymity to the gateway [12].

Garlic Routing vs. Onion Routing

Garlic routing is a variant of onion routing used by I2P, the Invisible Internet Project [10, 11]. Michael J. Freedman coined the phrase in Section 8.1.1 of Roger Dingledine’s June 2000 Free Haven master’s thesis, defining it as an extension that bundles multiple messages—each carrying its own delivery instructions—into one encrypted package. Freedman called each bundled message a “bulb,” whereas I2P developers call them “garlic cloves” [10, 13].

I2P uses the term “garlic” for three things: layered tunnel encryption, end-to-end message bundling above tunnels, and ElGamal/AES+SessionTag encryption for network database entries. Unlike Tor’s two-way circuits, I2P relies on unidirectional tunnels—one outbound and one inbound per user—so a round-trip exchange needs four tunnels. Each client message becomes a clove inside a garlic message, and I2P periodically bundles a Delivery Status Message acknowledgment (wrapped in its own garlic message since release 0.9.12) alongside a Database Store Message holding the sender’s LeaseSet [10].

Packing multiple messages together speeds up data transfers and makes traffic analysis harder for outsiders [11, 13]. Outside the Java-based I2P network, the Windows peer-to-peer client Perfect Dark uses garlic routing over a mixnet and distributed datastore, and a research design called Garlic Cast combines random-walk proxy selection with an Information Dispersal Algorithm for low-latency anonymous file sharing [13].

Timing Analysis and Exit Node Risks

Anonymous relay networks split into two groups: high-latency mixnets descended from Chaum’s Mix-Net design—such as Babel, Mixmaster, and Mixminion—and low-latency onion networks like Tor. High-latency systems delay and reorder packets to resist global eavesdroppers, but that lag breaks interactive tools like web browsing or SSH. Because low-latency circuits move packets quickly, an attacker watching both ends of a route can compare packet timing and data volume [8, 11]. Even when HTTPS hides passwords and content from an ISP, connection logs still record timestamps and byte counts, letting observers correlate traffic entering and leaving a network or track users when circuits rebuild [11].

Exit nodes pose a different hazard because the last relay strips the final onion layer and sends raw data to the destination. If traffic lacks authenticated end-to-end encryption like HTTPS, or if a user accepts a fake SSL certificate, a malicious exit node can capture passwords, private messages, and bank account numbers. Swedish researcher Dan Egerstad showed this flaw by running an exit node that collected passwords for more than 100 email accounts linked to foreign embassies [11].

Even protocol compatibility rules can leak information. In a 2018 study, F. Rochet and O. Pereira examined Tor’s rule that nodes must silently ignore unknown messages to stay compatible with future versions. They built two active attacks: one sent dummy cells that onion services quietly dropped, revealing an onion service’s entry guard in one day through public bandwidth logs, while the “dropmark” attack encoded a 1-bit signal to correlate client flows with overwhelming accuracy in Shadow simulations [6].

Formal Models of Onion Routing

Researchers have also measured how onion routing holds up under mathematical adversary models [1, 4]. In 2012, J. Feigenbaum, A. Johnson, and Paul Syverson analyzed onion routing in a black-box Universally Composable model against an active attacker who controls a fraction b of routers and knows prior destination probabilities. They found that in large networks, a user’s worst-case anonymity occurs when other users either always pick the destination that user is least likely to visit or always pick the exact same destination—leaving worst-case anonymity against fraction b comparable to best-case anonymity against fraction √b [1].

Guard selection is another focus of formal study. Tor pairs clients with long-term “entry” guards to blunt predecessor attacks that gradually deanonymize users as circuits rotate, and in 2014 Dingledine and colleagues proposed moving from three guards to a single long-term guard. In 2015, J. Hayes and G. Danezis proved that one guard would be optimal only if the network never failed. Under realistic node failures, a single guard leaves users open to fingerprinting attacks and shrinks anonymity sets for fresh guards, so Hayes and Danezis proposed shared “guard sets” that boost attack resistance without noticeable bandwidth loss [2].

Cryptographers have also designed protocols with formal differential-privacy proofs. In 2017, M. Ando, A. Lysyanskaya, and E. Upfal introduced provably secure onion routing protocols for passive and active adversaries where each user still picks paths independently. Their active-adversary protocol finishes in O(log² λ) rounds and has each participant send O(log⁴ λ) onions per round [4].

Peer-to-Peer Designs Beyond Tor

Not every low-latency anonymity design organizes relays the same way Tor does. Earlier alternatives included the Java Anon Proxy (also known as Web MIXes), which routes traffic down fixed shared cascades, and PipeNet, which offered stronger guarantees but let a single silent user halt the entire network. Peer-to-peer networks such as Tarzan and MorphMix took another path by having every participant both generate traffic and relay packets for peers so outsiders can’t tell who originated a stream [8].

Recent papers adapt onion routing for decentralized web links and mobile environments [3, 5]. In 2019, K. Balasubramanian and S. Kannan proposed a peer-to-peer onion routing architecture for WebRTC connections that avoids relying on a single server—which creates a single point of failure and exposes IP addresses under tunnel port forwarding—by using multiple directory servers and an onion routing chain [5].

Highly mobile networks raise tougher hurdles because links break as nodes move. In a 2019 IEEE Internet of Things Journal study, M. S. Haghighi and Z. Aziminejad designed a location-based onion routing protocol for vehicular ad hoc networks (VANETs). Vehicles form dynamic relay groups around set locations, swap real identities for pseudo-IDs, and lengthen or shorten chains on the fly to trade off location anonymity and speed. In SUMO traffic simulations, the protocol beat naive onion routing on delivery ratio, delay, and retransmissions [3].

Sources
  1. ACADEMIC JOURNAL Feigenbaum, J., Johnson, A., & Syverson, P. F. (2012). Probabilistic analysis of onion routing in a black-box model. ACM Transactions on Information and System Security, 15(3), 1-28. [Article Link]
  2. ACADEMIC JOURNAL Hayes, J., & Danezis, G. (2015). Guard Sets for Onion Routing. Proceedings on Privacy Enhancing Technologies, 2015(2), 65-80. [Article Link]
  3. ACADEMIC JOURNAL Haghighi, M. S., & Aziminejad, Z. (2019). Highly Anonymous Mobility-Tolerant Location-Based Onion Routing for VANETs. IEEE Internet of Things Journal, 7(4), 2582-2590. [Article Link]
  4. ACADEMIC JOURNAL Ando, M., Lysyanskaya, A., & Upfal, E. (2017). Practical and Provably Secure Onion Routing. DROPS (Schloss Dagstuhl – Leibniz Center for Informatics). [Article Link]
  5. ACADEMIC JOURNAL Balasubramanian, K., & Kannan, S. (2019). Onion Routing in Anonymous Network. Applied Mathematics & Information Sciences, 13(S1), 247-253. [Article Link]
  6. ACADEMIC JOURNAL Rochet, F., & Pereira, O. (2018). Dropping on the Edge: Flexibility and Traffic Confirmation in Onion Routing Protocols. Proceedings on Privacy Enhancing Technologies, 2018(2), 27-46. [Article Link]
  7. WEBSITE SEUL.org. (2002, September 20). pre-alpha: run an onion proxy now! OR-dev Mailing List. [Article Link]
  8. WEBSITE Dingledine, R., Mathewson, N., & Syverson, P. (2004, May 18). Tor: The Second-Generation Onion Router. The Tor Project. [Article Link]
  9. WEBSITE Onion-Router.net. (2005). Onion Routing. [Article Link]
  10. WEBSITE The Invisible Internet Project. (2025, October 1). Garlic Routing. I2P Docs. [Article Link]
  11. WEBSITE Wikipedia. (n.d.). Onion routing. [Article Link]
  12. WEBSITE Wikipedia. (n.d.).onion. [Article Link]
  13. WEBSITE Wikipedia. (n.d.). Garlic routing. [Article Link]

Cover image: Korrupt / Wikimedia Commons, CC BY 4.0

Leave a Comment

Related Posts
Total
0
Share