Skip to content
pwnsy
network-securitybeginner#tor#anonymity#onion-routing#privacy#network-security

How Tor Works: Onion Routing and the Three-Hop Circuit

How Tor anonymises traffic: onion routing, guard, middle and exit relays, the three-hop circuit, what Tor protects, and where it fails.

When you load a website normally, a lot of parties learn that you did it. Your internet provider sees the destination. The site sees your IP address. Anyone on the wire in between can watch the connection form. Tor exists to break that chain, so that the fact of a connection cannot be traced back to the person who made it.

Tor stands for The Onion Router, and the name describes the mechanism exactly. Your traffic is wrapped in layers of encryption and passed through a series of relays, each of which peels off one layer. No single relay ever holds the whole picture. That property, spread across thousands of volunteer-run relays, is what gives Tor its anonymity.

The problem Tor solves

A direct connection ties two facts together in one place: your identity (your IP address) and your intent (the site you are visiting). Whoever sees both can profile you. A simple proxy or VPN does not fix this. It just moves the party who sees both from your provider to the proxy operator. You have to trust that one operator completely.

Tor removes the need to trust any single point. It splits the two facts across separate relays run by different people, so that learning both would require those separate operators to collude.

Onion routing, layer by layer

Before your traffic leaves your machine, the Tor client builds a path and encrypts your data in nested layers, one for each relay on that path. Think of a sealed parcel inside a sealed parcel inside a sealed parcel.

Each relay holds the key to exactly one layer. It opens its own layer, finds instructions that say only "pass this to the next relay", and forwards it. The relay learns who handed it the parcel and who to give it to next. It learns nothing about the layers it cannot open, and nothing about the layers already removed.

By the time the traffic reaches the last relay, every Tor layer is gone and the original request is forwarded to its real destination. The destination sees a request coming from that last relay, not from you.

The three-hop circuit

A standard Tor path, called a circuit, uses three relays. Each has a distinct role.

RelayAlso calledWhat it seesWhat it does not see
First hopGuard (entry)Your real IP addressThe final destination
Second hopMiddleThe guard and the exitYour IP and the destination
Third hopExitThe final destination and the traffic contentYour real IP address

The middle relay is the important insulation. Because the guard only ever talks to the middle, and the exit only ever hears from the middle, neither end relay can connect your identity to your destination on its own. The guard knows who you are but not where you are going. The exit knows where the traffic is going but not who sent it.

Circuits are rebuilt regularly, roughly every ten minutes for new connections, so a long browsing session does not run through one fixed path.

Why the guard stays the same

Tor deliberately reuses the same guard relay for weeks, while rotating middle and exit relays freely. This sounds backwards, but it reduces your exposure. If Tor picked a fresh entry relay every circuit, you would eventually route through a hostile one by chance. Sticking with a small set of trusted guards lowers the odds that an attacker watching entry traffic ever sees you at all.

What Tor actually protects

Tor protects the metadata of your connection. That is the answer to "who is talking to whom". Specifically:

  • Your internet provider and local network see that you are using Tor, but not what you are visiting.
  • The websites you reach see the exit relay's IP address, not yours.
  • No single relay in the path can link your identity to your activity.

This is genuinely powerful. It defeats the passive observer sitting on your local network, the coffee-shop Wi-Fi snoop, and the site trying to log your real IP.

Where Tor stops protecting you

Tor is precise about what it does, which means it is precise about what it does not do. Understanding the limits is the difference between real privacy and false confidence.

The exit relay sees your unencrypted traffic. Once the last Tor layer is peeled, whatever you sent travels normally to the destination. If that traffic is plain HTTP, the exit operator can read and modify it. HTTPS still matters on top of Tor, because it protects the content the exit would otherwise see.

Tor does not hide what you tell a site about yourself. If you log into an account tied to your name, the site knows exactly who you are regardless of how the packets arrived. Anonymity of the connection cannot survive you identifying yourself over it.

Browser fingerprinting can undo it. Your screen size, fonts, and browser quirks can single you out even with a hidden IP. This is why Tor Browser exists: it is a hardened Firefox that makes users look alike and blocks the scripts that fingerprint you. Routing an ordinary browser through Tor leaks identity through the browser itself.

A global adversary watching both ends is the deep limit. If someone can observe the traffic entering your guard and the traffic leaving your exit at the same time, they can correlate the timing and volume to link the two, even without breaking any encryption. This end-to-end correlation attack is the main theoretical weakness of low-latency anonymity systems, and Tor's guard design is a direct response to it.

Treat the exit relay as untrusted

Tor hides who you are from the sites you visit and hides your destinations from your network. It does not encrypt your traffic all the way to the destination on its own. Treat the exit relay as untrusted: never send anything over Tor that you would not send over open Wi-Fi, unless it is inside HTTPS or an onion service.

Onion services

There is one case where traffic never touches an exit relay: onion services, the sites with .onion addresses. Here both the user and the server build circuits into the Tor network and meet at a rendezvous point inside it. The connection stays encrypted end to end within Tor, the server's location is hidden too, and no exit relay is involved. This is why onion services avoid the exit-snooping problem entirely.

