114-distributed-storage.txt 43 KB

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