143-distributed-storage-improvements.txt 9.6 KB

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