Tor hides the network path to an onion service very well. It does nothing to stop the server from simply telling people where it is, and servers are chatty. Nearly every documented case of an onion service being located came down to something on the server side or the operator's side, not a break in Tor. When the FBI explained how it found the Silk Road server in 2013, its account was that the site's login page leaked the real IP address through a misconfigured component (the defence disputed that account, and how the server was really found is still argued about). Misconfiguration is the boring, reliable way these things fall over.

Here are the leaks I see over and over, roughly in order of how often they happen.

The web server is also listening on the public IP

Default installs of Apache and Nginx listen on all interfaces. If your onion site's virtual host is the default one, or the only one, the same content is served to anyone who browses to the server's public IP. Services like Shodan and Censys scan the entire IPv4 space continuously and record page titles, response bodies, headers and favicon hashes. Matching an onion page to an indexed IP can be a single search.

Fix it at the source: bind to 127.0.0.1 or a Unix socket, not 0.0.0.0. Then verify from the server:

sudo ss -tlnp

Everything belonging to your site should show 127.0.0.1 or [::1]. Don't forget IPv6. A server that's carefully locked down on v4 and wide open on v6 is a classic.

Status pages, debug pages and default content

Apache's mod_status exposes /server-status to localhost by default. On an onion service, every request comes from localhost (it's tor connecting to the web server), so /server-status is visible to every visitor, and it can list other virtual hosts, client requests and sometimes the server's own addresses. Researchers found a lot of onion sites with this page open around 2016, and it's still a thing. Disable the module or restrict it by something other than source IP.

The same localhost logic catches other tools that trust 127.0.0.1: admin panels with "allow local" rules, framework debug toolbars, phpinfo() pages, metrics endpoints. On an onion service, "local" means "everyone." Assume any page that's visible to localhost is public.

Error pages are a smaller version of the same problem. A stack trace with full file paths, a database error naming the host, a "Welcome to nginx on Debian" page on a mistyped path. None of these give away the IP directly, but they hand over clues: OS, versions, usernames in paths, hostnames that match a clearnet server.

The server talks to the internet on its own

This is the one that experienced people still get wrong. Anything your server fetches from the internet, it fetches from its real IP unless you've arranged otherwise. Examples:

  • A forum that shows link previews or proxies remote images.
  • Avatar fields that accept a URL and download it.
  • Webhooks, OAuth callbacks, payment notifications, RSS fetchers.
  • Outgoing email from contact forms or password resets. Mail headers include the sending server's IP.
  • Package updates, plugin update checks, NTP, DNS lookups.

The first three let a visitor trigger a request to a server they control and simply read the source address off their logs. That's not a sophisticated attack; it's an evening's work.

The real fix is to make it impossible for the server to reach the internet except through tor. On a single Linux box, an egress firewall that only lets the tor user out does most of the work:

iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -m owner --uid-owner debian-tor -j ACCEPT
iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -j REJECT
# and the same for ip6tables

Now the web app trying to fetch a URL simply fails, which you'll notice and fix properly (route it through tor's SOCKS port, or remove the feature) rather than leaking silently. Updates can go through tor too; Debian's apt-transport-tor exists for this. A stronger setup puts the web server in a VM or container whose only network is a Tor gateway, the model Whonix uses. Then even a fully compromised web app can't reach the internet directly.

Shared identity with a clearnet server

Running an onion site on the same machine as a normal website is fine for organisations that aren't hiding (see why big sites run onions). For anyone who is, it creates correlations everywhere:

The same SSH host key. If SSH is reachable on the public IP and also offered over the onion (or the clearnet IP is in some scanner database), the host key fingerprint matches. Scanners index those too.

The same TLS certificate or certificate details. If you put a certificate on the onion that also covers a clearnet name, Certificate Transparency logs publish that link forever. More on that in HTTPS on .onion.

The same unusual software stack, response headers, ETag format or page content. Anything distinctive enough to search for.

Uptime and timing

If your server goes down whenever a particular hosting provider has an outage, someone watching both can line them up. The same goes for reboots: tor rebuilds descriptors and circuits after a restart, and an observer polling your service can see the gap. Over weeks, these coincidences add up. There's not a lot to do about it except keep the service stable and avoid tying it to infrastructure that has public status pages. It's a slow attack, mostly relevant to services that someone determined is already looking at.

The operator

Finally, the leaks that aren't technical at all. Reusing a username from your personal accounts. Uploading images with EXIF data from your own camera. Posting announcements at times that match your timezone. Writing in a style that matches your public blog (stylometry is a real field). Logging into the server's hosting account from your home connection. Paying for the VPS with a card in your name.

Several high-profile operators were identified through exactly this sort of thing, long before anyone needed to touch the Tor network. Our OPSEC basics article covers the habits side.

A quick audit

If you only have half an hour, do this. From a different network, request your server's public IP (v4 and v6) on ports 80, 443 and anything else you run, and make sure nothing related to the onion comes back. Run ss -tlnp on the server. Grep your web server config for server-status, status and allow 127.0.0.1. Try every feature on your site that takes a URL and point it at a server you control; if you see a connection from your server's real IP, you've found a leak. Then turn on the egress firewall and see what breaks. Whatever breaks was leaking.

None of this replaces protection against network-level attacks like guard discovery, but in practice it's where the real risk sits.

#onion-service-security #ip-leak #opsec #server-hardening #deanonymization