114-distributed-storage.txt 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  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. 09-Jul-2007 Incorporated suggestions by Roger, added status of specification
  13. and implementation for upcoming GSoC mid-term evaluation
  14. Overview:
  15. The basic idea of this proposal is to distribute the tasks of storing and
  16. serving hidden service descriptors from currently three authoritative
  17. directory nodes among a large subset of all onion routers. The two reasons to
  18. do this are better scalability and improved security properties. Further,
  19. this proposal suggests changes to the hidden service descriptor format to
  20. prevent new security threats coming from decentralization and to gain even
  21. better security properties.
  22. Motivation:
  23. The current design of hidden services exhibits the following performance and
  24. security problems:
  25. First, the three hidden service authoritative directories constitute a
  26. performance bottleneck in the system. The directory nodes are responsible for
  27. storing and serving all hidden service descriptors. At the moment there are
  28. about 1000 descriptors at a time, but this number is assumed to increase in
  29. the future. Further, there is no replication protocol for descriptors between
  30. the three directory nodes, so that hidden services must ensure the
  31. availability of their descriptors by manually publishing them on all
  32. directory nodes. Whenever a fourth or fifth hidden service authoritative
  33. directory is added, hidden services will need to maintain an equally
  34. increasing number of replicas. These scalability issues have an impact on the
  35. current usage of hidden services and put an even higher burden on the
  36. development of new kinds of applications for hidden services that might
  37. require storing even bigger numbers of descriptors.
  38. Second, besides posing a limitation to scalability, storing all hidden
  39. service descriptors on three directory nodes also constitutes a security
  40. risk. The directory node operators could easily analyze the publish and fetch
  41. requests to derive information on service activity and usage and read the
  42. descriptor contents to determine which onion routers work as introduction
  43. points for a given hidden service and need to be attacked or threatened to
  44. shut it down. Furthermore, the contents of a hidden service descriptor offer
  45. only minimal security properties to the hidden service. Whoever gets aware of
  46. the service ID can easily find out whether the service is active at the
  47. moment and which introduction points it has. This applies to (former)
  48. clients, (former) introduction points, and of course to the directory nodes.
  49. It requires only to request the descriptor for the given service ID, which
  50. can be performed by anyone anonymously.
  51. This proposal suggests two major changes to approach the described
  52. performance and security problems:
  53. The first change affects the storage location for hidden service descriptors.
  54. Descriptors are distributed among a large subset of all onion routers instead
  55. of three fixed directory nodes. Each storing node is responsible for a subset
  56. of descriptors for a limited time only. It is not able to choose which
  57. descriptors it stores at a certain time, because this is determined by its
  58. onion ID which is hard to change frequently and in time (only routers which
  59. are stable for a given time are accepted as storing nodes). In order to
  60. resist single node failures and untrustworthy nodes, descriptors are
  61. replicated among a certain number of storing nodes. A first replication
  62. protocol makes sure that descriptors don't get lost when the node population
  63. changes; therefore, a storing node periodically requests the descriptors from
  64. its siblings. A second replication protocol distributes descriptors among
  65. non-consecutive nodes of the ID ring to prevent a group of adversaries from
  66. generating new onion keys until they have consecutive IDs to create a 'black
  67. hole' in the ring and make random services unavailable. Connections to
  68. storing nodes are established by extending existing circuits by one hop to
  69. the storing node. This also ensures that contents are encrypted. The effect
  70. of this first change is that the probability that a single node operator
  71. learns about a certain hidden service is very small and that it is very hard
  72. to track a service over time, even when it collaborates with other node
  73. operators.
  74. The second change concerns the content of hidden service descriptors.
  75. Obviously, security problems cannot be solved only by decentralizing storage;
  76. in fact, they could also get worse if done without caution. At first, a
  77. descriptor ID needs to change periodically in order to be stored on changing
  78. nodes over time. Next, the descriptor ID needs to be computable only for the
  79. service's clients, but should be unpredictable for all other nodes. Further,
  80. the storing node needs to be able to verify that the hidden service is the
  81. true originator of the descriptor with the given ID even though it is not a
  82. client. Finally, a storing node should learn as little information as
  83. necessary by storing a descriptor, because it might not be as trustworthy as
  84. a directory node; for example it does not need to know the list of
  85. introduction points. Therefore, a second key is applied that is only known to
  86. the hidden service provider and its clients and that is not included in the
  87. descriptor. It is used to calculate descriptor IDs and to encrypt the
  88. introduction points. This second key can either be given to all clients
  89. together with the hidden service ID, or to a group or a single client as
  90. authentication token. In the future this second key could be the result of
  91. some key agreement protocol between the hidden service and one or more
  92. clients. A new text-based format is proposed for descriptors instead of an
  93. extension of the existing binary format for reasons of future extensibility.
  94. Design:
  95. The proposed design is described by the required changes to the current
  96. design. These requirements are grouped by content, rather than by affected
  97. specification documents or code files, and numbered for reference below.
  98. Hidden service clients, servers, and directories:
  99. /1/ Create routing list
  100. All participants can filter the consensus status document received from the
  101. directory authorities to one routing list containing only those servers
  102. that store and serve hidden service descriptors and which are running for
  103. at least 24 hours. A participant only trusts its own routing list and never
  104. learns about routing information from other parties.
  105. - rend-spec.txt, section 1.4: Added description of how to obtain a routing
  106. list of hidden service directories.
  107. - routerparse.c: Changed routerstatus_parse_entry_from_string to parse the
  108. "HSDir" flag in vote and consensus status documents.
  109. - routerlist.c: Changed router_get_routerlist() to initialize routing list.
  110. - or.h: Added hs_dirs member to routerlist_t.
  111. [July 9: Specified and running, though the routing list is compiled for
  112. each request anew.]
  113. /2/ Determine responsible hidden service directory
  114. All participants can determine the hidden service directory that is
  115. responsible for storing and serving a given ID, as well as the hidden
  116. service directories that replicate its content. Every hidden service
  117. directory is responsible for the descriptor IDs in the interval from
  118. its predecessor, exclusive, to its own ID, inclusive. Further, a hidden
  119. service directory holds replicas for its n predecessors, where n denotes
  120. the number of consecutive replicas. (requires /1/)
  121. - rend-spec.txt, section 1.4: Added description of how to determine the
  122. responsible node(s) for a given descriptor ID.
  123. - routerlist.c: Added get_responsible_hs_dir() to determine the router that
  124. is responsible for a given descriptor ID.
  125. - container.h: Added prototype for smartlist_digest_next_circular().
  126. - container.c: Added implementation for smartlist_digest_next_circular().
  127. [July 9: Specified and running.]
  128. Hidden service clients and providers:
  129. /3/ Send tunneled HTTP request to hidden service directory in BEGIN_DIR cell
  130. - rend-spec.txt, section 1.4: Added the requirement that requests need to
  131. be sent via Tor.
  132. - rend-spec.txt, section 1.6: Added the requirement that requests need to
  133. be sent via Tor.
  134. [July 9: Pending]
  135. Hidden service directory nodes:
  136. /4/ Process tunneled HTTP request in BEGIN_DIR cell
  137. - rend-spec.txt, section 3.2: Added the requirement that requests need to
  138. be contained within BEGIN_DIR cells.
  139. - rend-spec.txt, section 3.3: Added the requirement that requests need to
  140. be contained within BEGIN_DIR cells.
  141. [July 9: Pending]
  142. /5/ Advertise hidden service directory functionality
  143. Every onion router that has its directory port open can decide whether it
  144. wants to store and serve hidden service descriptors by setting a new config
  145. option "HSDir" 0|1 to 1. An onion router with this config option being set
  146. includes the flag "hidden-service-dir" in its router descriptors that it
  147. sends to directory authorities.
  148. - tor.1.in: Added the config option HSDir.
  149. - dir-spec.txt, section 2.1: Added the flag hidden-service-dir to the
  150. router descriptor format.
  151. - rend-spec.txt, section 3.1: Added process of configuring a hidden service
  152. directory.
  153. - router.c: Changed router_dump_router_to_string() to include the
  154. hidden-service-dir flag in a router descriptor if configured.
  155. - or.h: Added HSDir to or_options_t.
  156. - config.c: Added config option HSDir.
  157. [July 9: Specified and running.]
  158. /6/ Accept v2 publish requests, parse and store v2 descriptors
  159. Hidden service directory nodes accept publish requests for hidden service
  160. descriptors and store them to their local memory. (It is not necessary to
  161. make descriptors persistent, because after disconnecting, the onion router
  162. would not be accepted as storing node anyway, because it has not been
  163. running for at least 24 hours.) All requests and replies are formatted as
  164. HTTP messages. Requests are directed to the router's directory port and are
  165. contained within BEGIN_DIR cells. A hidden service directory node stores a
  166. descriptor only when it thinks that it is responsible for storing that
  167. descriptor based on its own routing table. Every hidden service directory
  168. node is responsible for the descriptor IDs in the interval of its n-th
  169. predecessor in the ID circle up to its own ID (n denotes the number of
  170. consecutive replicas). (requires /1/ and /4/)
  171. - rend-spec.txt, section 1.2: Added the new v2 hidden service descriptor
  172. format.
  173. - rend-spec.txt, section 3.2: Added the acceptance of v2 publish requests.
  174. - routerparse.c: Added rend_parse_v2_service_descriptor() to parse a v2
  175. hidden service descriptor.
  176. - routerparse.c: Added desc_token_table[] to parse v2 hidden service
  177. descriptors.
  178. - routerparse.c: Added 8 keywords to directory_keyword to parse v2 hidden
  179. service descriptors.
  180. - rendcommon.c: Added rend_cache_store_v2_dir() to allow a hidden service
  181. directory to store a v2 descriptor in the local cache under its
  182. descriptor ID instead of its service ID.
  183. - rendcommon.c: Moved the parsing part from rend_cache_store() to the new
  184. function rend_cache_store_parse() to reuse it for v2 descriptors.
  185. - or.h: Added constant REND_DESC_ID_V2_LEN to reflect that v2 descriptor
  186. IDs are longer than v0/1 onion addresses.
  187. [July 9: Base version specified and running; no checking of published
  188. descriptors, tunneling over BEGIN_DIR cells not yet implemented.]
  189. /7/ Accept v2 fetch requests
  190. Same as /6/, but with fetch requests for hidden service descriptors.
  191. (requires /4/)
  192. - rend-spec.txt, section 3.3: Added the processing of v2 fetch requests.
  193. - rendcommon.c: Added rend_cache_lookup_v2_dir() to allow a hidden service
  194. directory to look up a v2 descriptor in the local cache under its
  195. descriptor ID instead of its service ID.
  196. - or.h: Added constant REND_DESC_ID_V2_LEN to reflect that v2 descriptor
  197. IDs are longer than v0/1 onion addresses.
  198. [July 9: Base version specified and running; tunneling over BEGIN_DIR
  199. cells not yet implemented.]
  200. /8/ Replicate descriptors with neighbors
  201. A hidden service directory node replicates descriptors from its two
  202. predecessors by downloading them once an hour. Further, it checks its
  203. routing table periodically for changes. Whenever it realizes that a
  204. predecessor has left the network, it establishes a connection to the new
  205. n-th predecessor and requests its stored descriptors in the interval of its
  206. (n+1)-th predecessor and the requested n-th predecessor. Whenever it
  207. realizes that a new onion router has joined with an ID higher than its
  208. former n-th predecessor, it adds it to its predecessors and discards all
  209. descriptors in the interval of its (n+1)-th and its n-th predecessor.
  210. (requires /1/)
  211. - rend-spec.txt, section 3.3: Added the replication of v2 descriptors.
  212. [July 9: To some extend specified, but not yet implemented.]
  213. Authoritative directory nodes:
  214. /9/ Confirm a router's hidden service directory functionality
  215. Directory nodes include a new flag "HSDir" for routers that decided to
  216. provide storage for hidden service descriptors and that are running for at
  217. least 24 hours. The last requirement prevents a node from frequently
  218. changing its onion key to become responsible for an identifier it wants to
  219. target.
  220. - dir-spec.txt, section 3.2: Added the status flag "HSDir" to the vote and
  221. consensus status document format.
  222. - dir-spec.txt, section 3.3: Added a rule for how an authority decides
  223. whether a router is assigned the flag "HSDir".
  224. - rend-spec.txt, section 3.1: Added the decision on whether an onion router
  225. is confirmed to act as hidden service directory or not.
  226. - routerparse.c: Changed router_parse_entry_from_string() to parse the
  227. "hidden-service-dir" flag in router descriptors.
  228. - routerparse.c: Added an entry to routerdesc_token_table[] to parse the
  229. "hidden-service-directory" flag in router descriptors.
  230. - routerparse.c: Added 1 keyword to directory_keyword to parse the
  231. "hidden-service-dir" flag in router descriptors.
  232. - or.h: Added is_hs_dir member to routerinfo_t and to routerstatus_t.
  233. - dirserv.c: Changed routerstatus_format_entry() to include the "HSDir"
  234. flag in vote and consensus status documents.
  235. - dirserv.c: Changed set_routerstatus_from_routerinfo() to set the "HSDir"
  236. flag.
  237. [July 9: Base version specified and running in which all nodes that have
  238. the hidden-service-dir flag set in their router descriptor get the
  239. HSDir flag, not only those which are running for at least 24 hours.]
  240. Hidden service provider:
  241. /10/ Configure v2 hidden service
  242. Each hidden service provider that has set the config option
  243. "PublishV2HidServDescriptors" 0|1 to 1 is configured to publish v2
  244. descriptors and conform to the v2 connection establishment protocol. When
  245. configuring a hidden service, a hidden service provider checks if it has
  246. already created a random secret_cookie and a hostname2 file; if not, it
  247. creates both of them. (requires /2/)
  248. - tor.1.in: Added the config option PublishV2HidServDescriptors.
  249. - tor.1.in: Added the files hostname2 and secret_cookie.
  250. - rend-spec.txt, section 1.1: Added requirement to create secret_cookie and
  251. hostname2 file.
  252. - rendservice.c: Added rend_get_hostname2() to assemble a v2 onion address.
  253. - rendservice.c: Changed rend_service_load_keys() to write a secret_cookie
  254. and a hostname2 file.
  255. - rendservice.c: Extended rend_service_t by a member secret_cookie.
  256. - or.h: Added PublishV2HidServDescriptors to or_options_t.
  257. - config.c: Added config option PublishV2HidServDescriptors.
  258. [July 9: Specified and running.]
  259. /11/ Establish introduction points with fresh key
  260. If configured to publish only v2 descriptors and no v0/v1 descriptors any
  261. more, a hidden service provider that is setting up the hidden service at
  262. introduction points does not pass its own public key, but the public key
  263. of a freshly generated key pair. It also includes these fresh public keys
  264. in the hidden service descriptor together with the other introduction point
  265. information. The reason is that the introduction point does not need to and
  266. therefore should not know for which hidden service it works, so as to
  267. prevent it from tracking the hidden service's activity. (If a hidden
  268. service provider supports both, v0/v1 and v2 descriptors, v0/v1 clients
  269. rely on the fact that all introduction points accept the same public key,
  270. so that this new feature cannot be used.)
  271. - rend-spec.txt, section 1.3: Instead of Bob's public key, the hidden
  272. service provider uses a freshly generated public key for every
  273. introduction point.
  274. [July 9: Specified, but not yet implemented.]
  275. /12/ Encode v2 descriptors and send v2 publish requests
  276. If configured to publish v2 descriptors, a hidden service provider
  277. publishes a new descriptor whenever its content changes or a new
  278. publication period starts for this descriptor. If the current publication
  279. period would only last for less than 60 minutes (= 2 x 30 minutes to allow
  280. the server to be 30 minutes behind and the client 30 minutes ahead), the
  281. hidden service provider publishes both a current descriptor and one for
  282. the next period. Publication is performed by sending the descriptor to all
  283. hidden service directories that are responsible for keeping replicas for
  284. the descriptor ID. This includes two non-consecutive replicas that are
  285. stored at 3 consecutive nodes each. (requires /1/ and /3/)
  286. - rend-spec.txt, section 1.2: Added the new v2 hidden service descriptor
  287. format.
  288. - rend-spec.txt, section 1.4: Bob's OP does not only upload v0/v1 service
  289. descriptors to the authoritative directories, but also v2 service
  290. descriptors to the hidden service directories.
  291. - rendservice.c: Changed upload_service_descriptor() to upload v2 hidden
  292. service descriptors, if configured.
  293. - rendservice.c: Changed rend_consider_services_upload() to also initiate
  294. the upload of v2 descriptors, if configured.
  295. - rendservice.c: Extended rend_service_t by a member secret_cookie.
  296. - rendcommon.c: Added rend_compute_v2_descriptor_fields() to prepare the
  297. encoding of a v2 descriptor.
  298. - rendcommon.c: Added rend_encode_v2_descriptor() to encode a v2
  299. descriptor.
  300. - or.h: Added 7 new members to rend_service_descriptor_t to store
  301. v2-specific information.
  302. - or.h: Added constant DIR_PURPOSE_UPLOAD_RENDDESC_V2.
  303. - directory.c: Added directory_post_to_hs_dir().
  304. - directory.c: Changed directory_initiate_command() to also recognize v2
  305. publish requests.
  306. - directory.c: Changed directory_send_command() to also prepare v2 publish
  307. requests.
  308. - directory.c: Changed directory_handle_command_post() to handle v2 publish
  309. requests.
  310. - crypto.c: Added implementation for crypto_cipher_encrypt_cbc().
  311. [July 9: Base version specified and running; yet, replication is not
  312. implemented, republication does not depend on publication periods, yet.]
  313. Hidden service client:
  314. /13/ Send v2 fetch requests
  315. A hidden service client that has set the config option
  316. "FetchV2HidServDescriptors" 0|1 to 1 handles SOCKS requests for v2 onion
  317. addresses by requesting a v2 descriptor from a randomly chosen hidden
  318. service directory that is responsible for keeping replica for the
  319. descriptor ID. In total there are six replicas of which the first and the
  320. last three are stored on consecutive nodes. The probability of picking one
  321. of the three consecutive replicas is 1/6, 2/6, and 3/6 to incorporate the
  322. fact that the availability will be the highest on the node with next higher
  323. ID. A hidden service client relies on the hidden service provider to store
  324. two sets of descriptors to compensate clock skew between service and
  325. client. (requires /1/, /2/, and /3/)
  326. - tor.1.in: Added the config option FetchV2HidServDescriptors.
  327. - rend-spec.txt, section 1.5: Added the new v2 onion address format.
  328. - rend-spec.txt, section 1.6: Alice's OP downloads the service descriptors
  329. similarly as Bob's OP uploaded them in 1.4.
  330. - rendcommon.c: Changed rend_cache_lookup_entry to enable it to also lookup
  331. v2 descriptors.
  332. - rendcommon.c: Added rend_compute_desc_id() to generate v2 descriptor IDs
  333. from v2 onion addresses.
  334. - rendcommon.c: Changed rend_valid_service_id() to also consider v2 onion
  335. addresses as valid and return the version number of the request (1 or 2).
  336. - rendclient.c: Added rend_client_refetch_v2_renddesc() to fetch v2 service
  337. descriptors using the secret cookie.
  338. - rendclient.c: Changed rend_client_remove_intro_point() to copy the secret
  339. cookie if the local descriptor has expired or there are no introduction
  340. points left.
  341. - or.h: Added FetchV2HidServDescriptors to or_options_t.
  342. - or.h: Added constant REND_DESC_ID_V2_LEN to reflect that v2 descriptor
  343. IDs are longer than v0/1 onion addresses.
  344. - or.h: Added constant DIR_PURPOSE_FETCH_RENDDESC_V2.
  345. - directory.c: Added directory_get_from_hs_dir().
  346. - directory.c: Changed directory_initiate_command() to also recognize v2
  347. fetch requests.
  348. - directory.c: Changed directory_send_command() to also prepare v2 fetch
  349. requests.
  350. - directory.c: Changed directory_handle_command_get() to handle v2 fetch
  351. requests.
  352. - connection_edge.c: Changed connection_ap_handshake_rewrite_and_attach()
  353. to fetch v2 service descriptors.
  354. - connection_edge.c: Changed parse_extended_hostname() to accept both,
  355. current and v2 onion addresses.
  356. - config.c: Added config options FetchV2HidServDescriptors.
  357. [July 9: Base version specified and running in which only one node is
  358. responsible for a specific descriptor ID.]
  359. /14/ Process v2 fetch reply and parse v2 descriptors
  360. A hidden service client that has sent a request for a v2 descriptor can
  361. parse it and store it to the local cache of rendezvous service descriptors.
  362. - rend-spec.txt, section 1.2: Added the new v2 hidden service descriptor
  363. format.
  364. - rend-spec.txt, section 1.6: Alice's OP parses the reply received from the
  365. hidden service directory.
  366. - routerparse.c: Added rend_parse_v2_service_descriptor() to parse a v2
  367. hidden service descriptor.
  368. - routerparse.c: Added rend_decrypt_introduction_points() to decrypt and
  369. parse the list of introduction points.
  370. - routerparse.c: Added ipo_token_table[] to parse the decrypted
  371. introduction points of v2 hidden service descriptors.
  372. - routerparse.c: Added desc_token_table[] to parse v2 hidden service
  373. descriptors.
  374. - routerparse.c: Added 8 to directory_keyword to parse v2 hidden service
  375. descriptors, and 5 to parse the decrypted list of introduction points.
  376. - rendcommon.c: Added rend_cache_store_v2_client() to parse a v2 descriptor
  377. and parse the encrypted list of introduction points.
  378. - or.h: Added secret_cookie to edge_connection_t, to dir_connection_t, and
  379. to origin_circuit_t to be able to decrypt introduction points when
  380. receiving a v2 descriptor.
  381. - or.h: Added 7 new members to rend_service_descriptor_t to store
  382. v2-specific information.
  383. - directory.c: Changed connection_dir_client_reached_eof() to also parse v2
  384. fetch replies.
  385. - crypto.c: Added implementation for crypto_cipher_decrypt_cbc().
  386. [July 9: Specified and running.]
  387. /15/ Establish connection to v2 hidden service
  388. A hidden service client can establish a connection to a hidden service
  389. using a v2 descriptor. This includes using the secret cookie for decrypting
  390. the introduction points contained in the descriptor. When contacting an
  391. introduction point, the client does not use the public key of the hidden
  392. service provider, but the freshly-generated public key that is included in
  393. the hidden service descriptor. Whether or not a fresh key is used instead
  394. of the key of the hidden service depends on the available protocol versions
  395. that are included in the descriptor; by this, connection establishment is
  396. to a certain extend decoupled from fetching the descriptor.
  397. - rend-spec.txt, section 1.8: Alice uses the public key that is included in
  398. the descriptor instead of Bob's permanent service key.
  399. - rendclient.c: Changed rend_client_introduction_acked() to copy the secret
  400. cookie in case the introduction point denied the request.
  401. - rendclient.c: Changed rend_client_remove_intro_point() to copy the secret
  402. cookie if the local descriptor has expired or there are no introduction
  403. points left.
  404. - or.h: Added secret_cookie to edge_connection_t, to dir_connection_t, and
  405. to origin_circuit_t to be able to decrypt introduction points when
  406. receiving a v2 descriptor.
  407. - or.h: Added 7 new members to rend_service_descriptor_t to store
  408. v2-specific information.
  409. - circuitlist.c: Changed _circuit_mark_for_close() to pass the secret
  410. cookie to rend_client_remove_intro_point() when an intro circ has failed.
  411. - circuituse.c: Changed circuit_get_open_circ_or_launch() to fetch a v2
  412. descriptor with the secret cookie, if no descriptor is available, or copy
  413. the secret cookie to the circuit, in case it dies later, so that it can
  414. be used to fetch a new descriptor.
  415. [July 9: Base version specified and running, but without fresh key.]
  416. Hidden service descriptor:
  417. (Requirements concerning the descriptor format are contained in /6/ and /7/.)
  418. The new v2 hidden service descriptor format looks like this:
  419. onion-address = h(public-key) + cookie
  420. descriptor-id = h(h(public-key) + h(time-period + cookie))
  421. descriptor-content = {
  422. descriptor-id,
  423. version,
  424. public-key,
  425. h(time-period + cookie),
  426. timestamp,
  427. protocol-versions,
  428. { introduction-points } encrypted with cookie
  429. } signed with private-key
  430. The "descriptor-id" needs to change periodically in order for the
  431. descriptor to be stored on changing nodes over time. It may only be
  432. computable by a hidden service provider and all of his clients to prevent
  433. unauthorized nodes from tracking the service activity by periodically
  434. checking whether there is a descriptor for this service. Finally, the
  435. hidden service directory needs to be able to verify that the hidden service
  436. provider is the true originator of the descriptor with the given ID.
  437. Therefore, "descriptor-id" is derived from the "public-key" of the hidden
  438. service provider, the current "time-period" which changes every 24 hours,
  439. and a secret "cookie" shared between hidden service provider and clients.
  440. (The "time-period" is constructed in a way that time periods do not change
  441. at the same moment for all descriptors by deriving a value between 0:00 and
  442. 23:59 hours from "public-key" and making the descriptors of this hidden
  443. service provider expire at that time of the day.) The "descriptor-id" is
  444. defined to be 160 bits long. [extending the "descriptor-id" length
  445. suggested by LO]
  446. Only the hidden service provider and the clients are able to generate
  447. future "descriptor-ID"s. Hence, the "onion-address" is extended from now
  448. the hash value of "public-key" by the secret "cookie". The "public-key" is
  449. determined to be 80 bits long, whereas the "cookie" is dimensioned to be
  450. 120 bits long. This makes a total of 200 bits or 40 base32 chars, which is
  451. quite a lot to handle for a human, but necessary to provide sufficient
  452. protection against an adversary from generating a key pair with same
  453. "public-key" hash or guessing the "cookie".
  454. A hidden service directory can verify that a descriptor was created by the
  455. hidden service provider by checking if the "descriptor-id" corresponds to
  456. the "public-key" and if the signature can be verified with the
  457. "public-key".
  458. The "introduction-points" that are included in the descriptor are encrypted
  459. using the same "cookie" that is shared between hidden service provider and
  460. clients. [correction to use another key than h(time-period + cookie) as
  461. encryption key for introduction points made by LO]
  462. A new text-based format is proposed for descriptors instead of an extension
  463. of the existing binary format for reasons of future extensibility.
  464. Security implications:
  465. The security implications of the proposed changes are grouped by the roles of
  466. nodes that could perform attacks or on which attacks could be performed.
  467. Attacks by authoritative directory nodes
  468. Authoritative directory nodes are not anymore the single places in the
  469. network that know about a hidden service's activity and introduction
  470. points. Thus, they cannot perform attacks using this information, e.g.
  471. track a hidden service's activity or usage pattern or attack its
  472. introduction points. Formerly, it would only require a single corrupted
  473. authoritative directory operator to perform such an attack.
  474. Attacks by hidden service directory nodes
  475. A hidden service directory node could misuse a stored descriptor to track a
  476. hidden service's activity and usage pattern by clients. Though there is no
  477. countermeasure against this kind of attack, it is very expensive to track a
  478. certain hidden service over time. An attacker would need to run a large
  479. number of stable onion routers that work as hidden service directory nodes
  480. to have a good probability to become responsible for its changing
  481. descriptor IDs. For each period, the probability is:
  482. 1-(N-c choose r)/(N choose r) for N-c>=r and 1 else with N as total
  483. number of hidden service directories, c as compromised nodes, and r as
  484. number of replicas
  485. The hidden service directory nodes could try to make a certain hidden
  486. service unavailable to its clients. Therefore, they could discard all
  487. stored descriptors for that hidden service and reply to clients that there
  488. is no descriptor for the given ID or return an old or false descriptor
  489. content. The client would detect a false descriptor, because it could not
  490. contain a correct signature. But an old content or an empty reply could
  491. confuse the client. Therefore, the countermeasure is to replicate
  492. descriptors among a small number of hidden service directories. The
  493. probability of a group of collaborating nodes to make a hidden service
  494. completely unavailable is in each period:
  495. (c choose r)/(N choose r) for c>=r and N>=r, and 0 else with N as total
  496. number of hidden service directories, c as compromised nodes, and r as
  497. number of replicas
  498. A hidden service directory could try to find out which introduction points
  499. are working on behalf of a hidden service. In contrast to the previous
  500. design, this is not possible anymore, because this information is encrypted
  501. to the clients of a hidden service.
  502. Attacks on hidden service directory nodes
  503. An anonymous attacker could try to swamp a hidden service directory with
  504. false descriptors for a given descriptor ID. This is prevented by requiring
  505. that descriptors are signed.
  506. Anonymous attackers could swamp a hidden service directory with correct
  507. descriptors for non-existing hidden services. There is no countermeasure
  508. against this attack. However, the creation of valid descriptors is more
  509. expensive than verification and storage in local memory. This should make
  510. this kind of attack unattractive.
  511. Attacks by introduction points
  512. Current or former introduction points could try to gain information on the
  513. hidden service they serve. But due to the fresh key pair that is used by
  514. the hidden service, this attack is not possible anymore.
  515. Attacks by clients
  516. Current or former clients could track a hidden service's activity, attack
  517. its introduction points, or determine the responsible hidden service
  518. directory nodes and attack them. There is nothing that could prevent them
  519. from doing so, because honest clients need the full descriptor content to
  520. establish a connection to the hidden service. At the moment, the only
  521. countermeasure against dishonest clients is to change the secret cookie and
  522. pass it only to the honest clients.
  523. Compatibility:
  524. The proposed design is meant to replace the current design for hidden service
  525. descriptors and their storage in the long run.
  526. There should be a first transition phase in which both, the current design
  527. and the proposed design are served in parallel. Onion routers should start
  528. serving as hidden service directories, and hidden service providers and
  529. clients should make use of the new design if both sides support it. Hidden
  530. service providers should be allowed to publish descriptors of the current
  531. format in parallel, and authoritative directories should continue storing and
  532. serving these descriptors.
  533. After the first transition phase, hidden service providers should stop
  534. publishing descriptors on authoritative directories, and hidden service
  535. clients should not try to fetch descriptors from the authoritative
  536. directories. However, the authoritative directories should continue serving
  537. hidden service descriptors for a second transition phase. As of this point,
  538. all v2 config options should be set to a default value of 1.
  539. After the second transition phase, the authoritative directories should stop
  540. serving hidden service descriptors.
  541. Specification:
  542. The proposed changes affect multiple sections in several specification
  543. documents that are only mentioned in the following. (As for now, all changes
  544. to specification documents are limited to the SVN branch 114-dist-storage.)
  545. tor.1.in
  546. Added the config options HSDir (/5/), PublishV2HidServDescriptors (/10/),
  547. and FetchV2HidServDescriptors (/13/).
  548. Added the files hostname2 and secret_cookie (/10/).
  549. dir-spec.txt
  550. 2.1 Added the flag hidden-service-dir to the router descriptor format
  551. (/5/).
  552. 3.2 Added the status flag HSDir to the vote and consensus status
  553. document format (/9/).
  554. 3.3 Added a rule for how an authority decides whether a router is assigned
  555. the flag HSDir (/9/).
  556. rend-spec.txt
  557. 0.4 Added history
  558. 1.1 Added requirement to create secret_cookie and hostname2 file (/10/).
  559. 1.2 Added the new v2 hidden service descriptor format (/6/, /12/ and
  560. /14/).
  561. 1.3 Instead of Bob's public key, the hidden service provider uses a
  562. freshly generated public key for every introduction point (/11/).
  563. 1.4 Added description of how to obtain a routing list of hidden service
  564. directories (/1/).
  565. 1.4 Added description of how to determine the responsible node(s) for a
  566. given descriptor ID (/2/).
  567. 1.4 Bob's OP does not only upload v0/v1 service descriptors to the
  568. authoritative directories, but also v2 service descriptors to the hidden
  569. service directories (/12/).
  570. 1.4 Added the requirement that requests need to be sent via Tor (/3/).
  571. 1.5 Added the new v2 onion address format (/13/).
  572. 1.6 Added the requirement that requests need to be sent via Tor (/3/).
  573. 1.6 Alice's OP downloads the service descriptors similarly as Bob's OP
  574. uploaded them in 1.4 (/13/).
  575. 1.6 Alice's OP parses the reply received from the hidden service directory
  576. (/14/).
  577. 1.8 Alice uses the public key that is included in the descriptor instead
  578. of Bob's permanent service key (/15/).
  579. 3.1: Added process of configuring a hidden service directory (/5/).
  580. 3.1: Added the decision on whether an onion router is confirmed to act as
  581. hidden service directory or not (/9/).
  582. 3.2: Added the requirement that requests need to be contained within
  583. BEGIN_DIR cells (/4/).
  584. 3.2: Added the acceptance of v2 publish requests (/6/).
  585. 3.3: Added the requirement that requests need to be contained within
  586. BEGIN_DIR cells (/4/).
  587. 3.3: Added the processing of v2 fetch requests (/7/).
  588. 3.3: Added the replication of v2 descriptors (/8/).
  589. Implementation:
  590. The proposed changes affect the following changes in the source code. (As for
  591. now, all changes to code are limited to the SVN branch 114-dist-storage.)
  592. container.h
  593. Added prototype for smartlist_digest_next_circular() (/2/).
  594. container.c
  595. Added implementation for smartlist_digest_next_circular() (/2/).
  596. crypto.h
  597. Added 3 prototypes according to the changes in crypto.c (various
  598. requirements).
  599. crypto.c
  600. Added implementation for crypto_cipher_encrypt_cbc() (/12/).
  601. Added implementation for crypto_cipher_decrypt_cbc() (/14/).
  602. Added implementation for base32_decode() (various requirements).
  603. circuitlist.c
  604. Changed _circuit_mark_for_close() to pass the secret cookie to
  605. rend_client_remove_intro_point() when an intro circ has failed (/15/).
  606. circuituse.c
  607. Changed circuit_get_open_circ_or_launch() to fetch a v2 descriptor with the
  608. secret cookie, if no descriptor is available, or copy the secret cookie to
  609. the circuit, in case it dies later, so that it can be used to fetch a new
  610. descriptor (/15/).
  611. config.c
  612. Added config options FetchV2HidServDescriptors (/13/), HSDir (/5/), and
  613. PublishV2HidServDescriptors (/10/).
  614. connection_edge.c
  615. Changed connection_ap_handshake_rewrite_and_attach() to fetch v2 service
  616. descriptors (/13/).
  617. Changed parse_extended_hostname() to accept both, current and v2 onion
  618. addresses (/13/).
  619. directory.c
  620. Added directory_post_to_hs_dir() (/12/).
  621. Added directory_get_from_hs_dir() (/13/).
  622. Changed directory_initiate_command() to also recognize v2 publish (/12/)
  623. and fetch (/13/) requests.
  624. Changed directory_send_command() to also prepare v2 publish (/12/) and
  625. fetch (/13/) requests.
  626. Changed connection_dir_client_reached_eof() to also parse v2 fetch replies
  627. (/14/).
  628. Changed directory_handle_command_get() to handle v2 fetch requests (/13/).
  629. Changed directory_handle_command_post() to handle v2 publish requests
  630. (/12/).
  631. dirserv.c
  632. Changed routerstatus_format_entry() to include the "HSDir" flag in vote and
  633. consensus status documents (/9/).
  634. Changed set_routerstatus_from_routerinfo() to set the "HSDir" flag (/9/).
  635. or.h
  636. Added constants DIR_PURPOSE_UPLOAD_RENDDESC_V2 (/12/) and
  637. DIR_PURPOSE_FETCH_RENDDESC_V2 (/13/).
  638. Added constant REND_DESC_ID_V2_LEN to reflect that v2 descriptor IDs are
  639. longer than v0/1 onion addresses (/6/, /7/, and /13/).
  640. Added rend_version and secret_cookie to edge_connection_t, to
  641. dir_connection_t, and to origin_circuit_t to be able to decrypt
  642. introduction points when receiving a v2 descriptor (/14/ and /15/).
  643. Added is_hs_dir member to routerinfo_t and to routerstatus_t (/9/).
  644. Added hs_dirs member to routerlist_t (/1/).
  645. Added FetchV2HidServDescriptors (/13/), HSDir (/5/), and
  646. PublishV2HidServDescriptors (/10/) to or_options_t.
  647. Added 7 new members to rend_service_descriptor_t to store v2-specific
  648. information (/12/, /14/, and /15/).
  649. Added 11 prototypes and changed the signature of 1 according to the
  650. changes in .c files (various requirements).
  651. rendclient.c
  652. Changed rend_client_introduction_acked() to copy the secret cookie in case
  653. the introduction point denied the request (/15/).
  654. Added rend_client_refetch_v2_renddesc() to fetch v2 service descriptors
  655. using the secret cookie (/13/).
  656. Changed rend_client_remove_intro_point() to copy the secret cookie if the
  657. local descriptor has expired or there are no introduction points left (/13/
  658. and /15/).
  659. rendcommon.c
  660. Added rend_compute_v2_descriptor_fields() to prepare the encoding of a v2
  661. descriptor (/12/).
  662. Added rend_compute_desc_id() to generate v2 descriptor IDs from v2 onion
  663. addresses (/13/).
  664. Added rend_encode_v2_descriptor() to encode a v2 descriptor (/12/).
  665. Changed rend_valid_service_id() to also consider v2 onion addresses as
  666. valid and return the version number of the request (1 or 2) (/13/).
  667. Changed rend_cache_lookup_entry to enable it to also lookup v2 descriptors
  668. (/13/).
  669. Added rend_cache_lookup_v2_dir() to allow a hidden service directory to
  670. look up a v2 descriptor in the local cache under its descriptor ID instead
  671. of its service ID (/7/).
  672. Moved the parsing part from rend_cache_store() to the new function
  673. rend_cache_store_parse() to reuse it for v2 descriptors (/6/).
  674. Added rend_cache_store_v2_client() to parse a v2 descriptor and parse the
  675. encrypted list of introduction points (/14/).
  676. Added rend_cache_store_v2_dir() to allow a hidden service directory to
  677. store a v2 descriptor in the local cache under its descriptor ID instead of
  678. its service ID (/6/).
  679. rendservice.c
  680. Extended rend_service_t by a member secret_cookie (/10/ and /12/).
  681. Added rend_get_hostname2() to assemble a v2 onion address (/10/).
  682. Changed rend_service_load_keys() to write a secret_cookie and a hostname2
  683. file (/10/).
  684. Changed upload_service_descriptor() to upload v2 hidden service
  685. descriptors, if configured (/12/).
  686. Changed rend_consider_services_upload() to also initiate the upload of v2
  687. descriptors, if configured (/12/).
  688. router.c
  689. Changed router_dump_router_to_string() to include the "hidden-service-dir"
  690. flag in a router descriptor if configured (/5/).
  691. routerlist.c
  692. Changed router_get_routerlist() to initialize routing list (/1/).
  693. Added get_responsible_hs_dir() to determine the router that is responsible
  694. for a given descriptor ID (/2/).
  695. routerparse.c
  696. Added 14 keywords to directory_keyword; 1 to parse the "hidden-service-dir"
  697. flag in router descriptors (/9/), 8 to parse v2 hidden service descriptors
  698. (/6/ and /14/), and 5 to parse the decrypted list of introduction points
  699. (/14/).
  700. Added an entry to routerdesc_token_table[] to parse the
  701. "hidden-service-directory" flag in router descriptors (/9/).
  702. Added desc_token_table[] to parse v2 hidden service descriptors (/6/ and
  703. /14/).
  704. Added ipo_token_table[] to parse the decrypted introduction points of v2
  705. hidden service descriptors (/14/).
  706. Changed router_parse_entry_from_string() to parse the "hidden-service-dir"
  707. flag in router descriptors (/9/).
  708. Changed routerstatus_parse_entry_from_string to parse the "HSDir" flag in
  709. vote and consensus status documents (/1/).
  710. Added rend_parse_v2_service_descriptor() to parse a v2 hidden service
  711. descriptor (/6/ and /14/).
  712. Added rend_decrypt_introduction_points() to decrypt and parse the list of
  713. introduction points (/14/).