dir-spec.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. $Id$
  2. Tor directory protocol for 0.1.1.x series
  3. 0. Scope and preliminaries
  4. This document should eventually be merged into tor-spec.txt and replace
  5. the existing notes on directories.
  6. This is not a finalized version; what we actually wind up implementing
  7. may be very different from the system described here.
  8. 0.1. Goals
  9. There are several problems with the way Tor handles directories right
  10. now:
  11. 1. Directories are very large and use a lot of bandwidth.
  12. 2. Every directory server is a single point of failure.
  13. 3. Requiring every client to know every server won't scale.
  14. 4. Requiring every directory cache to know every server won't scale.
  15. 5. Our current "verified server" system is kind of nonsensical.
  16. 6. Getting more directory servers adds more points of failure and
  17. worsens possible partitioning attacks.
  18. This design tries to solve every problem except problems 3 and 4, and to
  19. be compatible with likely eventual solutions to problems 3 and 4.
  20. 1. Outline
  21. There is no longer any such thing as a "signed directory". Instead,
  22. directory servers sign a very compressed 'network status' object that
  23. lists the current descriptors and their status, and router descriptors
  24. continue to be self-signed by servers. Clients download network status
  25. listings periodically, and download router descriptors as needed. ORs
  26. upload descriptors relatively infrequently.
  27. There are multiple directory servers. Rather than doing anything
  28. complicated to coordinate themselves, clients simply rotate through them
  29. in order, and only use servers that most of the last several directory
  30. servers like.
  31. 2. Router descriptors
  32. The router descriptor format is unchanged from tor-spec.txt.
  33. ORs SHOULD generate a new router descriptor whenever any of the
  34. following events have occurred:
  35. - A period of time (18 hrs by default) has passed since the last
  36. time a descriptor was generated.
  37. - A descriptor field other than bandwidth or uptime has changed.
  38. - Bandwidth has changed by more than +/- 50% from the last time a
  39. descriptor was generated, and at least a given interval of time
  40. (20 mins by default) has passed since then.
  41. - Uptime has been reset.
  42. After generating a descriptor, ORs upload it to every directory
  43. server they know.
  44. 3. Network status
  45. Directory servers generate, sign, and compress a network-status document
  46. as needed. As an optimization, they may rate-limit the number of such
  47. documents generated to once every few seconds. Directory servers should
  48. rate-limit at least to the point where these documents are generated no
  49. faster than once per second.
  50. The network status document contains a preamble, a set of router status
  51. entries, and a signature, in that order.
  52. We use the same meta-format as used for directories and router descriptors
  53. in "tor-spec.txt".
  54. The preamble contains:
  55. "network-status-version" -- A document format version. For this
  56. specification, the version is "2".
  57. "dir-source" -- The hostname, current IP address, and directory
  58. port of the directory server, separated by spaces.
  59. "fingerprint" -- A base16-encoded hash of the signing key's
  60. fingerprint, with no additional spaces added.
  61. "contact" -- An arbitrary string describing how to contact the
  62. directory server's administrator. Administrators should include at
  63. least an email address and a PGP fingerprint.
  64. "dir-signing-key" -- The directory server's public signing key.
  65. "client-versions" -- A comma-separated list of recommended client versions.
  66. "server-versions" -- A comma-separated list of recommended server versions.
  67. "published" -- The publication time for this network-status object.
  68. "dir-options" -- A set of flags separated by spaces:
  69. "Names" if this directory server performs name bindings.
  70. "Versions" if this directory server recommends software versions.
  71. The dir-options entry is optional. The "-versions" entries are required if
  72. the "Versions" flag is present. The other entries are required and must
  73. appear exactly once. The "network-status-version" entry must appear first;
  74. the others may appear in any order.
  75. For each router, the router entry contains: (This format is designed for
  76. conciseness.)
  77. "r" -- followed by the following elements, separated by spaces:
  78. - The OR's nickname,
  79. - A hash of its identity key, encoded in base64, with trailing =
  80. signs removed.
  81. - A hash of its most recent descriptor, encoded in base64, with
  82. trailing = signs removed. (The hash is calculated as for
  83. computing the signature of a descriptor.)
  84. - The publication time of its most recent descriptor.
  85. - An IP
  86. - An OR port
  87. - A directory port (or "0" for none")
  88. "s" -- A series of space-separated status flags:
  89. "Exit" if the router is useful for building general-purpose exit
  90. circuits.
  91. "Stable" if the router tends to stay up for a long time.
  92. "Fast" if the router has high bandwidth.
  93. "Running" if the router is currently usable.
  94. "Named" if the router's identity-nickname mapping is canonical.
  95. "Valid" if the router has been 'validated'.
  96. "Authority" if the router is a directory authority.
  97. The "r" entry for each router must appear first and is required. The
  98. 's" entry is optional. Unrecognized flags, or extra elements on the
  99. "r" line must be ignored.
  100. The signature section contains:
  101. "directory-signature". A signature of the rest of the document using
  102. the directory server's signing key.
  103. We compress the network status list with zlib before transmitting it.
  104. 4. Directory server operation
  105. By default, directory servers remember all non-expired, non-superseded OR
  106. descriptors that they have seen.
  107. For each OR, a directory server remembers whether the OR was running and
  108. functional the last time they tried to connect to it, and possibly other
  109. liveness information.
  110. Directory server administrators may label some servers or IPs as
  111. blacklisted, and elect not to include them in their network-status lists.
  112. Thus, the network-status list includes all non-blacklisted,
  113. non-expired, non-superseded descriptors for ORs that the directory has
  114. observed at least once to be running.
  115. Directory server administrators may decide to support name binding. If
  116. they do, then they must maintain a file of nickname-to-identity-key
  117. mappings, and try to keep this file consistent with other directory
  118. servers. If they don't, they act as clients, and report bindings made by
  119. other directory servers (name X is bound to identity Y if at least one
  120. binding directory lists it, and no directory binds X to some other Y'.)
  121. The authoritative network-status published by a host should be available at:
  122. http://<hostname>/tor/status/authority.z
  123. An authoritative network-status published by another host with fingerprint
  124. <F> should be available at:
  125. http://<hostname>/tor/status/fp/<F>.z
  126. An authoritative network-status published by other hosts with fingerprints
  127. <F1>,<F2>,<F3> should be available at:
  128. http://<hostname>/tor/status/fp/<F1>+<F2>+<F3>.z
  129. The most recent network-status documents from all known authoritative
  130. directories, concatenated, should be available at:
  131. http://<hostname>/tor/status/all.z
  132. The most recent descriptor for a server whose identity key has a
  133. fingerprint of <F> should be available at:
  134. http://<hostname>/tor/server/fp/<F>.z
  135. The most recent descriptors for servers have fingerprints <F1>,<F2>,<F3>
  136. should be available at:
  137. http://<hostname>/tor/server/fp/<F1>+<F2>+<F3>.z
  138. The most recent descriptor for this server should be at:
  139. http://<hostname>/tor/server/authority.z
  140. A concatenated set of the most recent descriptors for all known servers
  141. should be available at:
  142. http://<hostname>/tor/server/all.z
  143. For debugging, directories MAY expose non-compressed objects at URLs like
  144. the above, but without the final ".z".
  145. Clients MUST handle compressed concatenated information in two forms:
  146. - A concatenated list of zlib-compressed objects.
  147. - A zlib-compressed concatenated list of objects.
  148. Directory servers MAY generate either format: the former requires less
  149. CPU, but the latter requires less bandwidth.
  150. 4.1. Caching
  151. Directory caches (most ORs) regularly download network status documents,
  152. and republish them at a URL based on the directory server's identity key:
  153. http://<hostname>/tor/status/<identity fingerprint>.z
  154. A concatenated list of all network-status documents should be available at:
  155. http://<hostname>/tor/status/all.z
  156. 4.2. Compression
  157. 5. Client operation
  158. Every OP or OR, including directory servers, acts as a client to the
  159. directory protocol.
  160. Each client maintains a list of trusted directory servers. Periodically
  161. (currently every 20 minutes), the client downloads a new network status. It
  162. chooses the directory server from which its current information is most
  163. out-of-date, and retries on failure until it finds a running server.
  164. When choosing ORs to build circuits, clients proceed as follows:
  165. - A server is "listed" if it is listed by more than half of the "live"
  166. network status documents the clients have downloaded. (A network
  167. status is "live" if it is the most recently downloaded network status
  168. document for a given directory server, and the server is a directory
  169. server trusted by the client, and the network-status document is no
  170. more than D (say, 10) days old.)
  171. - A server is "valid" is it is listed as valid by more than half of the
  172. "live" downloaded" network-status document.
  173. - A server is "running" if it is listed as running by more than
  174. half of the "recent" downloaded network-status documents.
  175. (A network status is "recent" if it was published in the last
  176. 60 minutes. If there are fewer than 3 such documents, the most
  177. recently published 3 are "recent." If there are fewer than 3 in all,
  178. all are "recent.")
  179. Clients store network status documents so long as they are live.
  180. 5.1. Scheduling network status downloads
  181. This download scheduling algorithm implements the approach described above
  182. in a relatively low-state fashion. It reflects the current Tor
  183. implementation.
  184. Clients maintain a list of authorities; each client tries to keep the same
  185. list, in the same order.
  186. Periodically, on startup, and on HUP, clients check whether they need to
  187. download fresh network status documents. The approach is as follows:
  188. - If we have under X network status documents newer than OLD, we choose a
  189. member of the list at random and try download XX documents starting
  190. with that member's.
  191. - Otherwise, if we have no network status documents newer than NEW, we
  192. check to see which authority's document we retrieved most recently,
  193. and try to retrieve the next authority's document. If we can't, we
  194. try the next authority in sequence, and so on.
  195. 5.2. Managing naming
  196. In order to provide human-memorable names for individual server
  197. identities, some directory servers bind names to IDs. Clients handle
  198. names in two ways:
  199. If a client is encountering a name it has not mapped before:
  200. If all the "binding" networks-status documents the client has so far
  201. received same claim that the name binds to some identity X, and the
  202. client has received at least three network-status documents, the client
  203. maps the name to X.
  204. If a client is encountering a name it has mapped before:
  205. It uses the last-mapped identity value, unless all of the "binding"
  206. network status documents bind the name to some other identity.
  207. 5.3. Notes on what we do now.
  208. THIS SECTION SHOULD BE FOLDED INTO THE EARLIER SECTIONS; THEY ARE WRONG;
  209. THIS IS RIGHT.
  210. All downloaded networkstatuses are discarded once they are 10 days old (by
  211. published date).
  212. Authdirs download each others' networkstatus every
  213. AUTHORITY_NS_CACHE_INTERVAL minutes (currently 10).
  214. Directory caches download authorities' networkstatus every
  215. NONAUTHORITY_NS_CACHE_INTERVAL minutes (currently 10).
  216. Clients always try to replace any networkstatus received over
  217. NETWORKSTATUS_MAX_VALIDITY ago (currently 2 days). Also, when the most
  218. recently received networkstatus is more than
  219. NETWORKSTATUS_CLIENT_DL_INTERVAL (30 minutes) old, and we do not have any
  220. open directory connections fetching a networkstatus, clients try to
  221. download the networkstatus on their list after the most recently received
  222. networkstatus, skipping failed networkstatuses. A networkstatus is
  223. "failed" if NETWORKSTATUS_N_ALLOWABLE_FAILURES (3) attempts in a row have
  224. all failed.
  225. We do not update router statuses if we have less than half of the
  226. networkstatuses.
  227. A networkstatus is "live" if it is the most recent we have received signed
  228. by a given trusted authority.
  229. A networkstatus is "recent" if it is "live" and:
  230. - it was received in the last DEFAULT_RUNNING_INTERVAL (currently 60
  231. minutes)
  232. OR - it was one of the MIN_TO_INFLUENCE_RUNNING (3) most recently received
  233. networkstatuses.
  234. Authorities always believe their own opinion as to a router's status. For
  235. other tors:
  236. - a router is valid if more than half of the live networkstatuses think
  237. it's valid.
  238. - a router is named if more than half of the live networkstatuses from
  239. naming authorities think it's named, and they all think it has the
  240. same name.
  241. - a router is running if more than half of the recent networkstatuses
  242. think it's running.
  243. Everyone downloads router descriptors as follows:
  244. - If any networkstatus lists a more recently published routerdesc with a
  245. different descriptor digest, and no more than
  246. MAX_ROUTERDESC_DOWNLOAD_FAILURES attempts to retrieve that routerdesc
  247. have failed, then that routerdesc is "downloadable".
  248. - Every DirFetchInterval, or whenever a request for routerdescs returns
  249. no routerdescs, we launch a set of requests for all downloadable
  250. routerdescs. We divide the downloadable routerdescs into groups of no
  251. more than DL_PER_REQUEST, and send a request for each group to
  252. directory servers chosen independently.
  253. - We also launch a request as above when a request for routerdescs
  254. fails and we have no directory connections fetching routerdescs.
  255. TODO Specify here:
  256. - When to 0-out failure count for networkstatus?
  257. - Drop fallback to download-all. Also, always split download.
  258. - For versions: if you're listed by more than half of live versioning
  259. networkstatuses, good. if less than half of networkstatuses are live,
  260. don't do anything. If half are live, and half of less of the
  261. versioning ones list you, warn. Only warn once every 24 hours.
  262. - For names: warn if an unnamed router is specified by nickname.
  263. Rate-limit these warnings.
  264. - Also, don't believe N->K if another naming authdir says N->K'.
  265. - Revise naming rule: N->K is true if any naming directory says N->K,
  266. and no other naming directory says N->K' or N'->K.
  267. - Minimum info to build circuits.
  268. - Revise: always split requests when we have too little info to build
  269. circuits.
  270. - Describe when router is "out of date". (Any dirserver says so.)
  271. - Change rule from "do not launch new connections when one exists" to
  272. "do not request any fingerprint that we're currently requesting."
  273. - Launch new connections every minute, plus whenever a download fails.
  274. - Reset routerdesc failure count after 60 minutes, or when
  275. when network comes back on after absence.
  276. - Make "I didn't get the one I thought was most recent" a failure.
  277. - Retry these every 5 minutes if you're a client.
  278. - Mirrors should retry these harder and more often.
  279. - If we have a routerdesc for Bob, and he says, "I'm 0.1.0.x", don't
  280. fetch a new one if it was published in the last 2 hours. (??)
  281. - Describe what we do with old server versions.
  282. - If we have less than 16 to download, do not download unless 10 minutes
  283. have passed since last download.
  284. 6. Remaining issues
  285. Client-knowledge partitioning is worrisome. Most versions of this don't
  286. seem to be worse than the Danezis-Murdoch tracing attack, since an
  287. attacker can't do more than deduce probable exits from entries (or vice
  288. versa). But what about when the client connects to A and B but in a
  289. different order? How bad can it be partitioned based on its knowledge?