1 Filename: 199-bridgefinder-integration.txt
2 Title: Integration of BridgeFinder and BridgeFinderHelper
11 This proposal describes how the Tor client software can interact with
12 an external program that performs bridge discovery based on user input
13 or information extracted from a web page, QR Code, online game, or
14 other transmission medium.
19 This document describes how all of the components involved in bridge
20 discovery communicate this information to the rest of the Tor
21 software. The mechanisms of bridge discovery are not discussed, though
22 the design aims to be generalized enough to allow arbitrary new
23 discovery mechanisms to be added at any time.
25 This document is also written with the hope that those who wish to
26 implement BridgeFinder components and BridgeFinderHelpers can get
27 started immediately after a read of this proposal, so that development
28 of bridge discovery mechanisms can proceed in parallel to supporting
29 functionality improvements in the Tor client software.
32 Components and Responsibilities
36 The Tor Client is the piece of software that connects to the Tor
37 network (optionally using bridges) and provides a SOCKS proxy for
40 In initial implementations, the Tor Client will support only
41 standard bridges. In later implementations, it is expected to
42 support pluggable transports as defined by Proposal 180.
46 The Tor Control Port provides commands to perform operations,
47 configuration, and to obtain status information. It also optionally
48 provides event driven status updates.
50 In initial implementations, it will be used directly by BridgeFinder
51 to configure bridge information via GETINFO and SETCONF. It is covered
52 by control-spec.txt in the tor-specs git repository.
54 In later implementations, it will support the inter-controller
55 POSTMESSAGE IPC protocol as defined by Proposal 197 for use
56 in conveying bridge information to the Primary Controller.
60 The Primary Controller is the program that launches and configures the
61 Tor client, and monitors its status.
63 On desktop platforms, this program is Vidalia, and it also launches
64 the Tor Browser. On Android, this program is Orbot. Orbot does not
67 On all platforms, this proposal requires that the Primary Controller
68 will launch one or more BridgeFinder child processes and provide
69 them with authentication information through the environment variables
70 TOR_CONTROL_PORT and TOR_CONTROL_PASSWD.
72 In later implementations, the Primary Controller will be expected
73 to receive Bridge configuration information via the free-form
74 POSTMESSAGE protocol from Proposal 197, validate that information,
75 and hold that information for user approval.
79 A BridgeFinder is a program that discovers bridges and configures
82 In initial implementations, it is likely to be very dumb, and its main
83 purpose will be to serve as a layer of abstraction that should free
84 the Primary Controller from having to directly implement numerous ways
85 of retrieving bridges for various pluggable transports.
87 In later implementations, it may perform arbitrary network operations
88 to discover, authenticate to, and/or verify bridges, possibly using
89 informational hints provided by one or more external
90 BridgeFinderHelpers (see next component). It could even go so far as
91 to download new pluggable transport plugins and/or transform
92 definition files from arbitrary urls.
94 It will be launched by the Primary Controller and given access to the
95 Tor Control Port via the environment variables TOR_CONTROL_PORT and
98 Initial control port interactions can be command driven via GETINFO
99 and SETCONF, and do not need to subscribe to or process control port
100 events. Later implementations will use POSTMESSAGE as defined in
101 Proposal 197 to pass command requests to Vidalia, which will parse
102 them and ask for user confirmation before deploying them. Use of
103 POSTMESSAGE may or may not require event driven operation, depending
104 on POSTMESSAGE implementation status (POSTMESSAGE is designed to
105 support both command and event driven operation, but it is possible
106 event driven operation will happen first).
108 4. BridgeFinderHelper
110 Each BridgeFinder implementation can optionally communicate with one
111 or more BridgeFinderHelpers. BridgeFinderHelpers are plugins to
112 external 3rd party applications that can inspect traffic, handle mime
113 types, or implement protocol handlers for accepting bridge discovery
114 information to pass to BridgeFinder. Example 3rd party applications
115 include Chrome, World of Warcraft, QR Code readers, or simple cut
118 Due to the arbitrary nature of sandboxing that may be present in
119 various BridgeFinderHelper host applications, we do not mandate the
120 exact nature of the IPC between BridgeFinder instances and external
121 BridgeFinderHelper addons. However, please see the "Security Concerns"
122 section for common pitfalls to avoid.
126 This is the browser the user uses with Tor. It is not useful until Tor
127 is properly configured to use bridges. It fails closed.
129 It is not expected to run BridgeFinderHelper plugin instances, unless
130 those plugin instances exist to ensure the user always has a pool of
131 working bridges available after successfully configuring an
132 initial bridge. Once all bridges fail, the Tor Browser is useless.
134 6. Non-Tor Browser (aka BridgeFinderHelper host)
136 This is the program the user uses for normal Internet activity to
137 obtain bridges via a BridgeFinderHelper plugin. It does not have to be
138 a browser. In advanced scenarios, this component may not be a browser
139 at all, but may be a program such as World of Warcraft instead.
142 Incremental Deployability
144 The system is designed to be incrementally deployable: Simple designs
145 should be possible to develop and test immediately. The design is
146 flexible enough to be easily upgraded as more advanced features become
147 available from both Tor and new pluggable transports.
149 Initial Implementation
151 In the simplest possible initial implementation, BridgeFinder will
152 only discover Tor Bridges as they are deployed today. It will use the
153 Tor Control Port to configure these bridges directly via the SETCONF
154 command. It may or may not receive bridge information from a
155 BridgeFinderHelper. In an even more degenerate case,
156 BridgeFinderHelper may even be Vidalia or Orbot itself, acting upon
157 user input from cut and paste.
159 Initial Implementation: BridgeFinder Launch
161 In the initial implementation, the Primary Controller will launch one
162 or more BridgeFinders, providing control port authentication
163 information to them through the environment variables TOR_CONTROL_PORT
164 and TOR_CONTROL_PASSWD.
166 BridgeFinder will then directly connect to the control port and
167 authenticate. Initial implementations should be able to function
168 without using SETEVENTS, and instead only using command-based
169 status inquiries and configuration (GETINFO and SETCONF).
171 Initial Implementation: Obtaining Bridge Hint Information
173 In the initial implementation, to test functionality,
174 BridgeFinderHelper can simply scrape bridges directly from
175 https://bridges.torproject.org.
177 In slightly more advanced implementations, a BridgeFinderHelper
178 instance may be written for use in the user's Non-Tor Browser. This
179 plugin could extract bridges from images, html comments, and other
180 material present in ad banners and slack space on unrelated pages.
182 BridgeFinderHelper would then communicate with the appropriate
183 BridgeFinder instance over an acceptable IPC mechanism. This proposal
184 does not seek to specify the nature of that IPC channel (because
185 BridgeFinderHelper may be arbitrarily constrained due to host
186 application sandboxing), but we do make several security
187 recommendations under the section "Security Concerns: BridgeFinder and
190 Initial Implementation: Configuring New Bridges
192 In the initial implementation, Bridge configuration will be done
193 directly though the control port using the SETCONF command.
195 Initial implementations will support only retrieval and configuration
196 of standard Tor Bridges. These are configured using SETCONF on the Tor
197 Control Port as follows:
198 SETCONF Bridge="IP:ORPort [fingerprint]"
201 Future Implementations
203 In future implementations, the system can incrementally evolve in a
204 few different directions. As new pluggable transports are created, it
205 is conceivable that BridgeFinder may want to download new plugin
206 binaries (and/or new transport transform definition files) and
209 Furthermore, it may prove simpler to deploy multiple concurrent
210 BridgeFinder+BridgeFinderHelper pairs as opposed to adding new
211 functionality to existing prototypes.
213 Finally, it is desirable for BridgeFinder to obtain approval
214 from the user before updating bridge configuration, especially for
215 cases where BridgeFinderHelper is automatically discovering bridges
216 in-band during Non-Tor activity.
218 The exact mechanisms for accomplishing these improvements is
219 described in the following subsections.
221 Future Implementations: BridgeFinder Launch and POSTMESSAGE handshake
223 The nature of the BridgeFinder launch and the environment variables
224 provided is not expected to change. However, future Primary Controller
225 implementations may decide to launch more than one BridgeFinder
226 instance side by side.
228 Additionally, to negotiate the IPC channel created by Proposal 197
229 for purposes of providing user confirmation, it is recommended that
230 BridgeFinder and the Primary Controller perform a handshake using
231 POSTMESSAGE upon launch, to establish that all parties properly
234 Primary Controller: "POSTMESSAGE @all Controller wants POSTMESSAGE v1.1"
235 BridgeFinder: "POSTMESSAGE @all BridgeFinder has POSTMESSAGE v1.0"
236 Primary Controller: "POSTMESSAGE @all Controller expects POSTMESSAGE v1.0"
237 BridgeFinder: "POSTMESSAGE @all BridgeFinder will POSTMESSAGE v1.0"
239 If this 4 step handshake proceeds with an acceptable version,
240 BridgeFinder must use POSTMESSAGE to transmit SETCONF Bridge lines
241 (see "Future Implementations: Configuring New Bridges" below). If
242 POSTMESSAGE support is expected, but the handshake does not complete
243 for any reason, BridgeFinder should either exit or go dormant.
245 The exact nature of the version negotiation and exactly how much
246 backwards compatibility must be tolerated is unspecified.
247 "All-or-nothing" is a safe assumption to get started.
249 Future Implementations: Obtaining Bridge Hint Information
251 Future BridgeFinder implementations may download additional
252 information based on what is provided by BridgeFinderHelper. They
253 may fetch pluggable transport plugins, transformation parameters,
256 Future Implementations: Configuring New Bridges
258 Future implementations will be concerned with providing two new pieces
259 of functionality with respect to configuring bridges: configuring
260 pluggable transports, and properly prompting the user before altering
263 There are two ways to tell Tor clients about pluggable transports
264 (as defined in Proposal 180).
266 On the control port, an external Proposal 180 transport will be
268 SETCONF ClientTransportPlugin=<method> socks5 <addr:port> [auth=X]
270 SETCONF ClientTransportPlugin="trebuchet socks5 127.0.0.1:9999".
272 A managed proxy is configured with
273 SETCONF ClientTransportPlugin=<methods> exec <path> [options]
275 SETCONF ClientTransportPlugin="trebuchet exec /usr/libexec/trebuchet --managed".
277 This example tells Tor to launch an external program to provide a
278 socks proxy for 'trebuchet' connections. The Tor client only
279 launches one instance of each external program with a given set of
280 options, even if the same executable and options are listed for
281 more than one method.
283 Pluggable transport bridges discovered for this transport by
284 BridgeFinder would then be set with:
285 SETCONF Bridge="trebuchet 3.2.4.1:8080 keyid=09F911029D74E35BD84156C5635688C009F909F9 rocks=20 height=5.6m".
287 For more information on pluggable transports and supporting Tor
288 configuration commands, see Proposal 180.
290 Future Implementations: POSTMESSAGE and User Confirmation
292 Because configuring even normal bridges alone can expose the user to
293 attacks, it is strongly desired to provide some mechanism to allow
294 the user to approve new bridges prior to their use, especially for
295 situations where BridgeFinderHelper is extracting them transparently
296 while the user performs unrelated activity.
298 If BridgeFinderHelper grows to the point where it is downloading new
299 transform definitions or plugins, user confirmation becomes
302 To achieve user confirmation, we depend upon the POSTMESSAGE command
303 defined in Proposal 197.
305 If the POSTMESSAGE handshake succeeds, instead of sending SETCONF
306 commands directly to the control port, the commands will be wrapped
307 inside a POSTMESSAGE:
308 POSTMESSAGE @all SETCONF Bridge="www.example.com:8284"
310 Upon receiving this POSTMESSAGE, the Primary Controller will
311 validate it, evaluate it, store it to be later enabled by the
312 user, and alert the user that new bridges are available for
313 approval. It is only after the user has approved the new bridges
314 that the Primary Controller should then re-issue the SETCONF commands
315 to configure and deploy them in the tor client.
317 Additionally, see "Security Concerns: Primary Controller" for more
318 discussion on potential pitfalls with POSTMESSAGE.
322 While automatic bridge discovery and configuration is quite compelling
323 and powerful, there are several serious security concerns that warrant
324 extreme care. We've broken them down by component.
326 Security Concerns: Primary Controller
328 In the initial implementation, Orbot and Vidalia must take care to
329 transmit the Tor Control password to BridgeFinder in such a way that
330 it does not end up in system logs, process list, or viewable by other
331 system users. The best known strategy for doing this is by passing the
332 information through exported environment variables.
334 Additionally, in future implementations, Orbot and Vidalia will need
335 to validate Proposal 197 POSTMESSAGE input before prompting the user.
336 POSTMESSAGE is a free-form message-passing mechanism. All sorts of
337 unexpected input may be passed through it by any other authenticated
338 Tor Controllers for their own unrelated communication purposes.
340 Minimal validation includes verifying that the POSTMESSAGE data is a
341 valid Bridge or ClientTransportPlugin line and is acceptable input for
342 SETCONF. All unexpected characters should be removed through using a
343 whitelist, and format and structure should be checked against a
344 regular expression. Additionally, the POSTMESSAGE string should not be
345 passed through any string processing engines that automatically decode
346 character escape encodings, to avoid arbitrary control port execution.
348 At the same time, POSTMESSAGE validation should be light. While fully
349 untrusted input is not expected due to the need for control port
350 authentication and BridgeFinder sanitation, complicated manual string
351 parsing techniques during validation should be avoided. Perform simple
352 easy-to-verify whitelist-based checks, and ignore unrecognized input.
354 Beyond POSTMESSAGE validation, the manner in which the Primary
355 Controller achieves consent from the user is absolutely crucial to
356 security under this scheme. A simple "OK/Cancel" dialog is
357 insufficient to protect the user from the dangers of switching
358 bridges and running new plugins automatically.
360 Newly discovered bridge lines from POSTMESSAGE should be added to a
361 disabled set that the user must navigate to as an independent window
362 apart from any confirmation dialog. The user must then explicitly
363 enable recently added plugins by checking them off individually. We
364 need the user's brain to be fully engaged and aware that it is
365 interacting with Tor during this step. If they get an "OK/Cancel"
366 popup that interrupts their online game play, they will almost
367 certainly simply click "OK" just to get back to the game quickly.
369 The Primary Controller should transmit the POSTMESSAGE content to the
370 control port only after obtaining this out-of-band approval.
372 Security Concerns: BridgeFinder and BridgeFinderHelper
374 The unspecified nature of the IPC channel between BridgeFinder and
375 BridgeFinderHelper makes it difficult to make concrete security
376 suggestions. However, from past experience, the following best
377 practices must be employed to avoid security vulnerabilities:
379 1. Define a non-webby handshake and/or perform authentication
381 The biggest risk is that unexpected applications will be manipulated
382 into posting malformed data to the BridgeFinder's IPC channel as if it
383 were from BridgeFinderHelper. The best way to defend against this is
384 to require a handshake to properly complete before accepting input. If
385 the handshake fails at any point, the IPC channel must be abandoned
386 and closed. Do not continue scanning for good input after any bad
387 input has been encountered.
389 Additionally, if possible, it is wise to establish a shared secret
390 between BridgeFinder and BridgeFinderHelper through the filesystem or
391 any other means available for use in authentication. For an a good
392 example on how to use such a shared secret properly for
393 authentication, see Trac Ticket #5185 and/or the SafeCookie Tor
394 Control Port authentication mechanism.
396 2. Perform validation before parsing
398 Care must be taken before converting BridgeFinderHelper data into
399 Bridge lines, especially for cases where the BridgeFinderHelper data
400 is fed directly to the control port after passing through
403 The input should be subjected to a character whitelist and possibly
404 also validated against a regular expression to verify format, and if
405 any unexpected or poorly-formed data is encountered, the IPC channel
408 3. Fail closed on unexpected input
410 If the handshake fails, or if any other part of the BridgeFinderHelper
411 input is invalid, the IPC channel must be abandoned and closed. Do
412 *not* continue scanning for good input after any bad input has been