| 1 | <?xml version="1.0" encoding="utf-8" ?> |
|---|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|---|
| 4 | <head> |
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 6 | <meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" /> |
|---|
| 7 | <title></title> |
|---|
| 8 | <link rel="stylesheet" href="../css/bep.css" type="text/css" /> |
|---|
| 9 | </head> |
|---|
| 10 | <body> |
|---|
| 11 | <div class="document"> |
|---|
| 12 | |
|---|
| 13 | <div id="upper" class="clear"> |
|---|
| 14 | <div id="wrap"> |
|---|
| 15 | <div id="header"> |
|---|
| 16 | <h1><a href="../index.html">BitTorrent<span>.org</span></a></h1> |
|---|
| 17 | </div> |
|---|
| 18 | <div id="nav"> |
|---|
| 19 | <ul> |
|---|
| 20 | <li><a href="../index.html">Home</a></li> |
|---|
| 21 | <li><a href="../introduction.html">For Users</a></li> |
|---|
| 22 | <li><a href="bep_0000.html"><span>For Developers</span></a></li> |
|---|
| 23 | <!-- <li><a href="./blog">Blog</a></li> --> |
|---|
| 24 | <li><a href="http://forum.bittorrent.org"> Forums </li> |
|---|
| 25 | <li><a href="../donate.html">Donate!</a></li> |
|---|
| 26 | </ul> |
|---|
| 27 | </div> <!-- nav --> |
|---|
| 28 | <!-- ### Begin Content ### --> |
|---|
| 29 | <div id="second"> |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | <table class="rfc2822 docutils field-list" frame="void" rules="none"> |
|---|
| 34 | <col class="field-name" /> |
|---|
| 35 | <col class="field-body" /> |
|---|
| 36 | <tbody valign="top"> |
|---|
| 37 | <tr class="field"><th class="field-name">BEP:</th><td class="field-body">8</td> |
|---|
| 38 | </tr> |
|---|
| 39 | <tr class="field"><th class="field-name">Title:</th><td class="field-body">Tracker Peer Obfuscation</td> |
|---|
| 40 | </tr> |
|---|
| 41 | <tr class="field"><th class="field-name">Version:</th><td class="field-body">11049</td> |
|---|
| 42 | </tr> |
|---|
| 43 | <tr class="field"><th class="field-name">Last-Modified:</th><td class="field-body"><a class="reference external" href="http://bittorrent.org/trac/browser/dotorg/trunk/html/beps/bep_0008.rst">2008-04-29 18:09:14 -0700 (Tue, 29 Apr 2008)</a></td> |
|---|
| 44 | </tr> |
|---|
| 45 | <tr class="field"><th class="field-name">Author:</th><td class="field-body">David Harrison <dave at bittorrent.com>, Anthony Ciani <tony at ciani.phy.uic.edu>, Arvid Norberg <arvid at bittorrent.com>, Greg Hazel <greg at bittorrent.com></td> |
|---|
| 46 | </tr> |
|---|
| 47 | <tr class="field"><th class="field-name">Status:</th><td class="field-body">Deferred</td> |
|---|
| 48 | </tr> |
|---|
| 49 | <tr class="field"><th class="field-name">Type:</th><td class="field-body">Standards Track</td> |
|---|
| 50 | </tr> |
|---|
| 51 | <tr class="field"><th class="field-name">Created:</th><td class="field-body">31-Jan-2008</td> |
|---|
| 52 | </tr> |
|---|
| 53 | <tr class="field"><th class="field-name">Post-History:</th><td class="field-body"></td> |
|---|
| 54 | </tr> |
|---|
| 55 | </tbody> |
|---|
| 56 | </table> |
|---|
| 57 | <hr /> |
|---|
| 58 | <div class="contents topic" id="contents"> |
|---|
| 59 | <p class="topic-title first">Contents</p> |
|---|
| 60 | <ul class="simple"> |
|---|
| 61 | <li><a class="reference internal" href="#announce" id="id8">Announce</a></li> |
|---|
| 62 | <li><a class="reference internal" href="#announce-response" id="id9">Announce Response</a></li> |
|---|
| 63 | <li><a class="reference internal" href="#obfuscation-method" id="id10">Obfuscation Method</a></li> |
|---|
| 64 | <li><a class="reference internal" href="#optimizations" id="id11">Optimizations</a></li> |
|---|
| 65 | <li><a class="reference internal" href="#backwards-compatibility" id="id12">Backwards Compatibility</a></li> |
|---|
| 66 | <li><a class="reference internal" href="#rationale" id="id13">Rationale</a></li> |
|---|
| 67 | <li><a class="reference internal" href="#references" id="id14">References</a></li> |
|---|
| 68 | <li><a class="reference internal" href="#example-python-code" id="id15">Example Python Code</a></li> |
|---|
| 69 | <li><a class="reference internal" href="#copyright" id="id16">Copyright</a></li> |
|---|
| 70 | </ul> |
|---|
| 71 | </div> |
|---|
| 72 | <p>This extends the tracker protocol to support simple obfuscation of the |
|---|
| 73 | peers it returns, using the infohash as a shared secret between the |
|---|
| 74 | peer and the tracker. The obfuscation does not provide any security |
|---|
| 75 | against eavesdroppers that know the infohash of the torrent. The goal |
|---|
| 76 | is to prevent internet service providers and other network |
|---|
| 77 | administrators from blocking or disrupting bittorrent traffic |
|---|
| 78 | connections that span between the receiver of a tracker response and |
|---|
| 79 | any peer IP-port appearing in that tracker response.</p> |
|---|
| 80 | <p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", |
|---|
| 81 | "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are |
|---|
| 82 | to be interpreted as described in IETF <a class="reference external" href="http://tools.ietf.org/html/rfc2119">RFC 2119</a> <a class="footnote-reference" href="#id6" id="id7">[5]</a>.</p> |
|---|
| 83 | <div class="section" id="announce"> |
|---|
| 84 | <h1>Announce</h1> |
|---|
| 85 | <p>When using this extension, instead of passing the <tt class="docutils literal"><span class="pre">info_hash</span></tt> parameter |
|---|
| 86 | to the tracker, a <tt class="docutils literal"><span class="pre">sha_ih</span></tt> is passed.</p> |
|---|
| 87 | <p>The value of <tt class="docutils literal"><span class="pre">sha_ih</span></tt> MUST be the info-hash of the torrent, with a second |
|---|
| 88 | SHA-1 applied to it.</p> |
|---|
| 89 | <p>For example if a torrent has infohash with hex representation |
|---|
| 90 | <tt class="docutils literal"><span class="pre">aaf4c61ddcc5e8a2dabedef3b482cd9aea9434d</span></tt> then its <tt class="docutils literal"><span class="pre">sha_ih</span></tt> is |
|---|
| 91 | <tt class="docutils literal"><span class="pre">sha1(infohash)='6b4f89a54e2d27ecd7e8da5b4ab8fd9d1d8b119'</span></tt>.</p> |
|---|
| 92 | <p>The value MUST be url encoded, just like the <tt class="docutils literal"><span class="pre">info_hash</span></tt>. Thus the |
|---|
| 93 | <tt class="docutils literal"><span class="pre">sha_ih</span></tt> above when url encoded becomes |
|---|
| 94 | <tt class="docutils literal"><span class="pre">kO%89%A5N-%27%EC%D7%E8%DA%05%B4%AB%8F%D9%D1%D8%B1%19</span></tt>.</p> |
|---|
| 95 | <p>If the <tt class="docutils literal"><span class="pre">sha_ih</span></tt> is passed then the value for the <tt class="docutils literal"><span class="pre">port</span></tt> parameter |
|---|
| 96 | should be treated as a 16 bit integer and MUST be obscured as |
|---|
| 97 | described in the <a class="reference internal" href="#obfuscation-method">Obfuscation Method</a> section. Similarly if the |
|---|
| 98 | optional <tt class="docutils literal"><span class="pre">ip</span></tt> parameter is passed in the announce then its value |
|---|
| 99 | MUST also be so obscured.</p> |
|---|
| 100 | <p>This extension does not change the semantics of any parameter passed |
|---|
| 101 | in the peer's announce.</p> |
|---|
| 102 | </div> |
|---|
| 103 | <div class="section" id="announce-response"> |
|---|
| 104 | <h1>Announce Response</h1> |
|---|
| 105 | <p>If the tracker supports this extension, the response should be exactly |
|---|
| 106 | the same as if the <tt class="docutils literal"><span class="pre">info_hash</span></tt> had been passed, except that any |
|---|
| 107 | field that contains peer information (such as <tt class="docutils literal"><span class="pre">peers</span></tt>, <tt class="docutils literal"><span class="pre">peers6</span></tt> or |
|---|
| 108 | any other field defined by another extension) MUST be obfuscated as |
|---|
| 109 | described in the next section.</p> |
|---|
| 110 | <p>There are additional parameters the tracker may OPTIONALLY return. |
|---|
| 111 | These are discussed in the <a class="reference internal" href="#optimizations">optimizations</a> section.</p> |
|---|
| 112 | </div> |
|---|
| 113 | <div class="section" id="obfuscation-method"> |
|---|
| 114 | <h1>Obfuscation Method</h1> |
|---|
| 115 | <p>The values for the <tt class="docutils literal"><span class="pre">ip</span></tt> and <tt class="docutils literal"><span class="pre">port</span></tt> announce parameters, the |
|---|
| 116 | <em>returned peer list</em> and any other values that contain peer |
|---|
| 117 | information are obscured using the method described in this section.</p> |
|---|
| 118 | <p>We distinguish between the <em>tracker peer list</em> and the <em>returned peer |
|---|
| 119 | list</em>. The <em>tracker peer list</em> contains the ip-port pairs of all |
|---|
| 120 | known peers in a given torrent, i.e., those peers that have reported |
|---|
| 121 | to the tracker that they are transferring the file with a given |
|---|
| 122 | infohash. The tracker may store this peer list however it wishes. |
|---|
| 123 | The <em>returned peer list</em> contains a packed array of ip-port pairs |
|---|
| 124 | conforming to the BitTorrent protocol specification. If the swarm is |
|---|
| 125 | sufficiently large then the returned ip-port pairs constitute a subset |
|---|
| 126 | of the ip-port pairs in the <em>tracker peer list</em>.</p> |
|---|
| 127 | <p>When a parameter is obscured, it is encrypted using RC4-drop768 |
|---|
| 128 | encryption using the infohash as a shared secret and optionally |
|---|
| 129 | employing an initialization vector.</p> |
|---|
| 130 | <p>For the remainder of this document RC4 refers to RC4-drop768. In the |
|---|
| 131 | process of encryption, RC4 generates a pseudorandom string that is |
|---|
| 132 | XOR'd with the plaintext to generate the ciphertext. The receiver |
|---|
| 133 | recovers the plaintext by generating the same pseudorandom string and |
|---|
| 134 | XOR'ing it with the ciphertext. In generating the pseudorandom |
|---|
| 135 | string, the tracker and client MUST discard the first 768 bytes. The |
|---|
| 136 | next 8 bytes in the pseudorandom string are reserved for optimizations |
|---|
| 137 | discussed in the next section.</p> |
|---|
| 138 | <p>To communicate an initialization vector, the tracker includes in the |
|---|
| 139 | bencoded response the parameter <tt class="docutils literal"><span class="pre">iv</span></tt> with value set to a byte string |
|---|
| 140 | containing the initialization vector. The initialization vector can |
|---|
| 141 | be of arbitrary length and is sent in plaintext. Initialization |
|---|
| 142 | vectors can only be applied to parameters in tracker responses and NOT |
|---|
| 143 | to announces.</p> |
|---|
| 144 | <p>If the tracker sends no initialization vector then the infohash is |
|---|
| 145 | used as the RC4 key (160 bit key). If the tracker provides an |
|---|
| 146 | initialization vector then the RC4 key is generated by appending the |
|---|
| 147 | vector to the infohash and then hashing with SHA-1. The resulting |
|---|
| 148 | hash is then used as the RC4 key.</p> |
|---|
| 149 | <p>For example, given infohash <tt class="docutils literal"><span class="pre">aaf4c61ddcc5e8a2dabedef3b482cd9aea9434d</span></tt> |
|---|
| 150 | and initialization vector <tt class="docutils literal"><span class="pre">abcd</span></tt> both represented in hex, the RC4 key |
|---|
| 151 | is derived as follows:</p> |
|---|
| 152 | <pre class="literal-block"> |
|---|
| 153 | key = sha1( 'aaf4c61ddcc5e8a2dabedef3b482cd9aea9434dabcd' ) |
|---|
| 154 | </pre> |
|---|
| 155 | <p>The resulting key in hex is <tt class="docutils literal"><span class="pre">f36e9cae87cf33e07645ef5ca745a8a83469f31e</span></tt>.</p> |
|---|
| 156 | <p>It is RECOMMENDED that the tracker use the initialization vector, and |
|---|
| 157 | that it change the <tt class="docutils literal"><span class="pre">iv</span></tt> on roughly the same period as the rerequest |
|---|
| 158 | interval. The reasoning for this is contained in the rationale.</p> |
|---|
| 159 | </div> |
|---|
| 160 | <div class="section" id="optimizations"> |
|---|
| 161 | <h1>Optimizations</h1> |
|---|
| 162 | <p>The described optimizations are OPTIONAL for the tracker, but the |
|---|
| 163 | corresponding client-side MUST be implemented by clients that support |
|---|
| 164 | this extension. These optimizations hobble the strength of the RC4 |
|---|
| 165 | encryption in order to improve tracker performance. In the <a class="reference internal" href="#rationale">rationale</a> |
|---|
| 166 | section we discuss why hobbling RC4 is reasonable and in many cases |
|---|
| 167 | has negligible foreseen effect on security.</p> |
|---|
| 168 | <p>For the purpose of these optimizations we assume that the tracker |
|---|
| 169 | stores the tracker peer list for each infohash as a packed array that |
|---|
| 170 | can be copied directly into the response. We further assume that the |
|---|
| 171 | packed array is reused many times and that with each request the |
|---|
| 172 | tracker either returns the entire packed array or copies a single |
|---|
| 173 | contiguous substring from the tracker peer list into the response.</p> |
|---|
| 174 | <p>If the peerlist is represented and used as assumed then to improve |
|---|
| 175 | randomness in the set of peers handed out by the tracker, it is |
|---|
| 176 | RECOMMENDED that the tracker periodically reshuffle the peerlist with |
|---|
| 177 | period similar to the rerequest interval. After each reshuffle the |
|---|
| 178 | tracker reperforms the operations described in this section.</p> |
|---|
| 179 | <p>To reduce computation the tracker MAY cache the pseudorandom string |
|---|
| 180 | generated by RC4 and reuse it as peers arrive and depart.</p> |
|---|
| 181 | <p>The tracker MAY also cache the encrypted tracker peer list. To |
|---|
| 182 | support this the tracker MUST pass two additional parameters <em>i</em> and <em>n</em> |
|---|
| 183 | each with 32-bit integer values, except the tracker MAY omit <em>i</em> and |
|---|
| 184 | <em>n</em> when <em>i=0</em> and the <em>returned peer list</em> is the entire <em>tracker peer |
|---|
| 185 | list</em>. Whether the tracker returns <em>i</em> and <em>n</em>, the first 8 bytes of |
|---|
| 186 | the RC4 psuedorandom string are reserved for obscuring <em>i</em> and <em>n</em>. |
|---|
| 187 | We come back to this momentarily. Decryption starts by XORing from |
|---|
| 188 | <em>6i</em> bytes for ipv4 (or <em>18i</em> for ipv6) into the pseudorandom string |
|---|
| 189 | after the discarded and reserved bytes. Assuming that the tracker |
|---|
| 190 | encrypted the tracker peer list starting from the first byte after the |
|---|
| 191 | discarded and reserved bytes in the pseudorandom string then <em>i</em> also |
|---|
| 192 | corresponds to the <em>ith</em> ip-port pair in the tracker peer list.</p> |
|---|
| 193 | <p>So that the client and the tracker do not have to generate an |
|---|
| 194 | arbitrarily long pseudorandom string to support large swarms, we |
|---|
| 195 | assume the tracker bounds the length of the pseudorandom string and |
|---|
| 196 | reports the length in ip-port pairs as the value to parameter <em>n</em>. <em>n</em> |
|---|
| 197 | excludes reserved and discarded bytes. We RECOMMEND that <em>n</em> be equal |
|---|
| 198 | to the length of the tracker peer list or random but within constant |
|---|
| 199 | factor of the longest peerlist returned by the tracker, whichever is |
|---|
| 200 | smaller. Thus the tracker encrypts the <em>jth</em> byte of the <em>ith</em> |
|---|
| 201 | ip-port pair in an ipv4 tracker peer list by XORing with the byte |
|---|
| 202 | <em>(6i+j)</em> <cite>mod</cite> <em>n</em> bytes into the pseudorandom string.</p> |
|---|
| 203 | <p>Transmitting <em>i</em> and <em>n</em> as plaintext would significantly reduce the |
|---|
| 204 | cost for an attacker to recover the pseudorandom string. The tracker |
|---|
| 205 | MUST XOR the value of <em>i</em> with the first 32 bits of the pseudorandom |
|---|
| 206 | string. The tracker then XORs <em>n</em> with the next 32 bits from the |
|---|
| 207 | pseudorandom string (see Figure 1).</p> |
|---|
| 208 | <div class="figure"> |
|---|
| 209 | <img alt="bep_0008_pseudo.png" src="bep_0008_pseudo.png" /> |
|---|
| 210 | <p class="caption"><strong>Figure 1:</strong> The first 768 bytes of the RC4 pseudorandom |
|---|
| 211 | string are discarded. The parameter <em>i</em> in the tracker response has |
|---|
| 212 | value <tt class="docutils literal"><span class="pre">x</span> <span class="pre">xor</span> <span class="pre">i</span></tt>. The parameter <em>n</em> has value <tt class="docutils literal"><span class="pre">y</span> <span class="pre">xor</span> <span class="pre">n</span></tt>.</p> |
|---|
| 213 | </div> |
|---|
| 214 | <p>We describe encryption in the following example for an ipv4 tracker peer |
|---|
| 215 | list consisting of 3 ip-port pairs, and using an RC4 pseudorandom string |
|---|
| 216 | of length <em>n=2</em>. <em>n</em> is small for purposes of illustration. Also, for the |
|---|
| 217 | purpose of illustration, the tracker returns only 2 peers at a time.</p> |
|---|
| 218 | <pre class="literal-block"> |
|---|
| 219 | Given the following peer list |
|---|
| 220 | (208.72.193.86, 6881), (209.81.173.15,14321), (128.213.6.8, 6881) |
|---|
| 221 | |
|---|
| 222 | As a packed array represented in hex it becomes |
|---|
| 223 | |
|---|
| 224 | d048c1561ae1d151ad0f37f180d506081ae1 |
|---|
| 225 | |
|---|
| 226 | which we XOR with an RC4 pseudorandom string excluding discarded and |
|---|
| 227 | reserved bytes, e.g., |
|---|
| 228 | |
|---|
| 229 | a496e5f9b83e835013d42226 |
|---|
| 230 | |
|---|
| 231 | to generate |
|---|
| 232 | |
|---|
| 233 | 74de24afa2df5201bedb15d72443e3f1a2df |
|---|
| 234 | </pre> |
|---|
| 235 | <p>Because the RC4 pseudorandom string is shorter than the tracker |
|---|
| 236 | peer list, we wrap to the beginning of the pseudorandom string.</p> |
|---|
| 237 | <p>A tracker returning the first two peers would return the bencoded |
|---|
| 238 | equivalent of:</p> |
|---|
| 239 | <pre class="literal-block"> |
|---|
| 240 | peers=74de24afa2df5201bedb15d7, i=0, n=2 |
|---|
| 241 | </pre> |
|---|
| 242 | <p>A tracker returning the second and third peer would return the |
|---|
| 243 | bencoded equivalent of:</p> |
|---|
| 244 | <pre class="literal-block"> |
|---|
| 245 | peers=5201bedb15d72443e3f1a2df, i=1, n=2 |
|---|
| 246 | </pre> |
|---|
| 247 | <p>In each response the tracker includes additional parameters such as |
|---|
| 248 | the rerequest <tt class="docutils literal"><span class="pre">interval</span></tt> and the initialization vector <tt class="docutils literal"><span class="pre">iv</span></tt>.</p> |
|---|
| 249 | <p>The tracker response MUST remain a valid bencoded message.</p> |
|---|
| 250 | </div> |
|---|
| 251 | <div class="section" id="backwards-compatibility"> |
|---|
| 252 | <h1>Backwards Compatibility</h1> |
|---|
| 253 | <p>Trackers that support obfuscation are identified in the .torrent file |
|---|
| 254 | by the inclusion of an <tt class="docutils literal"><span class="pre">obfuscate-announce-list</span></tt> which otherwise has the |
|---|
| 255 | same semantics as the <tt class="docutils literal"><span class="pre">announce-list</span></tt> parameter. Peers that do not support |
|---|
| 256 | obfuscation simply ignore the <tt class="docutils literal"><span class="pre">obfuscate-announce-list</span></tt>.</p> |
|---|
| 257 | <p>A client that is configured to use this extension should always send |
|---|
| 258 | the <tt class="docutils literal"><span class="pre">sha_ih</span></tt> to any tracker supporting obfuscation. The client |
|---|
| 259 | SHOULD only contact trackers in the <tt class="docutils literal"><span class="pre">announce-list</span></tt> once the client |
|---|
| 260 | has attempted all trackers in the <tt class="docutils literal"><span class="pre">obfuscate-announce-list</span></tt> and all failed.</p> |
|---|
| 261 | <p>If a tracker that supports obfuscation wishes to allow legacy peers to |
|---|
| 262 | connect to the tracker then the announce URL should appear in both the |
|---|
| 263 | <tt class="docutils literal"><span class="pre">obfuscate-announce-list</span></tt> and the <tt class="docutils literal"><span class="pre">announce-list</span></tt>.</p> |
|---|
| 264 | <p>If a tracker URL appears in both lists running on the same port, and |
|---|
| 265 | the tracker failed to respond when selected from the |
|---|
| 266 | <tt class="docutils literal"><span class="pre">obfuscate-announce-list</span></tt> then the client MAY treat the tracker in |
|---|
| 267 | the <tt class="docutils literal"><span class="pre">announce-list</span></tt> as if it were temporarily unreachable and defer |
|---|
| 268 | trying it until it has tried other trackers in the <tt class="docutils literal"><span class="pre">announce-list</span></tt>.</p> |
|---|
| 269 | <p>Peers MUST never send both the <tt class="docutils literal"><span class="pre">info_hash</span></tt> and <tt class="docutils literal"><span class="pre">sha_ih</span></tt> parameters |
|---|
| 270 | in the same request, since that would defeat the purpose of the shared |
|---|
| 271 | secret.</p> |
|---|
| 272 | <p>Any peer that requests with a <tt class="docutils literal"><span class="pre">sha_ih</span></tt> SHOULD implement Message |
|---|
| 273 | Stream Encryption (MSE) <a class="footnote-reference" href="#mse" id="id1">[1]</a>. Any peer returned from the tracker |
|---|
| 274 | in response to a request with a <tt class="docutils literal"><span class="pre">sha_ih</span></tt> SHOULD be assumed to |
|---|
| 275 | support Message Stream Encryption. We include these provisions |
|---|
| 276 | because if a peer communicates with another peer without using MSE |
|---|
| 277 | then the BitTorrent protocol is trivially identified from the first |
|---|
| 278 | twenty bytes of the BitTorrent header and the <tt class="docutils literal"><span class="pre">info_hash</span></tt> appears in |
|---|
| 279 | plaintext as the next twenty bytes, hence also defeating the purpose |
|---|
| 280 | of the shared secret.</p> |
|---|
| 281 | <p>If the tracker does not know enough peers assumed to support MSE to |
|---|
| 282 | return the desired number of peers then it MAY include peers that are |
|---|
| 283 | not assumed to support MSE. If a peer closes a connection in response |
|---|
| 284 | to an encrypted header then the initiating peer SHOULD assume that the |
|---|
| 285 | peer does not support MSE. The initiating peer however SHOULD ONLY |
|---|
| 286 | initiate unencrypted connections when all peers have been tried and |
|---|
| 287 | those that support MSE fail to provide "adequate performance." We |
|---|
| 288 | intentionally omit any definition of "adequate performance."</p> |
|---|
| 289 | </div> |
|---|
| 290 | <div class="section" id="rationale"> |
|---|
| 291 | <h1>Rationale</h1> |
|---|
| 292 | <p>This extension directly addresses a known attack on the BitTorrent |
|---|
| 293 | protocol performed by some deployed network hardware. By obscuring |
|---|
| 294 | the ip-port pairs network hardware can no longer easily identify |
|---|
| 295 | ip-port pairs that are running BitTorrent by observing peer-to-tracker |
|---|
| 296 | communications. This deployed hardware under some conditions disrupts |
|---|
| 297 | BitTorrent connections by injecting forged TCP reset packets.</p> |
|---|
| 298 | <p>This hardware was presumably deployed to get around BitTorrent |
|---|
| 299 | Message Stream Encryption <a class="footnote-reference" href="#mse" id="id2">[1]</a>. Peers implementing BitTorrent Message Stream |
|---|
| 300 | Encryption obfuscate peer-to-peer connections by employing RC4 |
|---|
| 301 | encryption on every byte from the first byte transferred. BitTorrent |
|---|
| 302 | Message Stream Encryption thus increases the difficulty for a device |
|---|
| 303 | observing passing packets to identify BitTorrent peer-to-peer |
|---|
| 304 | connections.</p> |
|---|
| 305 | <p>By using the SHA-1 of the infohash, the tracker is able to identify |
|---|
| 306 | torrents without sending the plaintext infohash and without requiring |
|---|
| 307 | an additional prior exchange of a shared secret. Where trackers now |
|---|
| 308 | maintain mappings from infohash to the corresponding torrent's |
|---|
| 309 | peerlist and other torrent-specific state, obfuscated trackers would |
|---|
| 310 | need one additional mapping from <tt class="docutils literal"><span class="pre">sha_ih</span></tt> to the torrent's state. |
|---|
| 311 | Trackers may also cache the encrypted version of each torrent's |
|---|
| 312 | tracker peer list, to increase computational performance at the |
|---|
| 313 | expense of increasing memory footprint by a constant factor.</p> |
|---|
| 314 | <p>The obfuscation method meets the following criteria:</p> |
|---|
| 315 | <ul class="simple"> |
|---|
| 316 | <li>The entire plaintext of the peer list is not easily obtained even if |
|---|
| 317 | an eavesdropper identifies one or more subsequent connections as |
|---|
| 318 | using BitTorrent and the corresponding ip-port pairs appeared in the |
|---|
| 319 | ciphertext of the tracker response.</li> |
|---|
| 320 | <li>Even when a subsequent connection from a peer that has received a |
|---|
| 321 | tracker response is observed by an eavesdropper, it is difficult to |
|---|
| 322 | map the ip-port pair to specific ciphertext to verify that the |
|---|
| 323 | connection is using BitTorrent.</li> |
|---|
| 324 | </ul> |
|---|
| 325 | <p>When the <a class="reference internal" href="#optimizations">optimizations</a> are used,</p> |
|---|
| 326 | <ul class="simple"> |
|---|
| 327 | <li>Few computations are performed at request time.</li> |
|---|
| 328 | <li>Encryption may be performed at the time a peer is added. |
|---|
| 329 | The encrypted peer ip and port may be handed out hundreds of times.</li> |
|---|
| 330 | <li>Security is minimally impacted.</li> |
|---|
| 331 | </ul> |
|---|
| 332 | <p>The objective is NOT to create a cryptographically secure protocol |
|---|
| 333 | that can survive unlimited observation of passing packets and |
|---|
| 334 | substantial computational resources on network timescales. The objective |
|---|
| 335 | is to raise the bar sufficiently to deter attacks based on observing |
|---|
| 336 | ip-port numbers in peer-to-tracker communications.</p> |
|---|
| 337 | <p>If a tracker observes a large number of tracker requests and responses |
|---|
| 338 | and subsequent connections, it is possible to attack the encryption. |
|---|
| 339 | RC4 is known to have a number of weaknesses especially in the way it |
|---|
| 340 | is used with WEP <a class="footnote-reference" href="#borisov" id="id3">[2]</a> <a class="footnote-reference" href="#scott" id="id4">[3]</a> <a class="footnote-reference" href="#stubblefeld" id="id5">[4]</a>. However, with |
|---|
| 341 | tracker peer obfuscation, the number of bytes transferred between the |
|---|
| 342 | tracker and a client is likely significantly smaller than transferred |
|---|
| 343 | between a wireless computer and a basestation. An attacker faces a |
|---|
| 344 | much larger task in obtaining sufficient ciphertext to directly break |
|---|
| 345 | the encryption.</p> |
|---|
| 346 | <p>Hobbling the RC4 encryption by using a bounded-length RC4 pseudorandom |
|---|
| 347 | string for small swarms is likely to have negilgible impact on |
|---|
| 348 | security over any other encyption method since the pseudorandom string |
|---|
| 349 | is probably equal to or longer than the plaintext and thus no part of |
|---|
| 350 | it is repeated in the XOR except as peers arrive or leave the swarm. |
|---|
| 351 | Thus on the timescales of rerequest intervals, nearly the same |
|---|
| 352 | ciphertext is handed to every peer requesting the same infohash. |
|---|
| 353 | Intercepting the same ciphertext multiple times provides no additional |
|---|
| 354 | information to the attacker. The attacker could correlate ip-port |
|---|
| 355 | pairs in connections following tracker responses, but an attacker |
|---|
| 356 | could do this regardless of the encryption method employed. |
|---|
| 357 | Furthermore more direct methods of traffic analysis applied to |
|---|
| 358 | peer-to-peer communication is available to network operators.</p> |
|---|
| 359 | <p>For larger swarms, hobbling RC4 may simplify breaking the encryption |
|---|
| 360 | since the same pseudorandom string is used repeatedly across the peer |
|---|
| 361 | list. Some study is in order taking into account that the tracker can |
|---|
| 362 | periodically change intiailization vectors.</p> |
|---|
| 363 | <p>We know from experience that periodically reshuffling peer lists on |
|---|
| 364 | the order of the rerequest interval negligibly impacts tracker |
|---|
| 365 | performance even with swarms containing millions of peers. Generating |
|---|
| 366 | a new pseudorandom string using RC4 on this same time interval is |
|---|
| 367 | likely to incur negligible performance penalty because 1) RC4 is a |
|---|
| 368 | small constant factor more expensive than a shuffle on an input string |
|---|
| 369 | of equal length, 2) the generated pseudorandom string is only <em>n</em> |
|---|
| 370 | ip-port pairs long where recommended <em>n</em> is within a small constant |
|---|
| 371 | factor larger than the largest <em>returned peer list</em> and thus much |
|---|
| 372 | smaller than the <em>tracker peer list</em> for large swarms, and 3) the cost |
|---|
| 373 | of the XOR operation is lighter weight than performing a random |
|---|
| 374 | shuffle.</p> |
|---|
| 375 | </div> |
|---|
| 376 | <div class="section" id="references"> |
|---|
| 377 | <h1>References</h1> |
|---|
| 378 | <table class="docutils footnote" frame="void" id="mse" rules="none"> |
|---|
| 379 | <colgroup><col class="label" /><col /></colgroup> |
|---|
| 380 | <tbody valign="top"> |
|---|
| 381 | <tr><td class="label">[1]</td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id2">2</a>)</em> BitTorrent Message Stream Encryption |
|---|
| 382 | (<a class="reference external" href="http://www.azureuswiki.com/index.php/Message_Stream_Encryption">http://www.azureuswiki.com/index.php/Message_Stream_Encryption</a>)</td></tr> |
|---|
| 383 | </tbody> |
|---|
| 384 | </table> |
|---|
| 385 | <table class="docutils footnote" frame="void" id="borisov" rules="none"> |
|---|
| 386 | <colgroup><col class="label" /><col /></colgroup> |
|---|
| 387 | <tbody valign="top"> |
|---|
| 388 | <tr><td class="label"><a class="fn-backref" href="#id3">[2]</a></td><td>Nikita Borisov, Ian Goldberg, and David Wagner. Intercepting |
|---|
| 389 | mobile communications: the insecurity of 802.11. In ACM MobiCom 2001, |
|---|
| 390 | pages 180-189. ACM Press, 2001.</td></tr> |
|---|
| 391 | </tbody> |
|---|
| 392 | </table> |
|---|
| 393 | <table class="docutils footnote" frame="void" id="scott" rules="none"> |
|---|
| 394 | <colgroup><col class="label" /><col /></colgroup> |
|---|
| 395 | <tbody valign="top"> |
|---|
| 396 | <tr><td class="label"><a class="fn-backref" href="#id4">[3]</a></td><td>Scott R. Fluhrer, Itsik Mantin, and Adi |
|---|
| 397 | Shamir. Weaknesses in the key scheduling algorithm of RC4. In Serge |
|---|
| 398 | Vaudenay and Amr M. Youssef, editors, Selected Areas in |
|---|
| 399 | Cryptography 2001, volume 2259 of Lecture Notes in Computer |
|---|
| 400 | Science, pages 1-24. Springer, 2001.</td></tr> |
|---|
| 401 | </tbody> |
|---|
| 402 | </table> |
|---|
| 403 | <table class="docutils footnote" frame="void" id="stubblefeld" rules="none"> |
|---|
| 404 | <colgroup><col class="label" /><col /></colgroup> |
|---|
| 405 | <tbody valign="top"> |
|---|
| 406 | <tr><td class="label"><a class="fn-backref" href="#id5">[4]</a></td><td>Adam Stubblefeld, John Ioannidis, and Aviel |
|---|
| 407 | D. Rubin. A key recovery attack on the 802.11b wired equivalent |
|---|
| 408 | privacy protocol (WEP). ACM Transactions on Information and System |
|---|
| 409 | Security, 7(2):319-332, May 2004.</td></tr> |
|---|
| 410 | </tbody> |
|---|
| 411 | </table> |
|---|
| 412 | <table class="docutils footnote" frame="void" id="id6" rules="none"> |
|---|
| 413 | <colgroup><col class="label" /><col /></colgroup> |
|---|
| 414 | <tbody valign="top"> |
|---|
| 415 | <tr><td class="label"><a class="fn-backref" href="#id7">[5]</a></td><td><a class="reference external" href="http://tools.ietf.org/html/rfc2119">http://tools.ietf.org/html/rfc2119</a></td></tr> |
|---|
| 416 | </tbody> |
|---|
| 417 | </table> |
|---|
| 418 | </div> |
|---|
| 419 | <div class="section" id="example-python-code"> |
|---|
| 420 | <h1>Example Python Code</h1> |
|---|
| 421 | <p>Request handling in a dummy tracker implementing tracker peer obfuscation:</p> |
|---|
| 422 | <pre class="literal-block"> |
|---|
| 423 | from sha import sha |
|---|
| 424 | from random import randint |
|---|
| 425 | from struct import unpack |
|---|
| 426 | from rc4 import rc4 # rc4(k) generates k RC4 pseudorandom bytes. |
|---|
| 427 | |
|---|
| 428 | rand = open("/dev/random","r").read |
|---|
| 429 | rc4 = rc4() |
|---|
| 430 | |
|---|
| 431 | # tracker configuration |
|---|
| 432 | MAX_PEERS = 100 |
|---|
| 433 | |
|---|
|
|---|