Course contentsShow
← Security
Lesson 2985 of 3,05255. Secure CommunicationsFree lesson

Tor Relays: Guard, Middle, and Exit

Learn the role of each relay type, exit node risks, and how the network selects relays for circuits.

Tor Relays: Guard, Middle, and Exit

What you'll learn: How Tor's three relay types work together to protect your anonymity, and why exit nodes carry special risks.

The Three-Relay Circuit

When you learned about onion routing, you saw that Tor builds circuits through multiple relays. Each relay type has a specific role:

Guard relays are your entry point into the Tor network. The Tor client selects a small set of guards and uses them consistently for months. This prevents an attacker from repeatedly forcing you to connect through compromised relays. Think of guards as trusted doorways—you don't want to pick random doors every time, because some might be watched.

Middle relays sit between guard and exit. They know neither your true IP address nor your final destination. They simply relay encrypted traffic, unable to see the content or endpoints. Middle relays form the "anonymity set" that makes traffic correlation harder.

Exit relays decrypt the final layer and connect to your actual destination (website, service, etc.). The exit relay sees unencrypted traffic if you're not using HTTPS, but it doesn't know your real IP—only the middle relay's address.

The Exit Node Risk

Exit relays are the most sensitive position. A malicious exit operator can:

  • Sniff unencrypted traffic (HTTP, plain email)
  • Inject malicious content
  • Log destinations you visit

This is why always using HTTPS over Tor is critical. The exit relay's IP appears as the source to the destination server, which is why exits sometimes face abuse complaints.

Relay Selection

Tor clients select relays based on:

  • Bandwidth weights: Faster relays handle more traffic
  • Exit policies: Some relays refuse exit traffic; only about 10-15% are exits
  • Family/location diversity: Avoiding relays run by the same operator or country

Key Takeaway: Guard relays protect your entry point, middle relays obscure the path, and exit relays expose the most risk—always encrypt end-to-end beyond Tor itself.