121-hidden-service-authentication.txt 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. Filename: 121-hidden-service-authentication.txt
  2. Title: Hidden Service Authentication
  3. Version: $Revision$
  4. Last-Modified: $Date$
  5. Author: Tobias Kamm, Thomas Lauterbach, Karsten Loesing, Ferdinand Rieger,
  6. Christoph Weingarten
  7. Created: 10-Sep-2007
  8. Status: Open
  9. Target: 0.2.1.x
  10. Change history:
  11. 26-Sep-2007 Initial proposal for or-dev
  12. 08-Dec-2007 Incorporated comments by Nick posted to or-dev on 10-Oct-2007
  13. 15-Dec-2007 Rewrote complete proposal for better readability, modified
  14. authentication protocol, merged in personal notes
  15. 24-Dec-2007 Replaced misleading term "authentication" by "authorization"
  16. and added some clarifications (comments by Sven Kaffille)
  17. 28-Apr-2008 Updated most parts of the concrete authorization protocol
  18. 04-Jul-2008 Add a simple algorithm to delay descriptor publication for
  19. different clients of a hidden service
  20. 19-Jul-2008 Added INTRODUCE1V cell type (1.2), improved replay
  21. protection for INTRODUCE2 cells (1.3), described limitations
  22. for auth protocols (1.6), improved hidden service protocol
  23. without client authorization (2.1), added second, more
  24. scalable authorization protocol (2.2), rewrote existing
  25. authorization protocol (2.3); changes based on discussion
  26. with Nick
  27. 31-Jul-2008 Limit maximum descriptor size to 20 kilobytes to prevent
  28. abuse.
  29. 01-Aug-2008 Use first part of Diffie-Hellman handshake for replay
  30. protection instead of rendezvous cookie.
  31. Overview:
  32. This proposal deals with a general infrastructure for performing
  33. authorization (not necessarily implying authentication) of requests to
  34. hidden services at three points: (1) when downloading and decrypting
  35. parts of the hidden service descriptor, (2) at the introduction point,
  36. and (3) at Bob's Tor client before contacting the rendezvous point. A
  37. service provider will be able to restrict access to his service at these
  38. three points to authorized clients only. Further, the proposal contains
  39. specific authorization protocols as instances that implement the
  40. presented authorization infrastructure.
  41. This proposal is based on v2 hidden service descriptors as described in
  42. proposal 114 and introduced in version 0.2.0.10-alpha.
  43. The proposal is structured as follows: The next section motivates the
  44. integration of authorization mechanisms in the hidden service protocol.
  45. Then we describe a general infrastructure for authorization in hidden
  46. services, followed by specific authorization protocols for this
  47. infrastructure. At the end we discuss a number of attacks and non-attacks
  48. as well as compatibility issues.
  49. Motivation:
  50. The major part of hidden services does not require client authorization
  51. now and won't do so in the future. To the contrary, many clients would
  52. not want to be (pseudonymously) identifiable by the service (though this
  53. is unavoidable to some extent), but rather use the service
  54. anonymously. These services are not addressed by this proposal.
  55. However, there may be certain services which are intended to be accessed
  56. by a limited set of clients only. A possible application might be a
  57. wiki or forum that should only be accessible for a closed user group.
  58. Another, less intuitive example might be a real-time communication
  59. service, where someone provides a presence and messaging service only to
  60. his buddies. Finally, a possible application would be a personal home
  61. server that should be remotely accessed by its owner.
  62. Performing authorization for a hidden service within the Tor network, as
  63. proposed here, offers a range of advantages compared to allowing all
  64. client connections in the first instance and deferring authorization to
  65. the transported protocol:
  66. (1) Reduced traffic: Unauthorized requests would be rejected as early as
  67. possible, thereby reducing the overall traffic in the network generated
  68. by establishing circuits and sending cells.
  69. (2) Better protection of service location: Unauthorized clients could not
  70. force Bob to create circuits to their rendezvous points, thus preventing
  71. the attack described by Øverlier and Syverson in their paper "Locating
  72. Hidden Servers" even without the need for guards.
  73. (3) Hiding activity: Apart from performing the actual authorization, a
  74. service provider could also hide the mere presence of his service from
  75. unauthorized clients when not providing hidden service descriptors to
  76. them, rejecting unauthorized requests already at the introduction
  77. point (ideally without leaking presence information at any of these
  78. points), or not answering unauthorized introduction requests.
  79. (4) Better protection of introduction points: When providing hidden
  80. service descriptors to authorized clients only and encrypting the
  81. introduction points as described in proposal 114, the introduction points
  82. would be unknown to unauthorized clients and thereby protected from DoS
  83. attacks.
  84. (5) Protocol independence: Authorization could be performed for all
  85. transported protocols, regardless of their own capabilities to do so.
  86. (6) Ease of administration: A service provider running multiple hidden
  87. services would be able to configure access at a single place uniformly
  88. instead of doing so for all services separately.
  89. (7) Optional QoS support: Bob could adapt his node selection algorithm
  90. for building the circuit to Alice's rendezvous point depending on a
  91. previously guaranteed QoS level, thus providing better latency or
  92. bandwidth for selected clients.
  93. A disadvantage of performing authorization within the Tor network is
  94. that a hidden service cannot make use of authorization data in
  95. the transported protocol. Tor hidden services were designed to be
  96. independent of the transported protocol. Therefore it's only possible to
  97. either grant or deny access to the whole service, but not to specific
  98. resources of the service.
  99. Authorization often implies authentication, i.e. proving one's identity.
  100. However, when performing authorization within the Tor network, untrusted
  101. points should not gain any useful information about the identities of
  102. communicating parties, neither server nor client. A crucial challenge is
  103. to remain anonymous towards directory servers and introduction points.
  104. However, trying to hide identity from the hidden service is a futile
  105. task, because a client would never know if he is the only authorized
  106. client and therefore perfectly identifiable. Therefore, hiding client
  107. identity from the hidden service is not aimed by this proposal.
  108. The current implementation of hidden services does not provide any kind
  109. of authorization. The hidden service descriptor version 2, introduced by
  110. proposal 114, was designed to use a descriptor cookie for downloading and
  111. decrypting parts of the descriptor content, but this feature is not yet
  112. in use. Further, most relevant cell formats specified in rend-spec
  113. contain fields for authorization data, but those fields are neither
  114. implemented nor do they suffice entirely.
  115. Details:
  116. 1. General infrastructure for authorization to hidden services
  117. We spotted three possible authorization points in the hidden service
  118. protocol:
  119. (1) when downloading and decrypting parts of the hidden service
  120. descriptor,
  121. (2) at the introduction point, and
  122. (3) at Bob's Tor client before contacting the rendezvous point.
  123. The general idea of this proposal is to allow service providers to
  124. restrict access to some or all of these points to authorized clients
  125. only.
  126. 1.1. Client authorization at directory
  127. Since the implementation of proposal 114 it is possible to combine a
  128. hidden service descriptor with a so-called descriptor cookie. If done so,
  129. the descriptor cookie becomes part of the descriptor ID, thus having an
  130. effect on the storage location of the descriptor. Someone who has learned
  131. about a service, but is not aware of the descriptor cookie, won't be able
  132. to determine the descriptor ID and download the current hidden service
  133. descriptor; he won't even know whether the service has uploaded a
  134. descriptor recently. Descriptor IDs are calculated as follows (see
  135. section 1.2 of rend-spec for the complete specification of v2 hidden
  136. service descriptors):
  137. descriptor-id =
  138. H(service-id | H(time-period | descriptor-cookie | replica))
  139. Currently, service-id is equivalent to permanent-id which is calculated
  140. as in the following formula. But in principle it could be any public
  141. key.
  142. permanent-id = H(permanent-key)[:10]
  143. The second purpose of the descriptor cookie is to encrypt the list of
  144. introduction points, including optional authorization data. Hence, the
  145. hidden service directories won't learn any introduction information from
  146. storing a hidden service descriptor. This feature is implemented but
  147. unused at the moment, so that this proposal will harness the advantages
  148. of proposal 114.
  149. The descriptor cookie can be used for authorization by keeping it secret
  150. from everyone but authorized clients. A service could then decide whether
  151. to publish hidden service descriptors using that descriptor cookie later
  152. on. An authorized client being aware of the descriptor cookie would be
  153. able to download and decrypt the hidden service descriptor.
  154. The number of concurrently used descriptor cookies for one hidden service
  155. is not restricted. A service could use a single descriptor cookie for all
  156. users, a distinct cookie per user, or something in between, like one
  157. cookie per group of users. It is up to the specific protocol and how it
  158. is applied by a service provider.
  159. Two or more hidden service descriptors for different groups or users
  160. should not be uploaded at the same time. A directory node could conclude
  161. easily that the descriptors, were issued by the same hidden service, thus
  162. being able to link the two groups or users. Therefore, descriptors for
  163. different users or clients that ought to be stored on the same directory
  164. are delayed, so that only one descriptor is uploaded to a directory at a
  165. time. The remaining descriptors are uploaded with a delay of 30 seconds.
  166. Further, descriptors for different groups or users that are to be stored
  167. on different directories are delayed for a random time of up to 30
  168. seconds to hide relations from colluding directories. Certainly, this
  169. does not prevent linking entirely, but it makes it somewhat harder.
  170. There is a conflict between hiding links between clients and making a
  171. service available in a timely manner.
  172. Although this part of the proposal is meant to describe a general
  173. infrastructure for authorization, changing the way of using the
  174. descriptor cookie to look up hidden service descriptors, e.g. applying
  175. some sort of asymmetric crypto system, would require in-depth changes
  176. that would be incompatible to v2 hidden service descriptors. On the
  177. contrary, using another key for en-/decrypting the introduction point
  178. part of a hidden service descriptor, e.g. a different symmetric key or
  179. asymmetric encryption, would be easy to implement and compatible to v2
  180. hidden service descriptors as understood by hidden service directories
  181. (clients and servers would have to be upgraded anyway for using the new
  182. features).
  183. An adversary could try to abuse the fact that introduction points can be
  184. encrypted by storing arbitrary, unrelated data in the hidden service
  185. directory. This abuse can be limited by setting a hard descriptor size
  186. limit, forcing the adversary to split data into multiple chunks. There
  187. are some limitations that make splitting data across multiple descriptors
  188. unattractive: 1) The adversary would not be able to choose descriptor IDs
  189. freely and have to implement an own indexing structure. 2) Validity of
  190. descriptors is limited to at most 24 hours after which descriptors need
  191. to be republished.
  192. The regular descriptor size in bytes is 745 + num_ipos * 837 + auth_data.
  193. A large descriptor with 7 introduction points and 5 kilobytes of
  194. authorization data would be 11724 bytes in size. The upper size limit of
  195. descriptors should be set to 20 kilobytes, which limits the effect of
  196. abuse while retaining enough flexibility in designing authorization
  197. protocols.
  198. 1.2. Client authorization at introduction point
  199. The next possible authorization point after downloading and decrypting
  200. a hidden service descriptor is the introduction point. It may be important
  201. for authorization, because it bears the last chance of hiding presence
  202. of a hidden service from unauthorized clients. Further, performing
  203. authorization at the introduction point might reduce traffic in the
  204. network, because unauthorized requests would not be passed to the
  205. hidden service. This applies to those clients who are aware of a
  206. descriptor cookie and thereby of the hidden service descriptor, but do
  207. not have authorization data to pass the introduction point or access the
  208. service (such a situation might occur when authorization data for
  209. authorization at the directory is not issued on a per-user base as
  210. opposed to authorization data for authorization at the introduction
  211. point).
  212. It is important to note that the introduction point must be considered
  213. untrustworthy, and therefore cannot replace authorization at the hidden
  214. service itself. Nor should the introduction point learn any sensitive
  215. identifiable information from either server or client.
  216. In order to perform authorization at the introduction point, three
  217. message formats need to be modified: (1) v2 hidden service descriptors,
  218. (2) ESTABLISH_INTRO cells, and (3) INTRODUCE1 cells.
  219. A v2 hidden service descriptor needs to contain authorization data that
  220. is introduction-point-specific and sometimes also authorization data
  221. that is introduction-point-independent. Therefore, v2 hidden service
  222. descriptors as specified in section 1.2 of rend-spec already contain two
  223. reserved fields "intro-authorization" and "service-authorization"
  224. (originally, the names of these fields were "...-authentication")
  225. containing an authorization type number and arbitrary authorization
  226. data. We propose that authorization data consists of base64 encoded
  227. objects of arbitrary length, surrounded by "-----BEGIN MESSAGE-----" and
  228. "-----END MESSAGE-----". This will increase the size of hidden service
  229. descriptors, which however is possible, as there is no strict upper
  230. limit.
  231. The current ESTABLISH_INTRO cells as described in section 1.3 of
  232. rend-spec do not contain either authorization data or version
  233. information. Therefore, we propose a new version 1 of the ESTABLISH_INTRO
  234. cells adding these two issues as follows:
  235. V Format byte: set to 255 [1 octet]
  236. V Version byte: set to 1 [1 octet]
  237. KL Key length [2 octets]
  238. PK Bob's public key [KL octets]
  239. HS Hash of session info [20 octets]
  240. AUTHT The auth type that is supported [1 octet]
  241. AUTHL Length of auth data [2 octets]
  242. AUTHD Auth data [variable]
  243. SIG Signature of above information [variable]
  244. From the format it is possible to determine the maximum allowed size for
  245. authorization data: given the fact that cells are 512 octets long, of
  246. which 498 octets are usable (see section 6.1 of tor-spec), and assuming
  247. 1024 bit = 128 octet long keys, there are 215 octets left for
  248. authorization data. Hence, authorization protocols are bound to use no
  249. more than these 215 octets, regardless of the number of clients that
  250. shall be authenticated at the introduction point. Otherwise, one would
  251. need to send multiple ESTABLISH_INTRO cells or split them up, what we do
  252. not specify here.
  253. In order to understand a v1 ESTABLISH_INTRO cell, the implementation of
  254. a relay must have a certain Tor version. Hidden services need to be able
  255. to distinguish relays being capable of understanding the new v1 cell
  256. formats and perform authorization. We propose to use the version number
  257. that is contained in networkstatus documents to find capable
  258. introduction points.
  259. The current INTRODUCE1 cells as described in section 1.8 of rend-spec is
  260. not designed to carry authorization data and has no version number, too.
  261. Unfortunately, unversioned INTRODUCE1 cells consist only of a fixed-size,
  262. seemingly random PK_ID, followed by the encrypted INTRODUCE2 cell. This
  263. makes it impossible to distinguish unversioned INTRODUCE1 cells from any
  264. later format. In particular, it is not possible to introduce some kind of
  265. format and version byte for newer versions of this cell. That's probably
  266. where the comment "[XXX011 want to put intro-level auth info here, but no
  267. version. crap. -RD]" that was part of rend-spec some time ago comes from.
  268. We propose that new versioned INTRODUCE1 cells use the new cell type 41
  269. RELAY_INTRODUCE1V (where V stands for versioned):
  270. Cleartext
  271. V Version byte: set to 1 [1 octet]
  272. PK_ID Identifier for Bob's PK [20 octets]
  273. AUTHT The auth type that is supported [1 octet]
  274. AUTHL Length of auth data [2 octets]
  275. AUTHD Auth data [variable]
  276. Encrypted to Bob's PK:
  277. (RELAY_INTRODUCE2 cell)
  278. The maximum length of contained authorization data depends on the length
  279. of the contained INTRODUCE2 cell. A calculation follows below when
  280. describing the INTRODUCE2 cell format we propose to use.
  281. 1.3. Client authorization at hidden service
  282. The time when a hidden service receives an INTRODUCE2 cell constitutes
  283. the last possible authorization point during the hidden service
  284. protocol. Performing authorization here is easier than at the other two
  285. authorization points, because there are no possibly untrusted entities
  286. involved.
  287. In general, a client that is successfully authorized at the introduction
  288. point should be granted access at the hidden service, too. Otherwise, the
  289. client would receive a positive INTRODUCE_ACK cell from the introduction
  290. point and conclude that it may connect to the service, but the request
  291. will be dropped without notice. This would appear as a failure to
  292. clients. Therefore, the number of cases in which a client successfully
  293. passes the introduction point, but fails at the hidden service should be
  294. zero. However, this does not lead to the conclusion, that the
  295. authorization data used at the introduction point and the hidden service
  296. must be the same, but only that both authorization data should lead to
  297. the same authorization result.
  298. Authorization data is transmitted from client to server via an
  299. INTRODUCE2 cell that is forwarded by the introduction point. There are
  300. versions 0 to 2 specified in section 1.8 of rend-spec, but none of these
  301. contains fields for carrying authorization data. We propose a slightly
  302. modified version of v3 INTRODUCE2 cells that is specified in section
  303. 1.8.1 and which is not implemented as of December 2007. In contrast to
  304. the specified v3 we avoid specifying (and implementing) IPv6 capabilities,
  305. because Tor relays will be required to support IPv4 addresses for a long
  306. time in the future, so that this seems unnecessary at the moment. The
  307. proposed format of v3 INTRODUCE2 cells is as follows:
  308. VER Version byte: set to 3. [1 octet]
  309. AUTHT The auth type that is used [1 octet]
  310. AUTHL Length of auth data [2 octets]
  311. AUTHD Auth data [variable]
  312. TS Timestamp (seconds since 1-1-1970) [4 octets]
  313. IP Rendezvous point's address [4 octets]
  314. PORT Rendezvous point's OR port [2 octets]
  315. ID Rendezvous point identity ID [20 octets]
  316. KLEN Length of onion key [2 octets]
  317. KEY Rendezvous point onion key [KLEN octets]
  318. RC Rendezvous cookie [20 octets]
  319. g^x Diffie-Hellman data, part 1 [128 octets]
  320. The maximum possible length of authorization data is related to the
  321. enclosing INTRODUCE1V cell. A v3 INTRODUCE2 cell with
  322. 1024 bit = 128 octets long public keys without any authorization data
  323. occupies 306 octets (AUTHL is only used when AUTHT has a value != 0),
  324. plus 58 octets for hybrid public key encryption (see
  325. section 5.1 of tor-spec on hybrid encryption of CREATE cells). The
  326. surrounding INTRODUCE1V cell requires 24 octets. This leaves only 110
  327. of the 498 available octets free, which must be shared between
  328. authorization data to the introduction point _and_ to the hidden
  329. service.
  330. When receiving a v3 INTRODUCE2 cell, Bob checks whether a client has
  331. provided valid authorization data to him. He also requires that the
  332. timestamp is no more than 30 minutes in the past or future and that the
  333. first part of the Diffie-Hellman handshake has not been used in the past
  334. 60 minutes to prevent replay attacks by rogue introduction points. (The
  335. reason for not using the rendezvous cookie to detect replays---even
  336. though it is only sent once in the current design---is that it might be
  337. desirable to re-use rendezvous cookies for multiple introduction requests
  338. in the future.) If all checks pass, Bob builds a circuit to the provided
  339. rendezvous point and otherwise drops the cell.
  340. 1.4. Summary of authorization data fields
  341. In summary, the proposed descriptor format and cell formats provide the
  342. following fields for carrying authorization data:
  343. (1) The v2 hidden service descriptor contains:
  344. - a descriptor cookie that is used for the lookup process, and
  345. - an arbitrary encryption schema to ensure authorization to access
  346. introduction information (currently symmetric encryption with the
  347. descriptor cookie).
  348. (2) For performing authorization at the introduction point we can use:
  349. - the fields intro-authorization and service-authorization in
  350. hidden service descriptors,
  351. - a maximum of 215 octets in the ESTABLISH_INTRO cell, and
  352. - one part of 110 octets in the INTRODUCE1V cell.
  353. (3) For performing authorization at the hidden service we can use:
  354. - the fields intro-authorization and service-authorization in
  355. hidden service descriptors,
  356. - the other part of 110 octets in the INTRODUCE2 cell.
  357. It will also still be possible to access a hidden service without any
  358. authorization or only use a part of the authorization infrastructure.
  359. However, this requires to consider all parts of the infrastructure. For
  360. example, authorization at the introduction point relying on confidential
  361. intro-authorization data transported in the hidden service descriptor
  362. cannot be performed without using an encryption schema for introduction
  363. information.
  364. 1.5. Managing authorization data at servers and clients
  365. In order to provide authorization data at the hidden server and the
  366. authenticated clients, we propose to use files---either the tor
  367. configuration file or separate files. The exact format of these special
  368. files depends on the authorization protocol used.
  369. Currently, rend-spec contains the proposition to encode client-side
  370. authorization data in the URL, like in x.y.z.onion. This was never used
  371. and is also a bad idea, because in case of HTTP the requested URL may be
  372. contained in the Host and Referer fields.
  373. 1.6. Limitations for authorization protocols
  374. There are two limitations of the current hidden service protocol for
  375. authorization protocols that shall be identified here.
  376. 1. The three cell types ESTABLISH_INTRO, INTRODUCE1V, and INTRODUCE2
  377. restricts the amount of data that can be used for authorization.
  378. This forces authorization protocols that require per-user
  379. authorization data at the introduction point to restrict the number
  380. of authorized clients artifically. A possible solution could be to
  381. split contents among multiple cells and reassemble them at the
  382. introduction points.
  383. 2. The current hidden service protocol does not specify cell types to
  384. perform interactive authorization between client and introduction
  385. point or hidden service. If there should be an authorization
  386. protocol that requires interaction, new cell types would have to be
  387. defined and integrated into the hidden service protocol.
  388. 2. Specific authorization protocol instances
  389. In the following we present three specific authorization protocols that
  390. make use of (parts of) the new authorization infrastructure:
  391. 1. The first protocol does not really perform client authorization, but
  392. requires clients to have downloaded a service descriptor before
  393. establishing a connection in order to prevent introduction points
  394. from accessing a service.
  395. 2. The second protocol allows a service provider to restrict access
  396. to clients with a previously received secret key only, but does not
  397. attempt to hide service activity from others.
  398. 3. The third protocol, albeit being feasible for a limited set of about
  399. 16 clients, performs client authorization and hides service activity
  400. from everyone but the authorized clients.
  401. These three protocol instances together are intended to replace the
  402. existing hidden service protocol versions 0 and 2 in the long run and
  403. shall therefore be considered hidden service protocol version 3. All
  404. changes in this version 3 are designed to be fully backward-compatible to
  405. version 2 and can be run in parallel to version 0.
  406. 2.1. Services without client authorization
  407. Although hidden services without client authorization could be run as
  408. before, this proposal allows us to add a new security property at almost
  409. no costs: Denying the introduction points to access the hidden service.
  410. While this constitutes a defense against rogue introduction points, it
  411. also reduces responsibility of a Tor node operator for the doings of a
  412. hidden service offering illegal or unethical contents.
  413. The original hidden service design used the service's permanent key to
  414. establish introduction points. If an introduction point wanted to access
  415. the service, it could easily download the service's descriptor using its
  416. permanent key ID and establish a connection or generate an INTRODUCE2
  417. cell itself and forward it directly to the service.
  418. Hidden service protocol version 2 made it more difficult for introduction
  419. points to find out which service they are serving. Here, the hidden
  420. service created a fresh introduction key for each introduction point
  421. which 1) did not reveal the hidden service's identity and 2) did not
  422. allow downloading the service's descriptor. However, the introduction
  423. point could still generate an INTRODUCE2 cell itself and establish a
  424. connection to the service to find out what it is serving.
  425. Beginning with this proposal can include a so-called "introduction
  426. cookie" in v2 hidden service descriptors and v3 INTRODUCE2 cells. If
  427. both, service and client implement this proposal, a service receiving a
  428. v3 INTRODUCE2 cell with an introduction cookie in it can be sure that the
  429. client has downloaded its descriptor before. As long as hidden services
  430. also permit v2 INTRODUCE2 cells, introduction points can work around this
  431. safeguard. But the earlier this protocol is introduced, the earlier the
  432. services can stop supporting version 2 introductions.
  433. A hidden service generates a unique introduction cookie for each
  434. established introduction point and puts it in the "intro-authentication"
  435. field in its descriptor for auth-type "1". Further, the service sets the
  436. "protocol-versions" field to "2,3" to announce that it understands both,
  437. requests with and without introduction cookie. Clients that understand
  438. protocol version 3 include the introduction cookie in the v3 INTRODUCE2
  439. cell as auth-type "1" that they send to the service. (Clients that don't
  440. understand the protocol v3 do not recognize the authorization data and
  441. send a v2 INTRODUCE2 cell as usual.) The hidden service can compare a
  442. received introduction cookie with the value that it expects and grant or
  443. deny service correspondingly.
  444. 2.2. Service with large-scale client authorization
  445. The first client authorization protocol aims at performing access control
  446. while consuming as little additional resources as possible. A service
  447. provider should be able to permit access to a large number of clients
  448. while denying access for everyone else. However, the price for
  449. scalability is that the service won't be able to hide its activity from
  450. unauthorized or formerly authorized clients.
  451. The main idea of this protocol is to encrypt the introduction-point part
  452. in hidden service descriptors to authorized clients using symmetric keys.
  453. This ensures that nobody else but authorized clients can learn which
  454. introduction points a service currently uses, nor can someone send a
  455. valid INTRODUCE1 message without knowing the introduction key. Therefore,
  456. a subsequent authorization at the introduction point is not required.
  457. A service provider generates symmetric "descriptor cookies" for his
  458. clients and distributes them outside of Tor. The suggested key size is
  459. 128 bits, so that descriptor cookies can be encoded in 22 base64 chars
  460. (which can hold up to 22 * 5 = 132 bits, leaving 4 bits to encode the
  461. authorization type "2" and allow a client to distinguish this
  462. authorization protocol from others like the one proposed below).
  463. Typically, the contact information for a hidden service using this
  464. authorization protocol looks like this:
  465. v2cbb2l4lsnpio4q.onion Ll3X7Xgz9eHGKCCnlFH0uz
  466. When generating a hidden service descriptor, the service encrypts the
  467. introduction-point part with a single randomly generated symmetric
  468. 128-bit session key using AES-CTR as described for v2 hidden service
  469. descriptors in rend-spec. Afterwards, the service encrypts the session
  470. key to all descriptor cookies using AES.
  471. ### What would be a simple solution to include n encrypted session keys
  472. ### in the descriptor? The format may be binary and has no strict upper
  473. ### size limit. An authorized client should be able to efficiently find
  474. ### the session key that is encrypted for him/her. It should be
  475. ### impossible to track certain authorized clients over time by finding
  476. ### that the session key was encrypted for them in different descriptors.
  477. ### It should be hard to determine the exact number of authorized
  478. ### clients.
  479. ###
  480. ### Here comes the voodoo I've conceived:
  481. ###
  482. ### ATYPE Authorization type: set to 2. [1 octet]
  483. ### ALEN Number of authorized clients div 16 [1 octet]
  484. ### for each symmetric descriptor cookie:
  485. ### ID Client ID: H(descriptor cookie | IV)[:4] [4 octets]
  486. ### SKEY Session key encrypted with descriptor cookie [16 octets]
  487. ### (end of client-specific part)
  488. ### RND Random data [(16 - (number-of-clients mod 16)) * 20 octets]
  489. ### IV AES initialization vector [16 octets]
  490. ### IPOS Intro points, encrypted with session key [remaining octets]
  491. An authorized client needs to configure Tor to use the descriptor cookie
  492. when accessing the hidden service. Therefore, a user adds the contact
  493. information that she received from the service provider to her torrc
  494. file. Upon downloading a hidden service descriptor, Tor finds the
  495. encrypted introduction-point part and attempts to decrypt it using the
  496. configured descriptor cookie. (In the rare event of two or more client
  497. IDs being equal a client tries to decrypt all of them.)
  498. Upon sending the introduction, the client includes her descriptor cookie
  499. as auth type "2" in the INTRODUCE2 cell that she sends to the service.
  500. The hidden service checks whether the included descriptor cookie is
  501. authorized to access the service and either responds to the introduction
  502. request, or not.
  503. 2.3. Authorization for limited number of clients
  504. A second, more sophisticated client authorization protocol goes the extra
  505. mile of hiding service activity from unauthorized clients. With all else
  506. being equal to the preceding authorization protocol, the second protocol
  507. publishes hidden service descriptors for each user separately and gets
  508. along with encrypting the introduction-point part of descriptors to a
  509. single client. This allows the service to stop publishing descriptors for
  510. removed clients. As long as a removed client cannot link descriptors
  511. issued for other clients to the service, it cannot derive service
  512. activity any more. The downside of this approach is limited scalability.
  513. Even though the distributed storage of descriptors (cf. proposal 114)
  514. tackles the problem of limited scalability to a certain extent, this
  515. protocol should not be used for services with more than 16 clients. (In
  516. fact, Tor should refuse to advertise services for more than this number
  517. of clients.)
  518. A hidden service generates an asymmetric "client key" and a symmetric
  519. "descriptor cookie" for each client. The client key is used as
  520. replacement for the service's permanent key, so that the service uses a
  521. different identity for each of his clients. The descriptor cookie is used
  522. to store descriptors at changing directory nodes that are unpredictable
  523. for anyone but service and client, to encrypt the introduction-point
  524. part, and to be included in INTRODUCE2 cells. Once the service has
  525. created client key and descriptor cookie, he tells them to the client
  526. outside of Tor. The contact information string looks similar to the one
  527. used by the preceding authorization protocol (with the only difference
  528. that it has "3" encoded as auth-type in the remaining 4 of 132 bits
  529. instead of "2" as before).
  530. When creating a hidden service descriptor for an authorized client, the
  531. hidden service uses the client key and descriptor cookie to compute
  532. secret ID part and descriptor ID:
  533. secret-id-part = H(time-period | descriptor-cookie | replica)
  534. descriptor-id = H(client-key[:10] | secret-id-part)
  535. The hidden service also replaces permanent-key in the descriptor with
  536. client-key and encrypts introduction-points with the descriptor cookie.
  537. ATYPE Authorization type: set to 3. [1 octet]
  538. IV AES initialization vector [16 octets]
  539. IPOS Intro points, encr. with descriptor cookie [remaining octets]
  540. When uploading descriptors, the hidden service needs to make sure that
  541. descriptors for different clients are not uploaded at the same time (cf.
  542. Section 1.1) which is also a limiting factor for the number of clients.
  543. When a client is requested to establish a connection to a hidden service
  544. it looks up whether it has any authorization data configured for that
  545. service. If the user has configured authorization data for authorization
  546. protocol "3", the descriptor ID is determined as described in the last
  547. paragraph. Upon receiving a descriptor, the client decrypts the
  548. introduction-point part using its descriptor cookie. Further, the client
  549. includes its descriptor cookie as auth-type "3" in INTRODUCE2 cells that
  550. it sends to the service.
  551. 2.4. Hidden service configuration
  552. A hidden service that implements this proposal and that is meant to use
  553. the new protocols (including the protocol without client authorization as
  554. described in 2.1) adds version 3 to the list of supported hidden service
  555. protocols:
  556. HiddenServiceVersion version,version,... (Default: 0, 2, 3)
  557. If the service shall perform client authorization, another config option
  558. is set to either "1" for the protocol described in 2.2 or "2" for the
  559. protocol in 2.3 (auth type numbers differ from the internally used
  560. numbers primarily to avoid user questions about the whereabouts of auth
  561. type 1). This config option also includes a comma-separated list of
  562. human-readable client names, so that Tor can create authorization data
  563. for these clients:
  564. HiddenServiceAuthorizeClient auth-type client-name,client-name,...
  565. If this option is configured, HiddenServiceVersion is automatically
  566. reconfigured to contain only version numbers of 3 or higher. If this
  567. config option is not set but the configured hidden service version
  568. includes 3, the protocol without client authorization as described in 2.1
  569. is offered to clients (possibly in parallel to versions 0 and 2).
  570. Tor stores all generated authorization data for the authorization
  571. protocols described in Sections 2.2 and 2.3 in a new file using the
  572. following file format:
  573. "client-name" human-readable client identifier NL
  574. "descriptor-cookie" 128-bit key ^= 22 base64 chars NL
  575. If the authorization protocol of Section 2.3 is used, Tor also generates
  576. and stores the following data:
  577. "service-address" client-specific-onion-address NL
  578. "client-key" NL a public key in PEM format
  579. 2.5. Client configuration
  580. Clients need to make their authorization data known to Tor using another
  581. configuration option that contains a service name (mainly for the sake of
  582. convenience), the service address, and the descriptor cookie that is
  583. required to access a hidden service (the authorization protocol number is
  584. encoded in the descriptor cookie):
  585. HidServAuth service-name service-address descriptor-cookie
  586. Security implications:
  587. In the following we want to discuss possible attacks by dishonest
  588. entities in the presented infrastructure and specific protocol. These
  589. security implications would have to be verified once more when adding
  590. another protocol. The dishonest entities (theoretically) include the
  591. hidden server itself, the authenticated clients, hidden service directory
  592. nodes, introduction points, and rendezvous points. The relays that are
  593. part of circuits used during protocol execution, but never learn about
  594. the exchanged descriptors or cells by design, are not considered.
  595. Obviously, this list makes no claim to be complete. The discussed attacks
  596. are sorted by the difficulty to perform them, in ascending order,
  597. starting with roles that everyone could attempt to take and ending with
  598. partially trusted entities abusing the trust put in them.
  599. (1) A hidden service directory could attempt to conclude presence of a
  600. server from the existence of a locally stored hidden service descriptor:
  601. This passive attack is possible only for a single client-service
  602. relation, because descriptors need to contain a
  603. publicly visible signature of the server using the client key
  604. A possible protection
  605. would be to increase the number of hidden service directories in the
  606. network.
  607. (2) A hidden service directory could try to break the descriptor cookies
  608. of locally stored descriptors: This attack can be performed offline. The
  609. only useful countermeasure against it might be using safe passwords that
  610. are generated by Tor.
  611. (3) An introduction point could try to identify the pseudonym of the
  612. hidden service on behalf of which it operates: This is impossible by
  613. design, because the service uses a fresh public key for every
  614. establishment of an introduction point (see proposal 114) and the
  615. introduction point receives a fresh introduction cookie, so that there is
  616. no identifiable information about the service that the introduction point
  617. could learn. The introduction point cannot even tell if client accesses
  618. belong to the same client or not, nor can it know the total number of
  619. authorized clients. The only information might be the pattern of
  620. anonymous client accesses, but that is hardly enough to reliably identify
  621. a specific service.
  622. (4) An introduction point could want to learn the identities of accessing
  623. clients: This is also impossible by design, because all clients use the
  624. same introduction cookie for authorization at the introduction point.
  625. (5) An introduction point could try to replay a correct INTRODUCE1 cell
  626. to other introduction points of the same service, e.g. in order to force
  627. the service to create a huge number of useless circuits: This attack is
  628. not possible by design, because INTRODUCE1 cells are encrypted using a
  629. freshly created introduction key that is only known to authorized
  630. clients.
  631. (6) An introduction point could attempt to replay a correct INTRODUCE2
  632. cell to the hidden service, e.g. for the same reason as in the last
  633. attack: This attack is very limited by the fact that a server will only
  634. accept 3 INTRODUCE2 cells containing the same rendezvous cookie and drop
  635. all further replayed cells.
  636. (7) An introduction point could block client requests by sending either
  637. positive or negative INTRODUCE_ACK cells back to the client, but without
  638. forwarding INTRODUCE2 cells to the server: This attack is an annoyance
  639. for clients, because they might wait for a timeout to elapse until trying
  640. another introduction point. However, this attack is not introduced by
  641. performing authorization and it cannot be targeted towards a specific
  642. client. A countermeasure might be for the server to periodically perform
  643. introduction requests to his own service to see if introduction points
  644. are working correctly.
  645. (8) The rendezvous point could attempt to identify either server or
  646. client: This remains impossible as it was before, because the
  647. rendezvous cookie does not contain any identifiable information.
  648. (9) An authenticated client could swamp the server with valid INTRODUCE1
  649. and INTRODUCE2 cells, e.g. in order to force the service to create
  650. useless circuits to rendezvous points; as opposed to an introduction
  651. point replaying the same INTRODUCE2 cell, a client could include a new
  652. rendezvous cookie for every request: The countermeasure for this attack
  653. is the restriction to 10 connection establishments per client and hour.
  654. Compatibility:
  655. An implementation of this proposal would require changes to hidden
  656. servers and clients to process authorization data and encode and
  657. understand the new formats. However, both servers and clients would
  658. remain compatible to regular hidden services without authorization.
  659. Implementation:
  660. The implementation of this proposal can be divided into a number of
  661. changes to hidden service and client side. There are no
  662. changes necessary on directory, introduction, or rendezvous nodes. All
  663. changes are marked with either [service] or [client] do denote on which
  664. side they need to be made.
  665. /1/ Configure client authorization [service]
  666. - Parse configuration option HiddenServiceAuthorizeClient containing
  667. authorized client names.
  668. - Load previously created client keys and descriptor cookies.
  669. - Generate missing client keys and descriptor cookies, add them to
  670. client_keys file.
  671. - Rewrite the hostname file.
  672. - Keep client keys and descriptor cookies of authorized clients in
  673. memory.
  674. [- In case of reconfiguration, mark which client authorizations were
  675. added and whether any were removed. This can be used later when
  676. deciding whether to rebuild introduction points and publish new
  677. hidden service descriptors. Not implemented yet.]
  678. /2/ Publish hidden service descriptors [service]
  679. - Create and upload hidden service descriptors for all authorized
  680. clients.
  681. [- See /1/ for the case of reconfiguration.]
  682. /3/ Configure permission for hidden services [client]
  683. - Parse configuration option HidServAuth containing service
  684. authorization, store authorization data in memory.
  685. /5/ Fetch hidden service descriptors [client]
  686. - Look up client authorization upon receiving a hidden service request.
  687. - Request hidden service descriptor ID including client key and
  688. descriptor cookie. Only request v2 descriptors, no v0.
  689. /6/ Process hidden service descriptor [client]
  690. - Decrypt introduction points with descriptor cookie.
  691. /7/ Create introduction request [client]
  692. - Include descriptor cookie in INTRODUCE2 cell to introduction point.
  693. - Pass descriptor cookie around between involved connections and
  694. circuits.
  695. /8/ Process introduction request [service]
  696. - Read descriptor cookie from INTRODUCE2 cell.
  697. - Check whether descriptor cookie is authorized for access, including
  698. checking access counters.
  699. - Log access for accountability.