143-distributed-storage-improvements.txt 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. Filename: 143-distributed-storage-improvements.txt
  2. Title: Improvements of Distributed Storage for Tor Hidden Service Descriptors
  3. Version: $Revision$
  4. Last-Modified: $Date$
  5. Author: Karsten Loesing
  6. Created: 28-Jun-2008
  7. Status: Open
  8. Target: 0.2.1.x
  9. Change history:
  10. 28-Jun-2008 Initial proposal for or-dev
  11. Overview:
  12. An evaluation of the distributed storage for Tor hidden service
  13. descriptors and subsequent discussions have brought up a few improvements
  14. to proposal 114. All improvements are backwards compatible to the
  15. implementation of proposal 114.
  16. Design:
  17. 1. Report Bad Directory Nodes
  18. Bad hidden service directory nodes could deny existence of previously
  19. stored descriptors. A bad directory node that does this with all stored
  20. descriptors causes harm to the distributed storage in general, but
  21. replication will cope with this problem in most cases. However, an
  22. adversary that attempts to make a specific hidden service unavailable by
  23. running relays that become responsible for all of a service's
  24. descriptors poses a more serious threat. The distributed storage needs to
  25. defend against this attack by detecting and removing bad directory nodes.
  26. As a countermeasure hidden services try to download their descriptors
  27. every hour at random times from the hidden service directories that are
  28. responsible for storing it. If a directory node replies with 404 (Not
  29. found), the hidden service reports the supposedly bad directory node to
  30. a random selection of half of the directory authorities (with version
  31. numbers equal to or higher than the first version that implements this
  32. proposal). The hidden service posts a complaint message using HTTP 'POST'
  33. to a URL "/tor/rendezvous/complain" with the following message format:
  34. "hidden-service-directory-complaint" identifier NL
  35. [At start, exactly once]
  36. The identifier of the hidden service directory node to be
  37. investigated.
  38. "rendezvous-service-descriptor" descriptor NL
  39. [At end, Excatly once]
  40. The hidden service descriptor that the supposedly bad directory node
  41. does not serve.
  42. The directory authority checks if the descriptor is valid and the hidden
  43. service directory responsible for storing it. It waits for a random time
  44. of up to 30 minutes before posting the descriptor to the hidden service
  45. directory. If the publication is acknowledged, the directory authority
  46. waits another random time of up to 30 minutes before attempting to
  47. request the descriptor that it has posted. If the directory node replies
  48. with 404 (Not found), it will be blacklisted for being a hidden service
  49. directory node for the next 48 hours.
  50. A blacklisted hidden service directory is assigned the new flag BadHSDir
  51. instead of the HSDir flag in the vote that a directory authority creates.
  52. In a consensus a relay is only assigned a HSDir flag if the majority of
  53. votes contains a HSDir flag and no more than one third of votes contains
  54. a BadHSDir flag. As a result, clients do not have to learn about the
  55. BadHSDir flag. A blacklisted directory node will simply not be assigned
  56. the HSDir flag in the consensus.
  57. In order to prevent an attacker from setting up new nodes as replacement
  58. for blacklisted directory nodes, all directory nodes in the same /24
  59. subnet are blacklisted, too. Furthermore, if two or more directory nodes
  60. are blacklisted in the same /16 subnet concurrently, all other directory
  61. nodes in that /16 subnet are blacklisted, too. Blacklisting holds for at
  62. most 48 hours.
  63. 2. Publish Fewer Replicas
  64. The evaluation has shown that the probability of a directory node to
  65. serve a previously stored descriptor is 85.7% (more precisely, this is
  66. the 0.001-quantile of the empirical distribution with the rationale that
  67. it holds for 99.9% of all empirical cases). If descriptors are replicated
  68. to x directory nodes, the probability of at least one of the replicas to
  69. be available for clients is 1 - (1 - 85.7%) ^ x. In order to achieve an
  70. overall availability of 99.9%, x = 3.55 replicas need to be stored. From
  71. this follows that 4 replicas are sufficient, rather than the currently
  72. stored 6 replicas.
  73. Further, the current design stores 2 sets of descriptors on 3 directory
  74. nodes with consecutive identities. Originally, this was meant to
  75. facilitate replication between directory nodes, which has not been and
  76. will not be implemented (the selection criterion of 24 hours uptime does
  77. not make it necessary). As a result, storing descriptors on directory
  78. nodes with consecutive identities is not required. In fact it should be
  79. avoided to enable an attacker to create "black holes" in the identifier
  80. ring.
  81. Hidden services should store their descriptors on 4 non-consecutive
  82. directory nodes, and clients should request descriptors from these
  83. directory nodes only. For compatibility reasons, hidden services also
  84. store their descriptors on 2 consecutive directory nodes. Hence, 0.2.0.x
  85. clients will be able to retrieve 4 out of 6 descriptors, but will fail
  86. for the remaining 2 descriptors, which is sufficient for reliability. As
  87. soon as 0.2.0.x is deprecated, hidden services can stop publishing the
  88. additional 2 replicas.
  89. 3. Change Default Value of Being Hidden Service Directory
  90. The requirements for becoming a hidden service directory node are an open
  91. directory port and an uptime of at least 24 hours. The evaluation has
  92. shown that there are 300 hidden service directory candidates in the mean,
  93. but only 6 of them are configured to act as hidden service directories.
  94. This is bad, because those 6 nodes need to serve a large share of all
  95. hidden service descriptors. Optimally, there should be hundreds of hidden
  96. service directories. Having a large number of 0.2.1.x directory nodes
  97. also has a positive effect on 0.2.0.x hidden services and clients.
  98. Therefore, the new default of HidServDirectoryV2 should be 1, so that a
  99. Tor relay that has an open directory port automatically accepts and
  100. serves v2 hidden service descriptors. A relay operator can still opt-out
  101. running a hidden service directory by changing HidServDirectoryV2 to 0.
  102. The additional bandwidth requirements for running a hidden service
  103. directory node in addition to being a directory cache are negligible.
  104. 4. Make Descriptors Persistent on Directory Nodes
  105. Hidden service directories that are restarted by their operators or after
  106. a failure will not be selected as hidden service directories within the
  107. next 24 hours. However, some clients might still think that these nodes
  108. are responsible for certain descriptors, because they work on the basis
  109. of network consensuses that are up to three hours old. The directory
  110. nodes should be able to serve the previously received descriptors to
  111. these clients. Therefore, directory nodes make all received descriptors
  112. persistent and load previously received descriptors on startup.
  113. 5. Store and Serve Descriptors Regardless of Responsibility
  114. Currently, directory nodes only accept descriptors for which they think
  115. they are responsible. This may lead to problems when a directory node
  116. uses an older or newer network consensus than hidden service or client
  117. or when a directory node has been restarted recently. In fact, there are
  118. no security issues in storing or serving descriptors for which a
  119. directory node thinks it is not responsible. To the contrary, doing so
  120. may improve reliability in border cases. As a result, a directory node
  121. does not pay attention to responsibilty when receiving a publication or
  122. fetch request, but stores or serves the requested descriptor. Likewise,
  123. the directory node does not remove descriptors when it thinks it is not
  124. responsible for them any more.
  125. 6. Avoid Periodic Descriptor Re-Publication
  126. In the current implementation a hidden service re-publishes its
  127. descriptor either when its content changes or an hour elapses. However,
  128. the evaluation has shown that failures of hidden service directory nodes,
  129. i.e. of nodes that have not failed within the last 24 hours, are very
  130. rare. Together with making descriptors persistent on directory nodes,
  131. there is no necessity to re-publish descriptors hourly.
  132. The only two events leading to descriptor re-publication should be a
  133. change of the descriptor content and a new directory node becoming
  134. responsible for the descriptor. Hidden services should therefore consider
  135. re-publication every time they learn about a new network consensus
  136. instead of hourly.
  137. 7. Discard Expired Descriptors
  138. The current implementation lets directory nodes keep a descriptor for two
  139. days before discarding it. However, with the v2 design, descriptors are
  140. only valid for at most one day. Directory nodes should determine the
  141. validity of stored descriptors and discard them one hour after they have
  142. expired (to compensate wrong clocks on clients).
  143. 8. Shorten Client-Side Descriptor Fetch History
  144. When clients try to download a hidden service descriptor, they memorize
  145. fetch requests to directory nodes for up to 15 minutes. This allows them
  146. to request all replicas of a descriptor to avoid bad or failing directory
  147. nodes, but without querying the same directory node twice.
  148. The downside is that a client that has requested a descriptor without
  149. success, will not be able to find a hidden service that has been started
  150. during the following 15 minutes after the client's last request.
  151. This can be improved by shortening the fetch history to only 5 minutes.
  152. This time should be sufficient to complete requests for all replicas of a
  153. descriptor, but without ending in an infinite request loop.
  154. Compatibility:
  155. All proposed improvements are compatible to the currently implemented
  156. design as described in proposal 114.