Using Tor without shooting yourself in the foot

  1. Use Tor Browser, not a plugin or a manual proxy. The browser is the anonymity layer as much as the network is. It standardises your fingerprint and blocks the code that would identify you.
  2. Do not log into identifying accounts over Tor if the goal is anonymity. One authenticated session collapses the protection for that activity.
  3. Keep HTTPS on. Assume the exit relay is hostile and let transport encryption protect your content.
  4. Do not resize the browser window or install extra add-ons. Both make you more unique and easier to fingerprint.
  5. Prefer onion services when they exist for sensitive destinations, since they skip the exit relay altogether.

Tor gives you a specific, strong guarantee: your connection metadata cannot be traced to you through any single point. Respect the boundaries of that guarantee and it holds up remarkably well. Treat it as a magic invisibility cloak and you will leak identity through the browser, the exit, or your own logins.

Building a circuit, step by step

The circuit does not appear fully formed. The Tor client constructs it one hop at a time, and the incremental process is what keeps any single relay from learning the whole path. First the client picks a guard from its small set of long-lived entry relays and negotiates an encrypted connection with it, establishing a shared key known only to the client and that guard. That first exchange is the only point where a relay learns the client's real address.

Next the client asks the guard to extend the circuit to a chosen middle relay. The key negotiation for the middle hop is tunneled through the guard, so the guard passes the messages along without being able to read the new key that the client and the middle relay establish. The guard now knows it is talking to a client on one side and a middle relay on the other, and it cannot see past the middle. The client repeats the process once more, extending through the middle to the exit and negotiating a third key that neither the guard nor the middle can read.

At the end of this handshake the client holds three separate keys, one shared with each relay, and each relay holds only its own. When the client sends data, it encrypts it three times, once with each key in the right order, so that each relay peels exactly one layer as the message passes. Responses travel back the same way in reverse, with each relay adding a layer that the client alone can remove all three of. The layered keys are why a relay can forward traffic it cannot read.

What each relay knows

Anonymity comes from splitting knowledge, so it is worth stating precisely what each participant can and cannot see.

PartyLearns your real IPLearns the destinationCan read content
Your internet providerYesNo, sees only that you use TorNo
Guard relayYesNoNo
Middle relayNoNoNo
Exit relayNoYesOnly if traffic is unencrypted past the exit
Destination siteNo, sees the exitYes, it is the destinationYes, it is the endpoint

Read the columns and the design becomes clear. The only party that sees your address is the guard, and it is blind to where you are going. The only party that sees your destination is the exit, and it is blind to who you are. No row holds both facts, which is the entire point.

Detection and the adversary's view

Tor is unusual among privacy tools because using it is observable even though what you do over it is not. Understanding what an observer can tell separates real expectations from false ones.

  • A local observer sees Tor usage. Your provider or network can tell you are connecting to the Tor network, because the guard relays are publicly listed. They cannot see your destinations or content. Where merely using Tor is sensitive, bridges (unlisted entry points) exist to hide the fact of the connection.
  • A destination sees an exit address. Websites receive a connection from an exit relay whose address appears on public exit lists, which is why some sites treat Tor traffic differently. They do not learn your real address from the connection alone.
  • An exit operator sees unencrypted content. Anything you send in plain HTTP is readable and modifiable at the exit. The presence of HTTPS is what removes this exposure.
  • A global passive adversary is the deep threat. An entity able to watch the traffic entering your guard and leaving your exit at the same time can correlate the timing and volume of packets to link the two ends, without decrypting anything. This end-to-end correlation is the fundamental limit of low-latency anonymity, and the guard design exists to make it less likely that an attacker ever sees your entry traffic at all.
Correlation does not require breaking encryption

The correlation attack is often misunderstood as an attack on Tor's cryptography. It works instead on the shape of the traffic, the pattern of packet sizes and timings, which stays recognizable at both ends even though the payload is fully encrypted. This is why simply adding stronger encryption would not close it, and why the practical defense is limiting how often an adversary can observe your entry point.

Common misconceptions about Tor

Several beliefs about Tor are widespread and wrong, and each one leads to a specific mistake.

  • Tor encrypts everything end to end. It encrypts within the network, and the exit forwards your traffic onward in whatever form you sent it. Plain HTTP leaves the exit readable. HTTPS or an onion service is what protects content to the destination.
  • Tor makes you anonymous no matter what you do. Logging into an account tied to your name identifies you regardless of how the packets arrived. Anonymity of the path cannot survive you naming yourself over it.
  • A VPN and Tor are the same thing. A VPN moves trust to one operator who sees both your address and your destination. Tor splits those facts across three independent relays so no single one holds both.
  • Any browser through Tor is safe. The browser is half the protection. An ordinary browser leaks identity through fingerprinting and scripts even with a hidden address, which is why the hardened Tor Browser exists.
  • More hops always mean more safety. The three-hop design is a deliberate balance. Adding hops raises latency without meaningfully improving anonymity against the correlation threat that actually matters, so Tor keeps to three for general circuits.

