117-ipv6-exits.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. Filename: 117-ipv6-exits.txt
  2. Title: IPv6 exits
  3. Version: $Revision$
  4. Last-Modified: $Date$
  5. Author: coderman
  6. Created: 10-Jul-2007
  7. Status: Accepted
  8. Target: 0.2.1.x
  9. Overview
  10. Extend Tor for TCP exit via IPv6 transport and DNS resolution of IPv6
  11. addresses. This proposal does not imply any IPv6 support for OR
  12. traffic, only exit and name resolution.
  13. Contents
  14. 0. Motivation
  15. As the IPv4 address space becomes more scarce there is increasing
  16. effort to provide Internet services via the IPv6 protocol. Many
  17. hosts are available at IPv6 endpoints which are currently
  18. inaccessible for Tor users.
  19. Extending Tor to support IPv6 exit streams and IPv6 DNS name
  20. resolution will allow users of the Tor network to access these hosts.
  21. This capability would be present for those who do not currently have
  22. IPv6 access, thus increasing the utility of Tor and furthering
  23. adoption of IPv6.
  24. 1. Design
  25. 1.1. General design overview
  26. There are three main components to this proposal. The first is a
  27. method for routers to advertise their ability to exit IPv6 traffic.
  28. The second is the manner in which routers resolve names to IPv6
  29. addresses. Last but not least is the method in which clients
  30. communicate with Tor to resolve and connect to IPv6 endpoints
  31. anonymously.
  32. 1.2. Router IPv6 exit support
  33. In order to specify exit policies and IPv6 capability new directives
  34. in the Tor configuration will be needed. If a router advertises IPv6
  35. exit policies in its descriptor this will signal the ability to
  36. provide IPv6 exit. There are a number of additional default deny
  37. rules associated with this new address space which are detailed in
  38. the addendum.
  39. When Tor is started on a host it should check for the presence of a
  40. global unicast IPv6 address and if present include the default IPv6
  41. exit policies and any user specified IPv6 exit policies.
  42. If a user provides IPv6 exit policies but no global unicast IPv6
  43. address is available Tor should generate a warning and not publish the
  44. IPv6 policies in the router descriptor.
  45. It should be noted that IPv4 mapped IPv6 addresses are not valid exit
  46. destinations. This mechanism is mainly used to interoperate with
  47. both IPv4 and IPv6 clients on the same socket. Any attempts to use
  48. an IPv4 mapped IPv6 address, perhaps to circumvent exit policy for
  49. IPv4, must be refused.
  50. 1.3. DNS name resolution of IPv6 addresses (AAAA records)
  51. In addition to exit support for IPv6 TCP connections, a method to
  52. resolve domain names to their respective IPv6 addresses is also
  53. needed. This is accomplished in the existing DNS system via AAAA
  54. records. Routers will perform both A and AAAA requests when
  55. resolving a name so that the client can utilize an IPv6 endpoint when
  56. available or preferred.
  57. To avoid potential problems with caching DNS servers that behave
  58. poorly all NXDOMAIN responses to AAAA requests should be ignored if a
  59. successful response is received for an A request. This implies that
  60. both AAAA and A requests will always be performed for each name
  61. resolution.
  62. For reverse lookups on IPv6 addresses, like that used for
  63. RESOLVE_PTR, Tor will perform the necessary PTR requests via
  64. IP6.ARPA.
  65. All routers which perform DNS resolution on behalf of clients
  66. (RELAY_RESOLVE) should perform and respond with both A and AAAA
  67. resources.
  68. [NOTE: In a future version, when we extend the behavior of RESOLVE to
  69. encapsulate more of real DNS, it will make sense to allow more
  70. flexibility here. -nickm]
  71. 1.4. Client interaction with IPv6 exit capability
  72. 1.4.1. Usability goals
  73. There are a number of behaviors which Tor can provide when
  74. interacting with clients that will improve the usability of IPv6 exit
  75. capability. These behaviors are designed to make it simple for
  76. clients to express a preference for IPv6 transport and utilize IPv6
  77. host services.
  78. 1.4.2. SOCKSv5 IPv6 client behavior
  79. The SOCKS version 5 protocol supports IPv6 connections. When using
  80. SOCKSv5 with hostnames it is difficult to determine if a client
  81. wishes to use an IPv4 or IPv6 address to connect to the desired host
  82. if it resolves to both address types.
  83. In order to make this more intuitive the SOCKSv5 protocol can be
  84. supported on a local IPv6 endpoint, [::1] port 9050 for example.
  85. When a client requests a connection to the desired host via an IPv6
  86. SOCKS connection Tor will prefer IPv6 addresses when resolving the
  87. host name and connecting to the host.
  88. Likewise, RESOLVE and RESOLVE_PTR requests from an IPv6 SOCKS
  89. connection will return IPv6 addresses when available, and fall back
  90. to IPv4 addresses if not.
  91. [NOTE: This means that SocksListenAddress and DNSListenAddress should
  92. support IPv6 addresses. Perhaps there should also be a general option
  93. to have listeners that default to 127.0.0.1 and 0.0.0.0 listen
  94. additionally or instead on ::1 and :: -nickm]
  95. 1.4.3. MAPADDRESS behavior
  96. The MAPADDRESS capability supports clients that may not be able to
  97. use the SOCKSv4a or SOCKSv5 hostname support to resolve names via
  98. Tor. This ability should be extended to IPv6 addresses in SOCKSv5 as
  99. well.
  100. When a client requests an address mapping from the wildcard IPv6
  101. address, [::0], the server will respond with a unique local IPv6
  102. address on success. It is important to note that there may be two
  103. mappings for the same name if both an IPv4 and IPv6 address are
  104. associated with the host. In this case a CONNECT to a mapped IPv6
  105. address should prefer IPv6 for the connection to the host, if
  106. available, while CONNECT to a mapped IPv4 address will prefer IPv4.
  107. It should be noted that IPv6 does not provide the concept of a host
  108. local subnet, like 127.0.0.0/8 in IPv4. For this reason integration
  109. of Tor with IPv6 clients should consider a firewall or filter rule to
  110. drop unique local addresses to or from the network when possible.
  111. These packets should not be routed, however, keeping them off the
  112. subnet entirely is worthwhile.
  113. 1.4.3.1. Generating unique local IPv6 addresses
  114. The usual manner of generating a unique local IPv6 address is to
  115. select a Global ID part randomly, along with a Subnet ID, and sharing
  116. this prefix among the communicating parties who each have their own
  117. distinct Interface ID. In this style a given Tor instance might
  118. select a random Global and Subnet ID and provide MAPADDRESS
  119. assignments with a random Interface ID as needed. This has the
  120. potential to associate unique Global/Subnet identifiers with a given
  121. Tor instance and may expose attacks against the anonymity of Tor
  122. users.
  123. Tor avoid this potential problem entirely MAPADDRESS must always
  124. generate the Global, Subnet, and Interface IDs randomly for each
  125. request. It is also highly suggested that explicitly specifying an
  126. IPv6 source address instead of the wildcard address not be supported
  127. to ensure that a good random address is used.
  128. 1.4.4. DNSProxy IPv6 client behavior
  129. A new capability in recent Tor versions is the transparent DNS proxy.
  130. This feature will need to return both A and AAAA resource records
  131. when responding to client name resolution requests.
  132. The transparent DNS proxy should also support reverse lookups for
  133. IPv6 addresses. It is suggested that any such requests to the
  134. deprecated IP6.INT domain should be translated to IP6.ARPA instead.
  135. This translation is not likely to be used and is of low priority.
  136. It would be nice to support DNS over IPv6 transport as well, however,
  137. this is not likely to be used and is of low priority.
  138. 1.4.5. TransPort IPv6 client behavior
  139. Tor also provides transparent TCP proxy support via the Trans*
  140. directives in the configuration. The TransListenAddress directive
  141. should accept an IPv6 address in addition to IPv4 so that IPv6 TCP
  142. connections can be transparently proxied.
  143. 1.5. Additional changes
  144. The RedirectExit option should be deprecated rather than extending
  145. this feature to IPv6.
  146. 2. Spec changes
  147. 2.1. Tor specification
  148. In '6.2. Opening streams and transferring data' the following should
  149. be changed to indicate IPv6 exit capability:
  150. "No version of Tor currently generates the IPv6 format."
  151. In '6.4. Remote hostname lookup' the following should be updated to
  152. reflect use of ip6.arpa in addition to in-addr.arpa.
  153. "For a reverse lookup, the OP sends a RELAY_RESOLVE cell containing an
  154. in-addr.arpa address."
  155. In 'A.1. Differences between spec and implementation' the following
  156. should be updated to indicate IPv6 exit capability:
  157. "The current codebase has no IPv6 support at all."
  158. [NOTE: the EXITPOLICY end-cell reason says that it can hold an ipv4 or an
  159. ipv6 address, but doesn't say how. We may want a separate EXITPOLICY2
  160. type that can hold an ipv6 address, since the way we encode ipv6
  161. addresses elsewhere ("0.0.0.0 indicates that the next 16 bytes are ipv6")
  162. is a bit dumb. -nickm]
  163. [Actually, the length field lets us distinguish EXITPOLICY. -nickm]
  164. 2.2. Directory specification
  165. In '2.1. Router descriptor format' a new set of directives is needed
  166. for IPv6 exit policy. The existing accept/reject directives should
  167. be clarified to indicate IPv4 or wildcard address relevance. The new
  168. IPv6 directives will be in the form of:
  169. "accept6" exitpattern NL
  170. "reject6" exitpattern NL
  171. The section describing accept6/reject6 should explain that the
  172. presence of accept6 or reject6 exit policies in a router descriptor
  173. signals the ability of that router to exit IPv6 traffic (according to
  174. IPv6 exit policies).
  175. The "[::]/0" notation is used to represent "all IPv6 addresses".
  176. "[::0]/0" may also be used for this representation.
  177. If a user specifies a 'reject6 [::]/0:*' policy in the Tor
  178. configuration this will be interpreted as forcing no IPv6 exit
  179. support and no accept6/reject6 policies will be included in the
  180. published descriptor. This will prevent IPv6 exit if the router host
  181. has a global unicast IPv6 address present.
  182. It is important to note that a wildcard address in an accept or
  183. reject policy applies to both IPv4 and IPv6 addresses.
  184. 2.3. Control specification
  185. In '3.8. MAPADDRESS' the potential to have to addresses for a given
  186. name should be explained. The method for generating unique local
  187. addresses for IPv6 mappings needs explanation as described above.
  188. When IPv6 addresses are used in this document they should include the
  189. brackets for consistency. For example, the null IPv6 address should
  190. be written as "[::0]" and not "::0". The control commands will
  191. expect the same syntax as well.
  192. In '3.9. GETINFO' the "address" command should return both public
  193. IPv4 and IPv6 addresses if present. These addresses should be
  194. separated via \r\n.
  195. 2.4. Tor SOCKS extensions
  196. In '2. Name lookup' a description of IPv6 address resolution is
  197. needed for SOCKSv5 as described above. IPv6 addresses should be
  198. supported in both the RESOLVE and RESOLVE_PTR extensions.
  199. A new section describing the ability to accept SOCKSv5 clients on a
  200. local IPv6 address to indicate a preference for IPv6 transport as
  201. described above is also needed. The behavior of Tor SOCKSv5 proxy
  202. with an IPv6 preference should be explained, for example, preferring
  203. IPv6 transport to a named host with both IPv4 and IPv6 addresses
  204. available (A and AAAA records).
  205. 3. Questions and concerns
  206. 3.1. DNS A6 records
  207. A6 is explicitly avoided in this document. There are potential
  208. reasons for implementing this, however, the inherent complexity of
  209. the protocol and resolvers make this unappealing. Is there a
  210. compelling reason to consider A6 as part of IPv6 exit support?
  211. [IMO not till anybody needs it. -nickm]
  212. 3.2. IPv4 and IPv6 preference
  213. The design above tries to infer a preference for IPv4 or IPv6
  214. transport based on client interactions with Tor. It might be useful
  215. to provide more explicit control over this preference. For example,
  216. an IPv4 SOCKSv5 client may want to use IPv6 transport to named hosts
  217. in CONNECT requests while the current implementation would assume an
  218. IPv4 preference. Should more explicit control be available, through
  219. either configuration directives or control commands?
  220. Many applications support a inet6-only or prefer-family type option
  221. that provides the user manual control over address preference. This
  222. could be provided as a Tor configuration option.
  223. An explicit preference is still possible by resolving names and then
  224. CONNECTing to an IPv4 or IPv6 address as desired, however, not all
  225. client applications may have this option available.
  226. 3.3. Support for IPv6 only transparent proxy clients
  227. It may be useful to support IPv6 only transparent proxy clients using
  228. IPv4 mapped IPv6 like addresses. This would require transparent DNS
  229. proxy using IPv6 transport and the ability to map A record responses
  230. into IPv4 mapped IPv6 like addresses in the manner described in the
  231. "NAT-PT" RFC for a traditional Basic-NAT-PT with DNS-ALG. The
  232. transparent TCP proxy would thus need to detect these mapped addresses
  233. and connect to the desired IPv4 host.
  234. The IPv6 prefix used for this purpose must not be the actual IPv4
  235. mapped IPv6 address prefix, though the manner in which IPv4 addresses
  236. are embedded in IPv6 addresses would be the same.
  237. The lack of any IPv6 only hosts which would use this transparent proxy
  238. method makes this a lot of work for very little gain. Is there a
  239. compelling reason to support this NAT-PT like capability?
  240. 3.4. IPv6 DNS and older Tor routers
  241. It is expected that many routers will continue to run with older
  242. versions of Tor when the IPv6 exit capability is released. Clients
  243. who wish to use IPv6 will need to route RELAY_RESOLVE requests to the
  244. newer routers which will respond with both A and AAAA resource
  245. records when possible.
  246. One way to do this is to route RELAY_RESOLVE requests to routers with
  247. IPv6 exit policies published, however, this would not utilize current
  248. routers that can resolve IPv6 addresses even if they can't exit such
  249. traffic.
  250. There was also concern expressed about the ability of existing clients
  251. to cope with new RELAY_RESOLVE responses that contain IPv6 addresses.
  252. If this breaks backward compatibility, a new request type may be
  253. necessary, like RELAY_RESOLVE6, or some other mechanism of indicating
  254. the ability to parse IPv6 responses when making the request.
  255. 3.5. IPv4 and IPv6 bindings in MAPADDRESS
  256. It may be troublesome to try and support two distinct address mappings
  257. for the same name in the existing MAPADDRESS implementation. If this
  258. cannot be accommodated then the behavior should replace existing
  259. mappings with the new address regardless of family. A warning when
  260. this occurs would be useful to assist clients who encounter problems
  261. when both an IPv4 and IPv6 application are using MAPADDRESS for the
  262. same names concurrently, causing lost connections for one of them.
  263. 4. Addendum
  264. 4.1. Sample IPv6 default exit policy
  265. reject 0.0.0.0/8
  266. reject 169.254.0.0/16
  267. reject 127.0.0.0/8
  268. reject 192.168.0.0/16
  269. reject 10.0.0.0/8
  270. reject 172.16.0.0/12
  271. reject6 [0000::]/8
  272. reject6 [0100::]/8
  273. reject6 [0200::]/7
  274. reject6 [0400::]/6
  275. reject6 [0800::]/5
  276. reject6 [1000::]/4
  277. reject6 [4000::]/3
  278. reject6 [6000::]/3
  279. reject6 [8000::]/3
  280. reject6 [A000::]/3
  281. reject6 [C000::]/3
  282. reject6 [E000::]/4
  283. reject6 [F000::]/5
  284. reject6 [F800::]/6
  285. reject6 [FC00::]/7
  286. reject6 [FE00::]/9
  287. reject6 [FE80::]/10
  288. reject6 [FEC0::]/10
  289. reject6 [FF00::]/8
  290. reject *:25
  291. reject *:119
  292. reject *:135-139
  293. reject *:445
  294. reject *:1214
  295. reject *:4661-4666
  296. reject *:6346-6429
  297. reject *:6699
  298. reject *:6881-6999
  299. accept *:*
  300. # accept6 [2000::]/3:* is implied
  301. 4.2. Additional resources
  302. 'DNS Extensions to Support IP Version 6'
  303. http://www.ietf.org/rfc/rfc3596.txt
  304. 'DNS Extensions to Support IPv6 Address Aggregation and Renumbering'
  305. http://www.ietf.org/rfc/rfc2874.txt
  306. 'SOCKS Protocol Version 5'
  307. http://www.ietf.org/rfc/rfc1928.txt
  308. 'Unique Local IPv6 Unicast Addresses'
  309. http://www.ietf.org/rfc/rfc4193.txt
  310. 'INTERNET PROTOCOL VERSION 6 ADDRESS SPACE'
  311. http://www.iana.org/assignments/ipv6-address-space
  312. 'Network Address Translation - Protocol Translation (NAT-PT)'
  313. http://www.ietf.org/rfc/rfc2766.txt