117-ipv6-exits.txt 16 KB

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