An onion service builds lots of circuits, and an attacker can force it to build more. If the attacker runs a middle relay, sooner or later one of those circuits will pass through it, and from there the attacker learns which guard the service uses. That's a guard discovery attack. Once the guard is known, the attacker can try to watch or pressure it to find the server's real IP.

Vanguards close that gap by restricting the middle hops too. Instead of picking any relay for the second and third positions, the service picks from a small set of "layer two" and "layer three" relays that rotate on a schedule of days to weeks. An attacker has to compromise several layers in turn, which takes far longer.

Mike Perry first released it as the vanguards add-on, a Python script that also watches for other suspicious circuit behavior. A lighter version, vanguards-lite, was built into Tor in 0.4.7 and applies to onion services and clients by default. High-risk services can still run the full add-on.