114-distributed-storage.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. Filename: 114-distributed-storage.txt
  2. Title: Distributed Storage for Tor Hidden Service Descriptors
  3. Version: $Revision$
  4. Last-Modified: $Date$
  5. Author: Karsten Loesing
  6. Created: 13-May-2007
  7. Status: Closed
  8. Change history:
  9. 13-May-2007 Initial proposal
  10. 14-May-2007 Added changes suggested by Lasse Øverlier
  11. 30-May-2007 Changed descriptor format, key length discussion, typos
  12. 09-Jul-2007 Incorporated suggestions by Roger, added status of specification
  13. and implementation for upcoming GSoC mid-term evaluation
  14. 11-Aug-2007 Updated implementation statuses, included non-consecutive
  15. replication to descriptor format
  16. 20-Aug-2007 Renamed config option HSDir as HidServDirectoryV2
  17. 02-Dec-2007 Closed proposal
  18. Overview:
  19. The basic idea of this proposal is to distribute the tasks of storing and
  20. serving hidden service descriptors from currently three authoritative
  21. directory nodes among a large subset of all onion routers. The three
  22. reasons to do this are better robustness (availability), better
  23. scalability, and improved security properties. Further,
  24. this proposal suggests changes to the hidden service descriptor format to
  25. prevent new security threats coming from decentralization and to gain even
  26. better security properties.
  27. Status:
  28. As of December 2007, the new hidden service descriptor format is implemented
  29. and usable. However, servers and clients do not yet make use of descriptor
  30. cookies, because there are open usability issues of this feature that might
  31. be resolved in proposal 121. Further, hidden service directories do not
  32. perform replication by themselves, because (unauthorized) replica fetch
  33. requests would allow any attacker to fetch all hidden service descriptors in
  34. the system. As neither issue is critical to the functioning of v2
  35. descriptors and their distribution, this proposal is considered as Closed.
  36. Motivation:
  37. The current design of hidden services exhibits the following performance and
  38. security problems:
  39. First, the three hidden service authoritative directories constitute a
  40. performance bottleneck in the system. The directory nodes are responsible for
  41. storing and serving all hidden service descriptors. As of May 2007 there are
  42. about 1000 descriptors at a time, but this number is assumed to increase in
  43. the future. Further, there is no replication protocol for descriptors between
  44. the three directory nodes, so that hidden services must ensure the
  45. availability of their descriptors by manually publishing them on all
  46. directory nodes. Whenever a fourth or fifth hidden service authoritative
  47. directory is added, hidden services will need to maintain an equally
  48. increasing number of replicas. These scalability issues have an impact on the
  49. current usage of hidden services and put an even higher burden on the
  50. development of new kinds of applications for hidden services that might
  51. require storing even more descriptors.
  52. Second, besides posing a limitation to scalability, storing all hidden
  53. service descriptors on three directory nodes also constitutes a security
  54. risk. The directory node operators could easily analyze the publish and fetch
  55. requests to derive information on service activity and usage and read the
  56. descriptor contents to determine which onion routers work as introduction
  57. points for a given hidden service and need to be attacked or threatened to
  58. shut it down. Furthermore, the contents of a hidden service descriptor offer
  59. only minimal security properties to the hidden service. Whoever gets aware of
  60. the service ID can easily find out whether the service is active at the
  61. moment and which introduction points it has. This applies to (former)
  62. clients, (former) introduction points, and of course to the directory nodes.
  63. It requires only to request the descriptor for the given service ID, which
  64. can be performed by anyone anonymously.
  65. This proposal suggests two major changes to approach the described
  66. performance and security problems:
  67. The first change affects the storage location for hidden service descriptors.
  68. Descriptors are distributed among a large subset of all onion routers instead
  69. of three fixed directory nodes. Each storing node is responsible for a subset
  70. of descriptors for a limited time only. It is not able to choose which
  71. descriptors it stores at a certain time, because this is determined by its
  72. onion ID which is hard to change frequently and in time (only routers which
  73. are stable for a given time are accepted as storing nodes). In order to
  74. resist single node failures and untrustworthy nodes, descriptors are
  75. replicated among a certain number of storing nodes. A first replication
  76. protocol makes sure that descriptors don't get lost when the node population
  77. changes; therefore, a storing node periodically requests the descriptors from
  78. its siblings. A second replication protocol distributes descriptors among
  79. non-consecutive nodes of the ID ring to prevent a group of adversaries from
  80. generating new onion keys until they have consecutive IDs to create a 'black
  81. hole' in the ring and make random services unavailable. Connections to
  82. storing nodes are established by extending existing circuits by one hop to
  83. the storing node. This also ensures that contents are encrypted. The effect
  84. of this first change is that the probability that a single node operator
  85. learns about a certain hidden service is very small and that it is very hard
  86. to track a service over time, even when it collaborates with other node
  87. operators.
  88. The second change concerns the content of hidden service descriptors.
  89. Obviously, security problems cannot be solved only by decentralizing storage;
  90. in fact, they could also get worse if done without caution. At first, a
  91. descriptor ID needs to change periodically in order to be stored on changing
  92. nodes over time. Next, the descriptor ID needs to be computable only for the
  93. service's clients, but should be unpredictable for all other nodes. Further,
  94. the storing node needs to be able to verify that the hidden service is the
  95. true originator of the descriptor with the given ID even though it is not a
  96. client. Finally, a storing node should learn as little information as
  97. necessary by storing a descriptor, because it might not be as trustworthy as
  98. a directory node; for example it does not need to know the list of
  99. introduction points. Therefore, a second key is applied that is only known to
  100. the hidden service provider and its clients and that is not included in the
  101. descriptor. It is used to calculate descriptor IDs and to encrypt the
  102. introduction points. This second key can either be given to all clients
  103. together with the hidden service ID, or to a group or a single client as
  104. an authentication token. In the future this second key could be the result of
  105. some key agreement protocol between the hidden service and one or more
  106. clients. A new text-based format is proposed for descriptors instead of an
  107. extension of the existing binary format for reasons of future extensibility.
  108. Design:
  109. The proposed design is described by the required changes to the current
  110. design. These requirements are grouped by content, rather than by affected
  111. specification documents or code files, and numbered for reference below.
  112. Hidden service clients, servers, and directories:
  113. /1/ Create routing list
  114. All participants can filter the consensus status document received from the
  115. directory authorities to one routing list containing only those servers
  116. that store and serve hidden service descriptors and which are running for
  117. at least 24 hours. A participant only trusts its own routing list and never
  118. learns about routing information from other parties.
  119. /2/ Determine responsible hidden service directory
  120. All participants can determine the hidden service directory that is
  121. responsible for storing and serving a given ID, as well as the hidden
  122. service directories that replicate its content. Every hidden service
  123. directory is responsible for the descriptor IDs in the interval from
  124. its predecessor, exclusive, to its own ID, inclusive. Further, a hidden
  125. service directory holds replicas for its n predecessors, where n denotes
  126. the number of consecutive replicas. (requires /1/)
  127. [/3/ and /4/ were requirements to use BEGIN_DIR cells for directory
  128. requests which have not been fulfilled in the course of the implementation
  129. of this proposal, but elsewhere.]
  130. Hidden service directory nodes:
  131. /5/ Advertise hidden service directory functionality
  132. Every onion router that has its directory port open can decide whether it
  133. wants to store and serve hidden service descriptors by setting a new config
  134. option "HidServDirectoryV2" 0|1 to 1. An onion router with this config
  135. option being set includes the flag "hidden-service-dir" in its router
  136. descriptors that it sends to directory authorities.
  137. /6/ Accept v2 publish requests, parse and store v2 descriptors
  138. Hidden service directory nodes accept publish requests for hidden service
  139. descriptors and store them to their local memory. (It is not necessary to
  140. make descriptors persistent, because after disconnecting, the onion router
  141. would not be accepted as storing node anyway, because it has not been
  142. running for at least 24 hours.) All requests and replies are formatted as
  143. HTTP messages. Requests are directed to the router's directory port and are
  144. contained within BEGIN_DIR cells. A hidden service directory node stores a
  145. descriptor only when it thinks that it is responsible for storing that
  146. descriptor based on its own routing table. Every hidden service directory
  147. node is responsible for the descriptor IDs in the interval of its n-th
  148. predecessor in the ID circle up to its own ID (n denotes the number of
  149. consecutive replicas). (requires /1/)
  150. /7/ Accept v2 fetch requests
  151. Same as /6/, but with fetch requests for hidden service descriptors.
  152. (requires /2/)
  153. /8/ Replicate descriptors with neighbors
  154. A hidden service directory node replicates descriptors from its two
  155. predecessors by downloading them once an hour. Further, it checks its
  156. routing table periodically for changes. Whenever it realizes that a
  157. predecessor has left the network, it establishes a connection to the new
  158. n-th predecessor and requests its stored descriptors in the interval of its
  159. (n+1)-th predecessor and the requested n-th predecessor. Whenever it
  160. realizes that a new onion router has joined with an ID higher than its
  161. former n-th predecessor, it adds it to its predecessors and discards all
  162. descriptors in the interval of its (n+1)-th and its n-th predecessor.
  163. (requires /1/)
  164. [Dec 02: This function has not been implemented, because arbitrary nodes
  165. what have been able to download the entire set of v2 descriptors. An
  166. authorized replication request would be necessary. For the moment, the
  167. system runs without any directory-side replication. -KL]
  168. Authoritative directory nodes:
  169. /9/ Confirm a router's hidden service directory functionality
  170. Directory nodes include a new flag "HSDir" for routers that decided to
  171. provide storage for hidden service descriptors and that are running for at
  172. least 24 hours. The last requirement prevents a node from frequently
  173. changing its onion key to become responsible for an identifier it wants to
  174. target.
  175. Hidden service provider:
  176. /10/ Configure v2 hidden service
  177. Each hidden service provider that has set the config option
  178. "PublishV2HidServDescriptors" 0|1 to 1 is configured to publish v2
  179. descriptors and conform to the v2 connection establishment protocol. When
  180. configuring a hidden service, a hidden service provider checks if it has
  181. already created a random secret_cookie and a hostname2 file; if not, it
  182. creates both of them. (requires /2/)
  183. /11/ Establish introduction points with fresh key
  184. If configured to publish only v2 descriptors and no v0/v1 descriptors any
  185. more, a hidden service provider that is setting up the hidden service at
  186. introduction points does not pass its own public key, but the public key
  187. of a freshly generated key pair. It also includes these fresh public keys
  188. in the hidden service descriptor together with the other introduction point
  189. information. The reason is that the introduction point does not need to and
  190. therefore should not know for which hidden service it works, so as to
  191. prevent it from tracking the hidden service's activity. (If a hidden
  192. service provider supports both, v0/v1 and v2 descriptors, v0/v1 clients
  193. rely on the fact that all introduction points accept the same public key,
  194. so that this new feature cannot be used.)
  195. /12/ Encode v2 descriptors and send v2 publish requests
  196. If configured to publish v2 descriptors, a hidden service provider
  197. publishes a new descriptor whenever its content changes or a new
  198. publication period starts for this descriptor. If the current publication
  199. period would only last for less than 60 minutes (= 2 x 30 minutes to allow
  200. the server to be 30 minutes behind and the client 30 minutes ahead), the
  201. hidden service provider publishes both a current descriptor and one for
  202. the next period. Publication is performed by sending the descriptor to all
  203. hidden service directories that are responsible for keeping replicas for
  204. the descriptor ID. This includes two non-consecutive replicas that are
  205. stored at 3 consecutive nodes each. (requires /1/ and /2/)
  206. Hidden service client:
  207. /13/ Send v2 fetch requests
  208. A hidden service client that has set the config option
  209. "FetchV2HidServDescriptors" 0|1 to 1 handles SOCKS requests for v2 onion
  210. addresses by requesting a v2 descriptor from a randomly chosen hidden
  211. service directory that is responsible for keeping replica for the
  212. descriptor ID. In total there are six replicas of which the first and the
  213. last three are stored on consecutive nodes. The probability of picking one
  214. of the three consecutive replicas is 1/6, 2/6, and 3/6 to incorporate the
  215. fact that the availability will be the highest on the node with next higher
  216. ID. A hidden service client relies on the hidden service provider to store
  217. two sets of descriptors to compensate clock skew between service and
  218. client. (requires /1/ and /2/)
  219. /14/ Process v2 fetch reply and parse v2 descriptors
  220. A hidden service client that has sent a request for a v2 descriptor can
  221. parse it and store it to the local cache of rendezvous service descriptors.
  222. /15/ Establish connection to v2 hidden service
  223. A hidden service client can establish a connection to a hidden service
  224. using a v2 descriptor. This includes using the secret cookie for decrypting
  225. the introduction points contained in the descriptor. When contacting an
  226. introduction point, the client does not use the public key of the hidden
  227. service provider, but the freshly-generated public key that is included in
  228. the hidden service descriptor. Whether or not a fresh key is used instead
  229. of the key of the hidden service depends on the available protocol versions
  230. that are included in the descriptor; by this, connection establishment is
  231. to a certain extend decoupled from fetching the descriptor.
  232. Hidden service descriptor:
  233. (Requirements concerning the descriptor format are contained in /6/ and /7/.)
  234. The new v2 hidden service descriptor format looks like this:
  235. onion-address = h(public-key) + cookie
  236. descriptor-id = h(h(public-key) + h(time-period + cookie + relica))
  237. descriptor-content = {
  238. descriptor-id,
  239. version,
  240. public-key,
  241. h(time-period + cookie + replica),
  242. timestamp,
  243. protocol-versions,
  244. { introduction-points } encrypted with cookie
  245. } signed with private-key
  246. The "descriptor-id" needs to change periodically in order for the
  247. descriptor to be stored on changing nodes over time. It may only be
  248. computable by a hidden service provider and all of his clients to prevent
  249. unauthorized nodes from tracking the service activity by periodically
  250. checking whether there is a descriptor for this service. Finally, the
  251. hidden service directory needs to be able to verify that the hidden service
  252. provider is the true originator of the descriptor with the given ID.
  253. Therefore, "descriptor-id" is derived from the "public-key" of the hidden
  254. service provider, the current "time-period" which changes every 24 hours,
  255. a secret "cookie" shared between hidden service provider and clients, and
  256. a "replica" denoting the number of this non-consecutive replica. (The
  257. "time-period" is constructed in a way that time periods do not change at
  258. the same moment for all descriptors by deriving a value between 0:00 and
  259. 23:59 hours from h(public-key) and making the descriptors of this hidden
  260. service provider expire at that time of the day.) The "descriptor-id" is
  261. defined to be 160 bits long. [extending the "descriptor-id" length
  262. suggested by LØ]
  263. Only the hidden service provider and the clients are able to generate
  264. future "descriptor-ID"s. Hence, the "onion-address" is extended from now
  265. the hash value of "public-key" by the secret "cookie". The "public-key" is
  266. determined to be 80 bits long, whereas the "cookie" is dimensioned to be
  267. 120 bits long. This makes a total of 200 bits or 40 base32 chars, which is
  268. quite a lot to handle for a human, but necessary to provide sufficient
  269. protection against an adversary from generating a key pair with same
  270. "public-key" hash or guessing the "cookie".
  271. A hidden service directory can verify that a descriptor was created by the
  272. hidden service provider by checking if the "descriptor-id" corresponds to
  273. the "public-key" and if the signature can be verified with the
  274. "public-key".
  275. The "introduction-points" that are included in the descriptor are encrypted
  276. using the same "cookie" that is shared between hidden service provider and
  277. clients. [correction to use another key than h(time-period + cookie) as
  278. encryption key for introduction points made by LØ]
  279. A new text-based format is proposed for descriptors instead of an extension
  280. of the existing binary format for reasons of future extensibility.
  281. Security implications:
  282. The security implications of the proposed changes are grouped by the roles of
  283. nodes that could perform attacks or on which attacks could be performed.
  284. Attacks by authoritative directory nodes
  285. Authoritative directory nodes are no longer the single places in the
  286. network that know about a hidden service's activity and introduction
  287. points. Thus, they cannot perform attacks using this information, e.g.
  288. track a hidden service's activity or usage pattern or attack its
  289. introduction points. Formerly, it would only require a single corrupted
  290. authoritative directory operator to perform such an attack.
  291. Attacks by hidden service directory nodes
  292. A hidden service directory node could misuse a stored descriptor to track a
  293. hidden service's activity and usage pattern by clients. Though there is no
  294. countermeasure against this kind of attack, it is very expensive to track a
  295. certain hidden service over time. An attacker would need to run a large
  296. number of stable onion routers that work as hidden service directory nodes
  297. to have a good probability to become responsible for its changing
  298. descriptor IDs. For each period, the probability is:
  299. 1-(N-c choose r)/(N choose r) for N-c>=r and 1 otherwise, with N
  300. as total
  301. number of hidden service directories, c as compromised nodes, and r as
  302. number of replicas
  303. The hidden service directory nodes could try to make a certain hidden
  304. service unavailable to its clients. Therefore, they could discard all
  305. stored descriptors for that hidden service and reply to clients that there
  306. is no descriptor for the given ID or return an old or false descriptor
  307. content. The client would detect a false descriptor, because it could not
  308. contain a correct signature. But an old content or an empty reply could
  309. confuse the client. Therefore, the countermeasure is to replicate
  310. descriptors among a small number of hidden service directories, e.g. 5.
  311. The probability of a group of collaborating nodes to make a hidden service
  312. completely unavailable is in each period:
  313. (c choose r)/(N choose r) for c>=r and N>=r, and 0 otherwise,
  314. with N as total
  315. number of hidden service directories, c as compromised nodes, and r as
  316. number of replicas
  317. A hidden service directory could try to find out which introduction points
  318. are working on behalf of a hidden service. In contrast to the previous
  319. design, this is not possible anymore, because this information is encrypted
  320. to the clients of a hidden service.
  321. Attacks on hidden service directory nodes
  322. An anonymous attacker could try to swamp a hidden service directory with
  323. false descriptors for a given descriptor ID. This is prevented by requiring
  324. that descriptors are signed.
  325. Anonymous attackers could swamp a hidden service directory with correct
  326. descriptors for non-existing hidden services. There is no countermeasure
  327. against this attack. However, the creation of valid descriptors is more
  328. expensive than verification and storage in local memory. This should make
  329. this kind of attack unattractive.
  330. Attacks by introduction points
  331. Current or former introduction points could try to gain information on the
  332. hidden service they serve. But due to the fresh key pair that is used by
  333. the hidden service, this attack is not possible anymore.
  334. Attacks by clients
  335. Current or former clients could track a hidden service's activity, attack
  336. its introduction points, or determine the responsible hidden service
  337. directory nodes and attack them. There is nothing that could prevent them
  338. from doing so, because honest clients need the full descriptor content to
  339. establish a connection to the hidden service. At the moment, the only
  340. countermeasure against dishonest clients is to change the secret cookie and
  341. pass it only to the honest clients.
  342. Compatibility:
  343. The proposed design is meant to replace the current design for hidden service
  344. descriptors and their storage in the long run.
  345. There should be a first transition phase in which both, the current design
  346. and the proposed design are served in parallel. Onion routers should start
  347. serving as hidden service directories, and hidden service providers and
  348. clients should make use of the new design if both sides support it. Hidden
  349. service providers should be allowed to publish descriptors of the current
  350. format in parallel, and authoritative directories should continue storing and
  351. serving these descriptors.
  352. After the first transition phase, hidden service providers should stop
  353. publishing descriptors on authoritative directories, and hidden service
  354. clients should not try to fetch descriptors from the authoritative
  355. directories. However, the authoritative directories should continue serving
  356. hidden service descriptors for a second transition phase. As of this point,
  357. all v2 config options should be set to a default value of 1.
  358. After the second transition phase, the authoritative directories should stop
  359. serving hidden service descriptors.