114-distributed-storage.txt 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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: Open
  8. Change history:
  9. 13-May-2007 Initial proposal
  10. 14-May-2007 Added changes suggested by Lasse Overlier
  11. 30-May-2007 Changed descriptor format, key length discussion, typos
  12. Overview:
  13. The basic idea of this proposal is to distribute the tasks of storing and
  14. serving hidden service descriptors from currently three authoritative
  15. directory nodes among a large subset of all onion routers. The two reasons
  16. to do this are better scalability and improved security properties. Further,
  17. this proposal suggests changes to the hidden service descriptor format to
  18. prevent new security threats coming from decentralization and to gain
  19. even better security properties.
  20. Motivation:
  21. The current design of hidden services exhibits the following performance and
  22. security problems:
  23. First, the three hidden service authoritative directories constitute a
  24. performance bottleneck in the system. The directory nodes are responsible
  25. for storing and serving all hidden service descriptors. At the moment there
  26. are about 1000 descriptors at a time, but this number is assumed to increase
  27. in the future. Further, there is no replication protocol for descriptors
  28. between the three directory nodes, so that hidden services must ensure the
  29. availability of their descriptors by manually publishing them on all
  30. directory nodes. Whenever a fourth or fifth hidden service authoritative
  31. directory is added, hidden services will need to maintain an equally
  32. increasing number of replicas. These scalability issues have an impact on
  33. the current usage of hidden services and put an even higher burden on the
  34. development of new kinds of applications for hidden services that might
  35. require storing even bigger numbers of descriptors.
  36. Second, besides posing a limitation to scalability, storing all hidden
  37. service descriptors on three directory nodes also constitutes a security
  38. risk. The directory node operators could easily analyze the publish and fetch
  39. requests to derive information on service activity and usage and read the
  40. descriptor contents to determine which onion routers work as introduction
  41. points for a given hidden service and need to be attacked or threatened to
  42. shut it down. Furthermore, the contents of a hidden service descriptor offer
  43. only minimal security properties to the hidden service. Whoever gets aware
  44. of the service ID can easily find out whether the service is active at the
  45. moment and which introduction points it has. This applies to (former)
  46. clients, (former) introduction points, and of course to the directory nodes.
  47. It requires only to request the descriptor for the given service ID --- which
  48. can be performed by anyone anonymously.
  49. This proposal suggests two major changes to approach the described
  50. performance and security problems:
  51. The first change affects the storage location for hidden service
  52. descriptors. Descriptors are distributed among a large subset of all onion
  53. routers instead of three fixed directory nodes. Each storing node is
  54. responsible for a subset of descriptors for a limited time only. It is not
  55. able to choose which descriptors it stores at a certain time, because this
  56. is determined by its onion ID which is hard to change frequently and in time
  57. (only routers which are stable for a given time are accepted as storing
  58. nodes). In order to resist single node failures and untrustworthy nodes,
  59. descriptors are replicated among a certain number of storing nodes. A simple
  60. replication protocol makes sure that descriptors don't get lost when the
  61. node population changes. Therefore, a storing node periodically requests the
  62. descriptors from its siblings. Connections to storing nodes are established
  63. by extending existing circuits by one hop to the storing node. This also
  64. ensures that contents are encrypted. The effect of this first change is that
  65. the probability that a single node operator learns about a certain hidden
  66. service is very small and that it is very hard to track a service over time,
  67. even when it collaborates with other node operators.
  68. The second change concerns the content of hidden service descriptors.
  69. Obviously, security problems cannot be solved only by decentralizing
  70. storage; in fact, they could also get worse if done without caution. At
  71. first, a descriptor ID needs to change periodically in order to be stored on
  72. changing nodes over time. Next, the descriptor ID needs to be computable only
  73. for the service's clients, but should be unpredictable for all other nodes.
  74. Further, the storing node needs to be able to verify that the hidden service
  75. is the true originator of the descriptor with the given ID even though it is
  76. not a client. Finally, a storing node should learn as little information as
  77. necessary by storing a descriptor, because it might not be as trustworthy as
  78. a directory node; for example it does not need to know the list of
  79. introduction points. Therefore, a second key is applied that is only known
  80. to the hidden service provider and its clients and that is not included in
  81. the descriptor. It is used to calculate descriptor IDs and to encrypt the
  82. introduction points. This second key can either be given to all clients
  83. together with the hidden service ID, or to a group or a single client as
  84. authentication token. In the future this second key could be the result of
  85. some key agreement protocol between the hidden service and one or more
  86. clients. A new text-based format is proposed for descriptors instead of an
  87. extension of the existing binary format for reasons of future extensibility.
  88. Design:
  89. The proposed design is described by the changes that are necessary to the
  90. current design. Changes are grouped by content, rather than by affected
  91. specification documents.
  92. Tor clients and servers:
  93. All participants can combine the network status lists received from
  94. all directory authorities to one routing list containing only those
  95. servers that store and serve hidden service descriptors and which
  96. are contained in the majority of network status lists. A participant
  97. only trusts its own routing list and never learns about routing
  98. information from other parties. This list should only be created
  99. on demand by Tor clients and servers that are involved in the new
  100. hidden service protocol, i.e. hidden service directory node, hidden
  101. service provider, and hidden service client.
  102. All parties that are involved in the new hidden service protocol calculate
  103. the clock skew between their local time and the times of directory
  104. authorities. If the clock skew exceeds 1 minute (as opposed to 30 minutes
  105. as in the current implementation), the user is warned upon performing the
  106. first operation that is related to hidden services. However, the local
  107. time is not adjusted automatically, because then they would be open
  108. to attacks based on false times from directory authorities.
  109. Hidden service directory nodes:
  110. Every onion router can decide whether it wants to store and serve hidden
  111. service descriptors by setting a new config option HiddenServiceDirectory
  112. 0|1 to 1. This option should be 1 by default for those onion routers that
  113. have their directory port open, because the smaller the group of storing
  114. nodes is, the poorer the security properties are.
  115. HS directory nodes include the fact that they store and serve hidden
  116. service descriptors in router descriptors that they send to directory
  117. authorities.
  118. HS directory nodes accept publish and fetch requests for hidden service
  119. descriptors and store/retrieve them to/from their local memory. (It is not
  120. necessary to make descriptors persistent, because after disconnecting, the
  121. onion router would not be accepted as storing node anyway, because it is
  122. not stable.) All requests and replies are formatted as HTTP messages.
  123. Requests are directed to the router's directory port and are contained
  124. within BEGIN_DIR cells. A HS directory node stores a descriptor only when
  125. it thinks that it is responsible for storing that descriptor based on its
  126. own routing table. Every HS directory node is responsible for the
  127. descriptor IDs in the interval of its n-th predecessor in the ID circle up
  128. to its own ID (n denotes the number of replicas).
  129. A HS directory node replicates descriptors for which it is responsible by
  130. downloading them from other HS directory nodes. Therefore, it checks its
  131. routing table periodically every 10 minutes for changes. Whenever it
  132. realizes that a predecessor has left the network, it establishes a
  133. connection to the new n-th predecessor and requests its stored descriptors
  134. in the interval of its (n+1)-th predecessor and the requested n-th
  135. predecessor. Whenever it realizes that a new onion router has joined with
  136. an ID higher than its former n-th predecessor, it adds it to its
  137. predecessors and discards all descriptors in the interval of its (n+1)-th
  138. and its n-th predecessor.
  139. Authoritative directory nodes:
  140. Directory nodes include a new flag for routers that decided to provide
  141. storage for hidden service descriptors and that are stable for a given
  142. time. The requirement to be stable prevents a node from frequently
  143. changing its onion key to become responsible for an identifier it wants
  144. to target.
  145. Hidden service provider:
  146. When setting up the hidden service at introduction points, a hidden service
  147. provider does not pass its own public key, but the public key of a freshly
  148. generated key pair. It also includes this public key in the hidden service
  149. descriptor together with the other introduction point information. The
  150. reason is that the introduction point does not need to know for which
  151. hidden service it works, and should not know it to prevent it from
  152. tracking the hidden service's activity.
  153. Each hidden service provider publishes a new descriptor whenever
  154. its content
  155. changes or a new publication period starts for this descriptor. If the
  156. current publication period would only last for less than 60 minutes, the
  157. hidden service provider publishes both a current descriptor and one for
  158. the next period. Publication is performed by sending the descriptor to all
  159. hidden service directories that are responsible for keeping replicas for
  160. the descriptor ID.
  161. Hidden service client:
  162. Instead of downloading descriptors from a hidden service authoritative
  163. directory, a hidden service client downloads it from a randomly chosen
  164. hidden service directory that is responsible for keeping replica for the
  165. descriptor ID.
  166. When contacting an introduction point, the client does not use the
  167. public key of the hidden service provider, but the freshly-generated public
  168. key that is included in the hidden service descriptor.
  169. Hidden service descriptor:
  170. The descriptor ID needs to change periodically in order for the descriptor
  171. to be stored on changing nodes over time. It further may only be computable
  172. by a hidden service provider and all of his clients to prevent unauthorized
  173. nodes from tracking the service activity by periodically checking whether
  174. there is a descriptor for this service. Finally, the hidden service
  175. directory needs to be able to verify that the hidden service provider is
  176. the true originator of the descriptor with the given ID. Therefore, the
  177. ID is derived from the public key of the hidden service provider, the
  178. current time period, and a shared secret between hidden service provider
  179. and clients. Only the hidden service provider and the clients are able to
  180. generate future IDs, but together with the descriptor content the hidden
  181. service directory is able to verify its origin. The formula for calculating
  182. a descriptor ID is as follows:
  183. descriptor-id = h(permanent-id + h(time-period + cookie))
  184. "permanent-id" is the hashed value of the public key of the hidden service
  185. provider, "time-period" is a periodically changing value, e.g. the current
  186. date, and "cookie" is a shared secret between the hidden service provider
  187. and its clients. (The "time-period" should be constructed in a way that
  188. periods do not change at the same moment for all descriptors by including
  189. the "permanent-id" in the construction.) Amongst other things, the
  190. descriptor contains the public key of the hidden service provider, the
  191. value of h(time-period + cookie), and the signature of the descriptor
  192. content with the private key of the hidden service provider.
  193. The introduction points that are included in the descriptor are encrypted
  194. using a key that is derived from the same shared key that is used to
  195. generate the descriptor ID. [correction to use another key than
  196. h(time-period + cookie) as encryption key for introduction points made by
  197. LO]
  198. A new text-based format is proposed for descriptors instead of an
  199. extension of the existing binary format for reasons of future
  200. extensibility.
  201. The complete hidden service descriptor format looks like this:
  202. {
  203. descriptor-id = h(permanent-id + h(time-period + cookie))
  204. permanent-public-key (with permanent-id = h(permanent-public-key))
  205. h(time-period + cookie)
  206. timestamp
  207. {
  208. list of intro points (ID, IP, onion port, onion key, service key)
  209. } encrypted with cookie
  210. } signed with permanent-private-key
  211. A hidden service directory can verify that a descriptor was created by the
  212. hidden service provider by checking if the descriptor-id corresponds to
  213. the permanent-public-key and if the signature can be verified with the
  214. permanent-public-key.
  215. A client can download the descriptor by creating the same descriptor-id
  216. and verify its origin by performing the same operations as the hidden
  217. service directory.
  218. Security implications:
  219. The security implications of the proposed changes are grouped by the roles
  220. of nodes that could perform attacks or on which attacks could be performed.
  221. Attacks by authoritative directory nodes
  222. Authoritative directory nodes are not anymore the single places in the
  223. network that know about a hidden service's activity and introduction
  224. points. Thus, they cannot perform attacks using this information, e.g.
  225. track a hidden service's activity or usage pattern or attack its
  226. introduction points. Formerly, it would only require a single corrupted
  227. authoritative directory operator to perform such an attack.
  228. Attacks by hidden service directory nodes
  229. A hidden service directory node could misuse a stored descriptor to track
  230. a hidden service's activity and usage pattern by clients. Though there is
  231. no countermeasure against this kind of attack, it is very expensive to
  232. track a certain hidden service over time. An attacker would need to run a
  233. large number of stable onion routers that work as hidden service directory
  234. nodes to have a good probability to become responsible for its changing
  235. descriptor IDs. For each period, the probability is:
  236. 1-(N-c choose r)/(N choose r) for N-c>=r and 1 else with N as total
  237. number of hidden service directories, c as compromised nodes, and r as
  238. number of replicas
  239. The hidden service directory nodes could try to make a certain hidden
  240. service unavailable to its clients. Therefore, they could discard all
  241. stored descriptors for that hidden service and reply to clients that there
  242. is no descriptor for the given ID or return an old or false descriptor
  243. content. The client would detect a false descriptor, because it could not
  244. contain a correct signature. But an old content or an empty reply could
  245. confuse the client. Therefore, the countermeasure is to replicate
  246. descriptors among a small number of hidden service directories, e.g. 5.
  247. The probability of a group of collaborating nodes to make a hidden service
  248. completely unavailable is in each period:
  249. (c choose r)/(N choose r) for c>=r and N>=r, and 0 else with N as total
  250. number of hidden service directories, c as compromised nodes, and r as
  251. number of replicas
  252. A hidden service directory could try to find out which introduction points
  253. are working on behalf of a hidden service. In contrast to the previous
  254. design, this is not possible anymore, because this information is encrypted
  255. to the clients of a hidden service.
  256. Attacks on hidden service directory nodes
  257. An anonymous attacker could try to swamp a hidden service directory with
  258. false descriptors for a given descriptor ID. This is prevented by requiring
  259. that descriptors are signed.
  260. Anonymous attackers could swamp a hidden service directory with correct
  261. descriptors for non-existing hidden services. There is no countermeasure
  262. against this attack. However, the creation of valid descriptors is more
  263. expensive than verification and storage in local memory. This should make
  264. this kind of attack unattractive.
  265. Attacks by introduction points
  266. Current or former introduction points could try to gain information on the
  267. hidden service they serve. But due to the fresh key pair that is used by
  268. the hidden service, this attack is not possible anymore.
  269. Attacks by clients
  270. Current or former clients could track a hidden service's activity, attack
  271. its introduction points, or determine the responsible hidden service
  272. directory nodes and attack them. There is nothing that could prevent them
  273. from doing so, because honest clients need the full descriptor content to
  274. establish a connection to the hidden service. At the moment, the only
  275. countermeasure against dishonest clients is to change the secret cookie
  276. and pass it only to the honest clients.
  277. Specification:
  278. The proposed changes affect multiple sections in several specification
  279. documents that are only mentioned in the following. The detailed
  280. specification will follow as soon as the design decisions above are final.
  281. dir-spec-v2.txt
  282. 2.1 The router descriptor format needs to include an additional flag to
  283. denote that a router is a hidden service directory.
  284. 3 The network status format needs to be extended by a new status flag to
  285. denote that a router is a hidden service directory.
  286. 4 The sections on directory caches need to be extended by new sections for
  287. the operation of hidden service directories, including replication of
  288. descriptors.
  289. rend-spec.txt
  290. 1.2 The new descriptor format needs to be added.
  291. 1.3 Instead of Bob's public key, the hidden service provider uses a
  292. freshly generated public key for every introduction point.
  293. 1.4 Bob's OP does not upload his service descriptor to the authoritative
  294. directories, but to the hidden service directories.
  295. 1.6 Alice's OP downloads the service descriptors similarly as Bob
  296. published them in 1.4.
  297. 1.8 Alice uses the public key that is included in the descriptor instead
  298. of Bob's permanent service key.
  299. tor-spec.txt
  300. 6.2.1 Directory streams need to be used for connections to hidden service
  301. directories.
  302. Compatibility:
  303. The proposed design is meant to replace the current design for hidden service
  304. descriptors and their storage in the long run.
  305. There should be a first transition phase in which both, the current design
  306. and the proposed design are served in parallel. Onion routers should start
  307. serving as hidden service directories, and hidden service providers and
  308. clients should make use of the new design if both sides support it. But
  309. hidden service providers should continue publishing descriptors of the
  310. current format, and authoritative directories should store and serve these
  311. descriptors.
  312. After the first transition phase, hidden service providers should stop
  313. publishing descriptors on authoritative directories, and hidden service
  314. clients should not try to fetch descriptors from the authoritative
  315. directories. However, the authoritative directories should continue serving
  316. hidden service descriptors for a second transition phase.
  317. After the second transition phase, the authoritative directories should stop
  318. serving hidden service descriptors.
  319. Implementation:
  320. There are three key lengths that might need some discussion:
  321. 1) descriptor-id, formerly known as onion address: It is generated by OPs
  322. internally and used for storing and looking up descriptors. There is no
  323. need to remember a descriptor-id for a human. In order to reduce
  324. the success rate of collisions it could be extended to the full output
  325. of SHA-1 of 160 bits instead of 80 bits. [extending the descriptor-id
  326. length suggested by LO]
  327. 2) permanent-id: This is the first part of the onion address that a client
  328. passes to his OP. The overall onion address should be easy to memorize.
  329. Therefore, its overall length should only be extended from the existing
  330. 80 bits to as few bits as necessary. The length of the permanent-id has
  331. an influence on the probability that an adversary creates an own key
  332. pair that leads to the same descriptor-id in a given time-period as an
  333. honest service's key. 32 bits should provide sufficient protection to
  334. avoid collisions, given the fact that key generation is expensive and
  335. the attack needed to be performed for every time-period.
  336. 3) cookie: This is the second part of the onion address that is passed to
  337. an OP. In order to provide confidentiality of introduction points, this
  338. secret key should have 128 bits. In total, this leads to an onion
  339. address of 160 bits instead of the current 80 bits.