(Redirected from Hidden Services)
- 1 Tor Onion Services - EASY
- 1.1 Introduction
- 1.2 Web Server Software Recommendations
- 1.3 Security Recommendations
- 1.4 Hidden Webserver
- 1.4.1 Whonix-Gateway ™
- 1.4.2 Whonix-Workstation ™
- 1.4.3 Debugging
- 1.5 Tips settings up any onion service
- 1.6 Hidden VoIP Server
- 2 Tor Onion Services - ADVANCED
- 3 References
Tor Onion Services - EASY
Be sure to read and understand Tor: Onion Service Protocol [archive] (general information) and Configuring Onion Services for Tor [archive] (standard setup, no isolated proxy) first. Note that onion services are always only reachable using Tor or tunnel services, such as tor2web, (be careful [archive]). Also review Riseup's Tor Hidden (Onion) Services Best Practices guide [archive].
You do not need SSL , because connections to Tor onion services are end-to-end encrypted by default.  This is handy, as you do not have to bother with self signed certificates or certificate authorities.
Another interesting property is they can serve as a drop-in Global Server Load Balancing and Layer 3 DDoS-resistance solution. This raises the bar to withstanding attacks that the entire Tor network can tolerate. Same with I2P Eepsties. Tor can be also considered a very simple to configure encrypted transport alternative to IPSec.
An adversary can see whether the service (and presumably Tor) is up and running or not.
Even if someone hacks your hidden server software (
apache, etc.), the attacker can not steal your onion service key or bypass Tor, see Attack on Whonix ™. The key is stored on the Whonix-Gateway ™. Once you cleaned your Whonix-Workstation ™, no one can impersonate your onion service anymore.
Web Server Software Recommendations
- Avoid the
Apacheweb server. It has much more functionality, leak potential and attack surface than smaller and lighter alternatives.
- If your needs are limited to hosting static pages then look no further than
micro-httpdavailable from Debian repos. It is a bare-bones daemon made up of 150 lines of code.
Nginxweb server is a recommended alternative.
- Credits: Some of these instructions are paraphrased from Sarah Jamie Lewis' write-up after running OnionScan on the Onion web. All credit goes to her. OnionScan is an open source pen-testing suite that exposes misconfiguration errors that expose Hidden Servers. Do run it before your service goes live.
- Application Level Leaks: Beware of application level leaks. See Protocol-Leak-Protection and Fingerprinting-Protection for definition.
- Hide IP: IP hiding instructions for your specific server software should be applied.
- This is because a combination of a webserver that forwards IP addresses to web apps such as for example mediawiki would be a discouraged case, since mediawiki by default puts IPs of anonymous editors in the public accessible editor logs. The IP would be 10.152.152.10. That could not be used to identify you, because that is not your real external IP address, but it would identify the server as an onion service behind a Whonix-Gateway ™.
- Server Software Hardening: If any instructions for hardening the server instructions are available it is recommended to apply them. While using Whonix ™ we're quite confident that there are no IP/DNS leaks, but hardening the server software is still recommended but the responsibility of the user.
- General Hardening: In the Security Guide and in the Advanced Security Guide you'll find pointers for hardening.
- Mitigate DoS attacks: Its good practice to setup access to your site through reverse proxies to mitigate layer 7 DoS attacks and information leaks about your setup.
- Disable Banners: For SSH, FTP, SMTP and HTTP servers which leak info about the a daemon's name and version. If your SSH instance is for private use, use it with an Authenticated Onion Service to protect your server from brute-force and remote exploitation.
- Dedicated Onion Address: Each service you host should get its own dedicated onion address to prevent correlation between multiple instances running in the same VM.
- ALPaCA: An advanced website fingerprinting client/server mitigation named ALPaCA in development that applies server-side padding to requests sent out to Tor Browser. Once ts ready, service operators can run it to protect against this class of correlation attacks.
On your Whonix-Gateway ™:
Step 1: open Tor config
Step 2: edit Tor config
Step 3: make changes to Tor config take effect
Step 4: get your onion hostname
To get your Tor onion service url.
sudo cat /var/lib/tor/hidden_service/hostname
Step 5: backup your Tor onion service private key
Reminder: Always backup the onion service key. This is necessary in order to restore it on another machine, on a newer Whonix-Gateway ™, after HDD/SSD failure, etc. Follow the instructions below to find its location; root permission is required to access it.
On your Whonix-Workstation ™:
Step 1: Install Server Software
A) Run the following commands to install micro-httpd. OR
B) Run the following commands to install nginx.
Step 2: Open Whonix-Workstation ™ Firewall Port
Modify Whonix-Workstation ™ User Firewall Settings
EXTERNAL_OPEN_PORTS+=" 80 "
Reload Whonix-Workstation ™ Firewall.
Step 3: Final Notes
Note, that it may take up to 30 minutes (or so?) until a fresh .onion domain gets reachable.
Note, accessing 127.0.0.1 Local connections are no longer possible due to a change [archive] in Tor Browser by The Tor Project. Check Tor Browser, Local Connections for more information and a workaround..
On Whonix-Gateway ™.
sudo ls -la /var/lib/tor/hidden_service/
In case you manually restored your hidden_service keys as root, Tor will fail to start. The folder must be owned by debian-tor. In that case, fix the permissions.
sudo chown debian-tor:debian-tor /var/lib/tor/hidden_service/
In Whonix-Workstation ™.
Check if the service is available on 127.0.0.1:80.
## Circumventing Whonix ™ curl stream isolation wrapper. UWT_DEV_PASSTHROUGH=1 curl 127.0.0.1:80
## Circumventing Whonix ™ curl stream isolation wrapper. UWT_DEV_PASSTHROUGH=1 curl $(qubesdb-read /qubes-ip):80
Non-Qubes-Whonix ™: In Whonix-Workstation ™, check if the service is available on 10.152.152.11:80.
## Circumventing Whonix ™ curl stream isolation wrapper. UWT_DEV_PASSTHROUGH=1 curl 10.152.152.11:80
Note: Tor Browser will allow connections to 127.0.0.1:80 but not to 10.152.152.11:80.
Tips settings up any onion service
Please test the example Hidden Webserver above first. It helps understanding this in general and will ease debugging.
Quoted from the Tor manual:
HiddenServiceDir DIRECTORY Store data files for an onion service in DIRECTORY. Every onion service must have a separate directory. You may use this option multiple times to specify multiple services. DIRECTORY must be an existing directory.
Quoted from the Tor manual:
HiddenServicePort VIRTPORT [TARGET] Configure a virtual port VIRTPORT for an onion service. You may use this option multiple times; each time applies to the service using the most recent hiddenservicedir. By default, this option maps the virtual port to the same port on 127.0.0.1 over TCP. You may override the target port, address, or both by specifying a target of addr, port, or addr:port. You may also have multiple lines with the same VIRTPORT: when a user connects to that VIRTPORT, one of the TARGETs from those lines will be chosen at random.
Hidden VoIP Server
On the VoIP page is an example for a Hidden VoIP Mumble Server.
Tor Onion Services - ADVANCED
Onion Services Security Enhancements
- https://blog.torproject.org/announcing-vanguards-add-onion-services [archive]
- https://github.com/mikeperry-tor/vanguards [archive]
- https://forums.whonix.org/t/vanguards-additional-protections-for-tor-onion-services/8064 [archive]
- https://forums.whonix.org/t/onion-service-guard-protection-hslayer2nodes-hslayer3nodes/4855 [archive]
How Onion Services Connections Work
To understand how onion services work, a simple overview of the process is outlined below. 
Step 1. Onion services advertise their existence in the Tor network. This is done by randomly picking some relays and building circuits, before asking these relays to act as introduction points by providing the service's public key. The onion server's location (IP address) is shielded.
Step 2. The onion service generates an onion service descriptor containing the public key and a summary of introduction points. This is signed with its private key and then uploaded to a distributed hash table, so users can find the service when searching for a .onion resource.  This also forms an important verification mechanism for the user to confirm they are talking to the right onion service.
Step 3. The user who learnt that the .onion resource exists requests more information from the database, by downloading the descriptor from the distributed hash table. If the descriptor exists, the user now knows the introduction points and the right public key to use. The user also creates a Tor circuit to another randomly picked relay to use as a rendezvous point (with a one-time secret).
Step 4. If the descriptor is present and the rendezvous point is ready, the user assembles an "introduce message". This is encrypted to the onion service's public key and includes the rendezvous point address and the one-time secret. The user requests this be delivered to the onion service (via a Tor circuit) anonymously, so the IP address remains hidden.
Step 5. The onion service decrypts the user's introduce message and finds the rendezvous point address and one-time secret in it. The service creates a circuit to the rendezvous point and sends the one-time secret to it in a rendezvous message. The onion service must use the same set of entry guards when creating circuits, to prevent attackers from forcing onion services to use corrupt relays as an entry node (and learning the onion server's IP address via timing analysis).
Step 6. The rendezvous point notifies the user the successful connection has been established. Both the user and onion service use their circuits to the rendezvous point for communication. The rendezvous point relays end-to-end encrypted messages from user to service and vice versa.
Use of .onion addresses leads to a 6 relay arrangement: 3 picked by the user (with the third used as a rendezvous point), and 3 picked by the onion service. The final successful connection between a user and an onion service is represented in the picture below.
Figure: Alice (User) and Bob (Onion Service) Successful Connection 
Onion Services Security
Not Whonix ™ specific! Talking about Tor in general.
How safe are Tor Onion Services?
This is a difficult question. Therefore state relevant facts, quotes and links here.
Quote Roger Dingledine, an original developer of Tor, tor-talk mailing list: How easy are Tor hidden services to locate? [archive]:
Hidden services are definitely weaker than regular Tor circuits, a) because the adversary can induce them to speak, and b) because they stay at the same place over time. Mostly 'a'.
That said, there are plenty of hidden services out there, and few stories of people breaking their anonymity by breaking Tor. So they're not foolproof for sure, but they're also not trivial to deanonymize.
I'll turn it around, and ask "easy compared to what?"
When you're a Tor client, you only use the Tor network when you choose to access it (e.g. by trying to fetch a web page). So if the attacker has some attack that works only a very small percentage of time, they have to wait for you to initiate connections.
But for a hidden service, they can cause you to initiate a connection just by visiting the hidden service. And they can do it as often as they want.
And then see http://freehaven.net/anonbib/#wpes12-cogs [archive] for a more recent example. The goal of that paper is to understand how long it takes in normal operation (with entry guards going offline and being replaced) before a typical user touches an adversary-controlled guard node. For simplicity, the paper assumes that you use your guards every minute of every day for however many weeks or months it takes. A realistic user doesn't do that, so the paper overestimates the risk. But a realistic hidden service *would* do that, if the adversary caused it to.
- At time of writing there are no known attacks used in the wild constantly deanonymizing Tor onion services.
- The following is outdated since NextGenOnions [archive] (
80 bit name hash and RSA-1024 sized keys Quote Mike Perry ): http://firstname.lastname@example.org/msg05418.html [archive] Quote Mike Perry: http://email@example.com/msg05462.html [archive] Also see, The Tor Project Blog: Onion Services need some love [archive]. Non-Hidden Onion Services Considered Harmful: Attacks and Detection [archive] 
Onion Service Authentication
By default Onion Service names are known to the public as they are broadcast to Onion Service directories. This information becomes sequestered in search crawlers allowing anyone to try and connect and probe your Hidden Server even if this wasn't your intention.
To set up a Hidden service in a private mode, only accessible by just you or additionally your trusted associates, there is a little known feature in Tor feature known as Onion Services Authentication.  When activated, no one (not even the Onion Service Directories) can derive your .onion address from the descriptors nor can they know the introduction points to your server and consequently will not be able to connect to you.
This feature allows the HS operator to generate multiple shared secrets - giving access to different parties which is revocable. Configurable with the "stealth" auth type used with HiddenServiceAuthorizeClient. Meaning that clients who are banned will no longer know about the HS' introduction points anymore.
On Whonix-Gateway ™.
See the following example. Adjust it for your purposes and add it.
HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 22 127.0.0.1:22 HiddenServicePort 5900 127.0.0.1:5900 HiddenServiceVersion 3 ## syntax: ## HiddenServiceAuthorizeClient auth-type client-name,client-name,… ## The auth-type can either be 'basic' for a general-purpose authorization protocol or 'stealth' for a less scalable protocol that also hides service activity from unauthorized clients. ## Valid client names are 1 to 16 characters long and only use characters in A-Za-z0-9+-_ (no spaces). HiddenServiceAuthorizeClient stealth 1234567890123456
To get your Tor onion service url and password, run.
sudo cat /var/lib/tor/hidden_service/hostname
Should show something like this.
xxxxxxxxxxxxxxxx.onion 0123456789012345678901 # client: 1234567890123456
This is the authentication cookie that was generated by Tor that should be shared with the one supposed being allowed to connect,
- preferably face-to-face or,
- or via OpenPGP encrypted e-mail or OTR encrypted chat over Tor involving both parties.
Note that you can generate a unique authentication cookie for every individual or group you grant access to. This gives you the ability to revoke access if the need arises. It is an all or none rule for granting access to an onion service. If you want to limit that on a subdomain level you are advised to implement it by compartmentalizing your services under different onion service addresses running on a Multiple Workstation setup.
HidServAuth <onion-address> <auth-cookie>
Notes about End-to-end Security of Onion Services
Hidden services are not really "end-to-end" encrypted, they encrypted only Tor to End. (or "Tor to Tor") The communication between the browser or server and Tor is sent in clear text. This doesn't really constitute a security issue, as localhost (or Workstation to Gateway on an isolated network), is supposed to be secure. But it has some security implications:
With onion services alone, without TLS enabled, the adversary only needs to compromise Whonix-Gateway ™ to get knowledge of the content of the connection and the clients identity/location. To compromise the content of the connection, the adversary only needs to compromise either the gateway or the workstation.
With onion services, and TLS enabled, an adversary needs to compromise Whonix-Workstation ™ to gain knowledge of the content of the connection. The adversary would have to compromise Whonix-Gateway ™ as well, to gain knowledge of the client's identity/location.
It is possible to use onion services and TLS at the same time, i.e. https://****************.onion [archive]. There are only a very few onion services reachable over TLS. For example https://pad.riseup.net/ [archive] can be reached over https://5jp7xtmox6jyoqd5.onion/ [archive]. But since this only offers benefits to users of Whonix ™ (and other Tor gateway implementations), there is no demand. It would provide some nice defense in depth as it eliminates a single point of failure.
It would open the question, how would the certificate be verified?
That's simple for private sites, where server and clients know each other. They simply verify it over preshared secure channel, for example, a meeting.
And public onion services? It is unlikely, that certificate authorities will give out certificates for .onion sites. Startssl.com declined, because .onion is no .gTLD, see Bug #6116: apply for .onion gTLD at IANA [archive]. Although you could try asking other certificate authorities, if they offer SSL certificates for people who can prove that they own a .onion domain. You can prove, that you have control over the domain by editing its contents on their request.
But CAs should not be relied on anyway. See chapter SSL.
Onion Services with Whonix ™ are still safer than running Tor and the server software on the same host, because even when misconfigured, there can be, by design, no IP or DNS leaks.
- https://en.wikipedia.org/wiki/Secure_Sockets_Layer [archive]
- To be exact, only tor-to-tor, see Notes about End-to-end security of Onion Services.
- http://www.quora.com/Is-there-an-SSL-equivalent-for-Tor-Hidden-Services [archive]
- https://archive.is/Aaqsz [archive]
- https://lists.torproject.org/pipermail/tor-talk/2016-October/042360.html [archive]
- It is advised to install Template:Stable Whonix ™ based on Debian codename/libapache2-mod-removeip libapache2-mod-removeip [archive].
(Source: old forum [archive])
NameVirtualHost 127.0.0.1:80 Listen 127.0.0.1:80 ServerName localhost
Now Apache is not listening on, but only on . So now we somehow need to redirect to .
It can be done with a firewall rule or netcat:
sudo ncat -l 10.152.152.10 80 -c 'ncat 127.0.0.1 80'
- https://wiki.debian.org/WebServers [archive]
- https://mascherari.press/why-onionscan-should-worry-you/ [archive]
- https://mascherari.press/thwarting-identity-correlation-attacks/ [archive]
- https://github.com/s-rah/onionscan [archive]
- Since it is easy to know that the internal LAN IP 10.152.152.10 is usually used by Whonix-Gateway ™.
- https://github.com/camelids/ [archive]
- [https://petsymposium.org/2017/papers/issue2/paper54-2017-2-source.pdf [archive] Website Fingerprinting Defenses at the Application Layer]
- https://www.esat.kuleuven.be/cosic/?p=6743 [archive]
- https://www.torproject.org/docs/tor-manual.html.en [archive]
- https://www.torproject.org/docs/tor-manual.html.en [archive]
- https://www.torproject.org/docs/hidden-services.html.en [archive]
- This is currently a 16 character name, but will be increased to 54 characters in the near-medium term to upgrade the cryptographic strength of .onion services. See: https://blog.torproject.org/blog/cooking-onions-names-your-onions [archive]
- https://www.torproject.org/images/THS-6.png [archive]
- https://www.torproject.org/about/corepeople.html.en [archive]
- https://forums.whonix.org/t/cryptolog-for-whonix-website/3369/12 [archive]
- http://tor.stackexchange.com/questions/219/how-to-use-hidden-service-authentication [archive] How to use Onion Service Authentication?
- https://gitweb.torproject.org/torspec.git/tree/proposals/121-hidden-service-authentication.txt [archive]
This is a wiki. Want to improve this page? Help is welcome and volunteer contributions are happily considered! Read, understand and agree to Conditions for Contributions to Whonix ™, then Edit! Edits are held for moderation.
Copyright (C) 2012 - 2019 ENCRYPTED SUPPORT LP. Whonix ™ is a trademark. Whonix ™ is a licensee [archive] of the Open Invention Network [archive]. Unless otherwise noted, the content of this page is copyrighted and licensed under the same Freedom Software license as Whonix ™ itself. (Why?)