How onion routing developed

The core idea of wrapping a message in nested layers of encryption and routing it through intermediaries predates the modern Tor network. It grew out of research into anonymous communication, where the goal was to separate the fact of who is communicating from the fact of what they are communicating about. Onion routing gave that separation a concrete mechanism: layered encryption where each relay strips one layer and learns only its immediate neighbors.

The design that became widely used added the elements that make it practical at scale. A volunteer network of thousands of relays spreads trust so widely that colluding enough of them to deanonymize a user is hard. Long-lived guard relays reduce the chance that an attacker watching entry traffic ever catches a given user. A directory of relays lets clients build circuits without a central bottleneck. Onion services extended the model so that a server could receive connections without revealing its own location, keeping both ends inside the network. Each addition responded to a specific weakness in the plain idea, and together they turned a research concept into infrastructure people rely on daily.

Bridges and reaching Tor when it is blocked

Guard relays are published in a public directory, which makes them easy for a network operator to block outright. Where a government or a corporate filter wants to stop Tor entirely, blocking the known entry relays is the obvious move. Tor answers this with bridges, which are entry relays that are not listed in the public directory. A user obtains a bridge address through a side channel, configures Tor to use it, and connects to the network through a relay the blocker does not know about.

Blocking can go further than address lists. A censor can inspect the shape of the traffic itself and recognize the distinctive pattern of a Tor connection, then drop it even without knowing the relay. Pluggable transports exist for this case. They wrap Tor traffic so that it resembles something ordinary, disguising the telltale pattern that a deep-inspection filter looks for. The combination of unlisted bridges and disguised traffic is how Tor keeps working in networks that try to shut it out, and it is a separate concern from the anonymity that the three-hop circuit provides. One hides the fact that you are using Tor, the other hides who you are talking to.

Why Tor is slower than a direct connection

Anonymity through relaying has a cost, and it shows up as latency. A direct request goes from you to the destination. A Tor request travels to a guard, then a middle, then an exit, and only then to the destination, with the response retracing the same three hops back. Those relays sit at varying distances around the world and carry traffic for many users at once, so each added hop adds delay and each relay shares its capacity broadly.

This is a deliberate trade. Tor is a low-latency anonymity system, meaning it keeps delays small enough for interactive browsing while accepting that it will never match a direct connection. Pushing latency lower by cutting hops would weaken anonymity, and pushing anonymity higher with more hops or added delay would make ordinary browsing painful. Three hops is the balance the design settled on. Knowing the reason for the slowness helps set expectations: the delay is the price of splitting knowledge across independent relays, and it buys the property that no single point can tie your identity to your destination.

Slowness is a design choice, not a fault

If Tor feels slower than your normal connection, that is the relaying working as intended. Every request is bouncing through three separate machines run by strangers before it reaches its destination. Treat that latency as the visible cost of the anonymity you are getting, and do not try to speed it up by reducing hops or routing only part of your traffic through Tor, which quietly erodes the protection.

Frequently asked questions

Does Tor make me completely anonymous? It provides strong anonymity for your connection metadata, meaning it hides who is talking to whom through any single point in the path. It does not protect you if you identify yourself over the connection, if your browser is fingerprinted, or against an adversary who can watch both ends of your circuit at once.

Is using Tor illegal? Tor is a general-purpose privacy tool used by journalists, researchers, and ordinary people, and using it is lawful in most places. What matters legally is what a person does, not the tool. Some networks block or flag Tor usage, which is a separate matter from legality.

Why does Tor keep the same guard relay for so long? Rotating the entry relay every circuit would eventually route you through a hostile one by chance, giving an attacker who watches entry traffic a periodic view of you. Sticking with a small, stable set of guards lowers the probability that you ever route your entry through an adversary at all.

Do I still need HTTPS if I use Tor? Yes. The exit relay forwards your traffic to the destination in whatever form you sent it. Without HTTPS, the exit operator can read and modify plain traffic. HTTPS protects the content the exit would otherwise see, so keep it on.

What is the difference between Tor and a VPN? A VPN routes your traffic through one operator who can see both your address and your destination, so you trust that operator entirely. Tor splits those two facts across three separate relays run by different people, so learning both would require them to collude.

What are onion services and why do they avoid the exit problem? Onion services are sites with .onion addresses where both the user and the server build circuits into the network and meet at a rendezvous point inside it. The traffic never leaves through an exit relay, so no exit operator can read it, and the server's location stays hidden too.

Can Tor be traced? Against a single relay or a local observer, no single point can link your identity to your destination. The realistic threat is an adversary powerful enough to observe both your entry and your exit traffic simultaneously and correlate them, which is why that end-to-end correlation is described as Tor's fundamental limit.

For how Tor fits into the wider anonymity ecosystem and the marketplaces built on it, our threat group intelligence dashboard tracks the actors who rely on onion services for infrastructure and leak sites.

Sources & further reading

Sharetwitterlinkedin

Related guides