Hello everyone.To begin with i write a Server in Java (or maybe i will use an an existing more efficient you know), to serve a Hidden Service. With a few words i configure it so that it will accept TCP connections with a serverSocket only from localhost/ on a port of my choosing. Below follows my setup of torcc file.

HiddenServicePort 9053
PidFile pid
RunAsDaemon 1
SafeSocks 1
SocksPort 9020

My question now is and correct me if I'm wrong The HiddenServicePort directive tells tor on which port to listen, to forward to which ip and to which port and after that i go and bind a serversocket in that local port and i am waiting for connections. How secure is this? Do i need to establish an ssl in the local ServerSocket to make it more legit.

1 Answer 1


You need before the HiddenServicePort line(s) a line HiddenServiceDir /full/path/to/hs/dir. The suggestion is right, it's basically "HiddenServicePort [port-to-listen-on] -> [ip-to-forward-the-request-to]:[port-to-forward-the-request-to]". For localhost it's normal just to have a socket binded tightly to exactly the TCP pair "[ip-to-forward-the-request-to]:[port-to-forward-the-request-to]". If someone owns your box - there's no way to make it more secure on localhost. If you want to make it some sort of additional security layer - use iptables ability to restrict the usernames for port rules, but it's only until root/sudoer account is breached

  • of course i have HiddenServiceDir included but i forgot to mention here. What about ssl option? I mean for example If someone owns my box he will not be able to understand that theese packets have relationship with Tor and it will be a classic ssl connection localhost. Do i right? Sep 27, 2017 at 9:26
  • Not exactly... If someone owned the box, then it can become a root in one or another way. So to read Tor config means no problem for him
    – Alexey Vesnin
    Sep 27, 2017 at 14:28
  • Maybe you misunderstand something. Imagine tha someone not owned the box but it perfoms a Man in the middle attack and he watch the traffic is it possible to from him to understand that in the local serversocket port there is tor traffic if ssl not enabled on it? Sep 28, 2017 at 9:47
  • No, if box is not pwned - you are safe. The hidden services and clients both are using 3 hop circuits to the rendezvous points. So the connection is 3-layer secured on both sides, and man in the middle attack will give the attacker just the same "I have no clue" situation
    – Alexey Vesnin
    Sep 28, 2017 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .