How do I use Tor Browser with Qubes TorVM?

I want to run Tor Browser, without the bundled Tor, using Qubes TorVM. Let's assume I have already got Qubes OS running.

The TorVM documentation states under Future Work: "Create Tor Browser packages w/out bundled tor". This is essentially what I want to do now, except I will need to manually set things up so that Tor Browser uses Tor through the TorVM rather than through the bundled Tor executable.

Why? Because the version of Firefox that comes with the Tor Browser Bundle is already configured to be relatively secure and Tor-friendly compared to stock Firefox.

• Bundle your own Firefox rather than bundling your own Tor Browser? – Ry- Sep 25 '13 at 20:11
• You're going to have a tough time doing that, especially with Tor Browser Bundle 3.0's design where the Tor Launcher Firefox extension launches the Tor binary. In summary, sticking Tor Browser in a VM behind a firewall is definitely worthwhile to do, but there will be a lot of development work before we/you are there, and then also there's maintenance to consider. – Roger Dingledine Sep 25 '13 at 20:45
• Hi Roger, it's actually not that hard, thanks to brade implementing the TOR_SKIP_LAUNCH environment variable. See also my answer below. – adrelanos Sep 25 '13 at 23:05

This answer isn't perfect yet, but still better than nothing.

This answer mostly works for TBB 3.0 and above. (Currently the Alpha version of TBB.) Most of this solution is taken from Whonix's source code. It could be made to work with TBB 2.x (currently the stable version of TBB) as well, in that case get the modified Tor Browser start script (start-tor-browser) from Whonix 0.5.6 source code. (For TBB 2.x, see also TorifyHOWTO/WebBrowsers.) You can ask questions in the comments and I will improve this answer, if I can.

This is definitely doable and not rocket science. Also since TBB 3.0 works in Whonix out of the box. Download, [OpenPGP verification up to you], extract, run. No Tor over Tor. No modifications. (Because of environment variables and rinetd, see below.) So it might be useful to check out how it's done in Whonix. I try to summarize the relevant parts for you here...

Create a file /etc/profile.d/20_torbrowser.sh.

## Deactivate tor-launcher,
## a Vidalia replacement as browser extension,
## to prevent running Tor over Tor.
## https://trac.torproject.org/projects/tor/ticket/6009
## https://gitweb.torproject.org/tor-launcher.git
export TOR_SKIP_LAUNCH=1

## The following TOR_SOCKS_HOST and TOR_SOCKS_PORT variables
## do not work flawlessly, due to an upstream bug in Tor Button:
##    "TOR_SOCKS_HOST, TOR_SOCKS_PORT regression"
##    https://trac.torproject.org/projects/tor/ticket/8336
## (As an alternative,
##    /home/user/tor-browser_en-US/Data/profile/user.js
## could be used.)
#export TOR_SOCKS_HOST="192.168.0.10"
#export TOR_SOCKS_PORT="9100"

## Something else to consider, but better don't use it, use proper stream isolation.
#export TOR_TRANSPROXY=1


Reboot, so the environment variables takes effect.

Due to the bug changing Tor Browser's proxy settings with a script isn't as trivial as exporting the environment variables TOR_SOCKS_HOST and TOR_SOCKS_PORT. Either change the proxy settings in Tor Button (sorry, I don't know which IP/port the Qubes-Tor-Gateway is providing) or use rinetd.

Sample config for rinetd (you have to adjust IP's and ports, i.e. connectaddress and connectport):

##
## this is the configuration file for rinetd, the internet redirection server
##
## you may specify global allow and deny rules here
## only ip addresses are matched, hostnames cannot be specified here
## the wildcards you may use are * and ?
##
## allow 192.168.2.*
## deny 192.168.2.1?

##
## forwarding rules come here
##
## you may specify allow and deny rules after a specific forwarding rule
## to apply to only that forwarding rule
##