An onion service builds a lot of circuits. Every new client connection means a fresh circuit from the service to a rendezvous point that the client chose. If the client is an attacker, they're effectively telling the service "build a circuit to this relay, now, and again, and again." That's the lever behind guard discovery, and it's why onion services need more protection around their entry path than ordinary Tor users do.

The attack

The idea was published by Lasse Ă˜verlier and Paul Syverson in 2006, against the hidden services of the day, and the basic shape still applies.

The attacker runs a client and one or more middle relays. The client connects to the target service over and over, picking a rendezvous point it controls. Each time, the service builds a new three-hop circuit: its guard, a middle relay, a third relay, then the rendezvous. Without extra protection, the middle and third relays are chosen fresh for each circuit. Sooner or later, the attacker's own relay gets picked as the hop right after the service's guard. The attacker sends a recognisable traffic pattern down the rendezvous circuit, sees it arrive at their middle relay, and reads off the IP address of the relay it came from. That's the service's guard.

Knowing the guard isn't the same as knowing the service's IP. But it narrows things enormously. The guard is now the one place to watch: an attacker with legal reach can lean on its operator or hosting provider, an attacker with network reach can monitor its traffic, and an attacker with neither can try to knock it offline so the service picks a new guard (ideally one the attacker controls). The guard discovery attack is the first step in a chain, not the last.

How fast does it work? It depends on how much middle-relay bandwidth the attacker controls, since that sets the odds of being picked on each attempt. With a respectable share of the network's middle capacity and the freedom to hammer the service with connection attempts, it's a matter of hours to days, not months. That's the uncomfortable part.

What vanguards change

The fix is to stop choosing the second and third hops at random each time. Instead, the service keeps a small, slowly rotating set of relays for those positions, the same way it keeps a guard for the first.

HopWithout vanguardsWith vanguards
1 (guard)Long-lived guardLong-lived guard
2Fresh random relay each circuitPicked from a small layer-2 set, kept for days or weeks
3Fresh random relay each circuitPicked from a layer-3 set, kept for hours (full vanguards only)

Now the attacker's middle relay can't land next to the guard unless it happens to be in the layer-2 set, and that set changes rarely. Hammering the service with connections doesn't help, because it doesn't produce new layer-2 picks. The attacker is pushed back to finding a layer-2 relay first, then working from there, which is slower and noisier at each step.

There's a trade-off. Every relay you stick with for a long time is a relay that has a long time to observe you, which is the whole debate about guard rotation in a new place (we cover it for ordinary clients in Guard Relays and Why Tor Keeps Using the Same One). The rotation periods in the vanguards design are a compromise between "too short, so discovery is easy" and "too long, so a single malicious relay gets a long view."

Vanguards-lite: what you already have

Tor 0.4.7, released in 2022, turned on a reduced version called vanguards-lite (Tor proposal 333) by default. It pins the second hop to a small layer-2 set for both onion services and onion-service clients, and leaves the third hop random. It needs no configuration. If you're running a current tor, you have it.

For most onion services, that's enough. The vanguards idea is mostly about raising the cost of the cheap version of the attack, and lite does that.

Full vanguards and the addon

The fuller design, with layer-3 pinning and extra checks, was first shipped in 2018 as a separate Python program simply called vanguards, maintained under the Tor Project. It talks to tor over the control port and reconfigures tor's path selection on the fly. It also bundles a few other defences:

  • bandguards watches circuits for suspicious bandwidth patterns, such as circuits that carry far more data than expected or that see dropped cells, which can indicate an attacker injecting a traffic signal.
  • rendguard notices when clients ask the service to use the same rendezvous relay far more often than its share of the network would explain.
  • Smaller modules for logging and path verification.

On Debian and Ubuntu it's packaged as vanguards. You need tor's control port enabled:

# /etc/tor/torrc
ControlPort 127.0.0.1:9051
CookieAuthentication 1
sudo apt install vanguards
vanguards --control_port 9051

The package ships a systemd unit and a sample config with the tunables (layer sizes, rotation times, bandguard thresholds). The defaults were chosen by people who understand the attacks better than most of us, so leave them alone unless you've read the design document in the project's repository and have a specific reason.

Arti, the Rust rewrite of tor, implements vanguards natively with a lite and a full mode, which is part of a longer plan to make full vanguards a normal tor feature rather than an addon. Check the current documentation for your tor or Arti version before deciding whether you still need the separate program. The addon's own README is the authoritative place for its maintenance status.

Who should run full vanguards

Ask what happens if someone learns your service's guard. For a personal blog, a project mirror or a company's public onion site, the honest answer is "not much," and vanguards-lite is plenty. For a whistleblowing platform, an activist site in a hostile country, or anything whose operator would face serious consequences if located, it's worth running the full addon and reading its documentation properly.

Either way, vanguards only protect the network path. The overwhelming majority of real onion services that got unmasked were caught because of application mistakes, misconfigured servers or operator slip-ups, not clever relay attacks. If you haven't already, go through How Onion Services Leak Their Real IP first. It's the more likely problem. The network-level attacks, including the ones vanguards don't touch, are covered in Traffic Correlation Attacks Against Tor.

#vanguards #guard-discovery #onion-service-security #entry-guards #tor