1. The Tor Browser Hacking Guide
  2. Ways to Build Tor Browser
    1. Nightly Builds
    2. Building Official Tor Browser Release Binaries
    3. Reproducing an Existing Build
    4. Partial Builds
      1. Building Just Firefox
      2. Building Just Tor Launcher Or Torbutton
  3. Building Orfox
    1. Orfox
      1. Compiling Orfox
      2. Orfox Release
    2. Orbot
      1. Dependencies
      2. Fetching and Building
  4. Running Multiple Tor Browsers
    1. Using an Existing Tor Process
    2. Launching Tor with an Alternate SOCKS and Control port
  5. Tor Browser Team Communication and Organizational Patterns
    1. Communication Mechanisms and Meetings
    2. How we use Trac
      1. Trac Keywords
  6. Design and Core Components
    1. Design Document
    2. Component Source Repositories
      1. Firefox Branch Repo
      2. Torbutton
      3. Tor Launcher
      4. HTTPS-Everywhere
      5. NoScript
      6. Pluggable Transports
  7. Debugging the Tor Browser
    1. Enabling debug logs in extensions
    2. Offline Logging/Tracing
      1. Example Usage
        1. Source
        2. Aggregate
    3. Using the Javascript Debugger
    4. Debugging on Windows
    5. Using gdb
      1. Using Debug Symbols
      2. Attaching an already running TBB
      3. Starting firefox from inside gdb
      4. Generating and debugging core files
      5. Debugging ASan/selfrando builds
        1. Temporarily disable selfrando
        2. Convert ASan's stack trace message
    6. Using dtrace
      1. dtrace examples for Tor Browser Bundle
    7. Bisecting
      1. The easy case
      2. The medium difficult case
      3. The tricky case
      4. Testing in TaskCluster
    8. QA and Testing
      1. Tor Browser Test Suite
      2. VirusTotal uploads
      3. Browser Unit Tests
      4. Rebasing Tests
    9. Requesting testing of a custom build using the tbb-qa.yml file
      1. Tor Browser Unit Tests (xpcshell and mochitest)
      2. Android
  8. FPCentral
  9. Adding New Default Bridges
  10. Other Resources

The Tor Browser Hacking Guide

Welcome to the Official Tor Browser Hacking Guide. This page is meant to give you an overview of how to get started with Tor Browser development.

This page covers building the browser, debugging the browser, how we communicate and use trac to organize our issues and development process, what goes into the browser itself, and also provides links to other development resources and information.

Ways to Build Tor Browser

The first thing you probably want to know is how to obtain the very latest (and sometimes greatest) Tor Browser builds, and how to build your own version of the Tor Browser from our source code. Well wait no further.

Nightly Builds

Currently, nightly builds are available on a .onion site managed by boklm who is part of the Tor Browser team. If you are prompted for a username and password to access the nightly builds, use "tor-guest" as both the username and password.

As with all of our builds, it should be possible to reproduce byte-for-byte identical versions of all of those binaries from source. To learn how to do that, read on.

Building Official Tor Browser Release Binaries

Our build system is based on rbm, which is developed by boklm. rbm is using runc to provide a clean, controlled, reproducible build environment in a fully automated fashion. We further wrap rbm with our own helper scripts that download and authenticate inputs, and automate building and assembling each component piece of the browser into a final set of output packages for Linux, MacOS, and Windows. This is done with code in the tor-browser-build repository.

This system enables us to provide secure, verifiable, byte-for-byte reproducible builds to ensure the integrity of our binaries and to protect the build process from compromise. We have written a pair of blog posts that describe in more detail why this is important, and the technical details behind how this previously got achieved when using the Gitian system, if you are curious. The new build system based on rbm is working similarly and is facing pretty much the same issues.

To build the Tor Browser, you need essentially a Linux system with runc support. Once that is done, check out a copy of the tor-browser-build repo with:

git clone
cd tor-browser-build

After that you might need to install the additional dependencies mentioned in the README file and you should be able to run 'make', 'make alpha', 'make nightly', or 'make testbuild' to build the entire bundle for all three platforms. The build scripts will detect any additional packages or configuration you need to perform on your system.

Inside that directory you will also see a README.BUILD_ERRORS file with further information, should you run into any issues.

Reproducing an Existing Build

The Tor Browser build process is using signed tags for official builds. Stable tags follow the scheme 'tbb-X.X.X-buildN' where 'X' are figures building the version number (like '7.5') and 'buildN' specifies the build number for this particular browser version (e.g. 'build3'). Tags for the alpha releases are similar but contain an 'a' in it like 'tbb-8.0a1-build3'.

Once you know which version you want to reproduce check out the tag containing the latest build number and start doing a 'make' if it is a stable version or 'make alpha' if it is part of the alpha series.

At the end of the build you should end up with a 'sha256sums-unsigned-build.txt' file containing all the SHA-256 sums of the bundles and related packages in alpha/unsigned/your-tor-browser-version (or release/unsigned/your-tor-browser-version, respectively). They should match the official hash sums we have produced.

Be aware that this process is not fully future-proof. In particular, if Debian has updated their development tool chain since the bundles have been built, you may encounter differences between your resulting bundles and the original binaries. This should be rare, however, as we use only the "Long Term Support" or "Oldstable" of Debian in our build VMs. The only reason they should change the tool chain is in the event of serious security issues in the development tools themselves.

Partial Builds

This section is mostly of interest to developers making changes to Tor Browser or its components, and who wish to test their patches.

Building Just Firefox

If you want to just develop on the browser without messing with rbm (for example, to have incremental rebuilds of just the files you modify), the best way is to build a new browser distribution and copy the result over an existing Tor Browser directory. Clone the Tor Browser repo.

To build it, from the top directory of the tor-browser repo, do:

# Install a subset of the packages listed in
# Mostly, we don't need `libiw-dev` or `faketime`, but we *do* need `pkg-config`.

sudo torsocks apt-get install \
    --no-install-suggests --no-install-recommends \
    zip \
    unzip \
    libglib2.0-dev \
    libgconf2-dev \
    libgtk2.0-dev \
    libdbus-1-dev \
    libdbus-glib-1-dev \
    yasm \
    libasound2-dev \
    libcurl4-openssl-dev \
    libxt-dev \
    mesa-common-dev \
    autoconf \
    autoconf2.13 \
    libtool \
    hardening-wrapper \
    libgstreamer-plugins-base0.10-dev \
    pkg-config \
    g++ \

# On Ubuntu 17.10 gcc and g++ are version 7
# when used firefox gets a bunch of weird rendering issues so we have to force usage of gcc and g++ version 6

sudo torsocks apt-get install gcc-6 g++-6

# Add following lines to .mozconfig in tor-browser root:
export CC=gcc-6
export CXX=g++-6

# If you are building a nightly build or a release starting with 9.0a1, include the sources of tor-launcher to the browser/extensions repository.
git clone
mv tor-launcher browser/extensions/

# Generate the configure scripts:
./mach configure --with-tor-browser-version=tbb-nightly --with-distribution-id=org.torproject --enable-update-channel=default --enable-bundled-fonts

# And... compile and package:
./mach build
./mach build stage-package

# Point the INSTDIR at an existing TBB directory:
export INSTDIR="$HOME/tbb/test/tor-browser_en-US"

# Move the compiled firefox on top of the old TBB browser dir:
cp -a obj-*/dist/firefox/* $INSTDIR/Browser/

# If you want a smaller binary to copy into a vm/other machine for tests:
strip --strip-all $INSTDIR/Browser/*
rm -f $INSTDIR/Browser/firefox-bin

If that completes successfully, then your fresh build of Firefox should exist at $INSTDIR/Browser/firefox. Free the lizard.

Building Just Tor Launcher Or Torbutton

If you are only modifying one of our support addons (such as Tor Launcher or Torbutton) then you only need to create a new XPI and then copy it into an existing bundle.

For Tor Launcher:

# Point the INSTDIR at an existing TBB directory:
export INSTDIR="$HOME/tbb/test/tor-browser_en-US"

git clone
cd tor-launcher
# do some work
make package # should give you an xpi under ./pkg. Note the full filename and version in the output
cp pkg/tor-launcher- $INSTDIR/Browser/TorBrowser/Data/Browser/profile.default/extensions/

For Torbutton:

# Point the INSTDIR at an existing TBB directory:
export INSTDIR="$HOME/tbb/test/tor-browser_en-US"

git clone
cd torbutton
# do some work
./ # Will create an xpi in pkg, but you need to find the version for the next step
cp pkg/torbutton- $INSTDIR/Browser/TorBrowser/Data/Browser/profile.default/extensions/

Now, you should be able to start Tor Browser in $INSTDIR normally. To run multiple copies at once, see the next section.

Building Orfox

This section is of interest to developers making changes to the closest version of Tor Browser on Android or its components (e.g. Orbot), and who wish to test their patches.


If you're familiar with Tor Browser and how it uses two repositories, tor-browser.git and tor-browser-build.git, then Orfox similarly uses two repositories, too.

The first repo is tor-browser.git.

The second repo is the Orfox repo. This serves the same purpose as tor-browser-build.

Compiling Orfox

If you simply want to build an Orfox APK, then these are the instructions for you. We assume you are using a Debian Jessie (OldStable) environment.

1) Clone tor-browser.git

  • As mentioned above, unfortunately there are different git repositories depending for the current stable branch (Tor Browser 7.5) and the alpha branch (Tor Browser 8.0)
  • If you are building the stable branch then you can clone sysrqb's user repo
  • If you are building the alpha branch, then you can use the official Tor Browser git repo


$ git clone
# or
$ torsocks git clone http://dccbbv6cooddgcrq.onion/user/sysrqb/tor-browser.git


$ git clone
# or
$ torsocks git clone http://dccbbv6cooddgcrq.onion/tor-browser.git

This will take some time, please be patient.

2a) Checkout the stable branch

$ cd tor-browser
$ git checkout Orfox-tor-browser-52.7.3esr-7.5-1

2b) Checkout the alpha branch

$ cd tor-browser
$ git checkout tor-browser-52.7.3esr-8.0-1

The full checkout is ~3.2 GB.

3) There are many dependencies for building Firefox (and Tor Browser). Mozilla provide a mechanism for downloading and installing everything needed. This does require root access via sudo.

$ ./mach bootstrap

At the first menu, you most likely want option "4. Firefox for Android".

This downloads all the needed Android dependencies, as well. Sadly, the script doesn't verify the binaries downloaded from Google's servers.

4) If you don't have mercurial already installed, it will prompt. Using apt, option 2, is good enough (but you can select installing from pip if you want).

5) Boostrap checks the installed python version, if it is new enough then it will tell you

Your version of Python (2.7.9) is new enough.

6) Ready for building! Hopefully you have a message like this (if not, please ask us for help if you can't find why):

Your system should be ready to build Firefox for Android!

Paste the lines between the chevrons (>>> and <<<) into your mozconfig file:

# Build Firefox for Android:
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi

# With the following Android SDK and NDK:
ac_add_options --with-android-sdk="/home/<user>/.mozbuild/android-sdk-linux"
ac_add_options --with-android-ndk="/home/<user>/.mozbuild/android-ndk-r11b"

Don't copy those lines into your mozconfig (except if you really want to and/or you know what you're doing). We already have a mozconfig for Orfox and we'll use that, instead.

7) Build tools. The bootstrap script expects a different version of the Android Build Tools than is actually available with the SDK version. It wants build-tools-23.0.3 but build-tools-23.0.1 is available.

We are now installing the following Android packages:
tools, platform-tools, build-tools-23.0.3, android-23, extra-google-m2repository, extra-android-m2repository
You may be prompted to agree to the Android license. You may see some of
output as packages are downloaded and installed.

Refresh Sources:
  Validate XML
  Parse XML
  Fetched Add-ons List successfully
  Refresh Sources
Error: Ignoring unknown package filter 'build-tools-23.0.3'

As a short-term workaround, we'll manually install older version and then symlink them.

$ ${HOME}/.mozbuild/android-sdk-linux/tools/android update sdk --no-ui --all --filter build-tools-23.0.1
$ # Accept the license agreement

Installing Archives:
  Preparing to install archives
  Downloading Android SDK Build-tools, revision 23.0.1
  Installing Android SDK Build-tools, revision 23.0.1
    Installed Android SDK Build-tools, revision 23.0.199%)
  Done. 1 package installed.
$ ln -s ${HOME}/.mozbuild/android-sdk-linux/build-tools/23.0.{1,3}

The last line abuses a bash-ism - Brace Expansion.

Excellent! Now we'll set the MOZCONFIG environment variable as the mozconfig we want to build, and we'll set the SDK and NDK paths.

$ export MOZCONFIG=.mozconfig-orfox
$ export NDK_BASE=${HOME}/.mozbuild/android-ndk-r11b/
$ export SDK_BASE=${HOME}/.mozbuild/android-sdk-linux/

And now three more steps, we configure, build, and package Orfox!


$ ./mach configure
 0:04.75 Creating config.status
 0:04.80 Reticulating splines...
 0:09.69 Finished reading 799 files in 1.48s
 0:09.69 Processed into 6210 build config descriptors in 0.99s
 0:09.69 RecursiveMake backend executed in 2.15s
 0:09.69   1775 total backend files; 0 created; 0 updated; 1775 unchanged; 0 deleted; 42 -> 621 Makefile
 0:09.69 FasterMake backend executed in 0.12s
 0:09.69   6 total backend files; 0 created; 0 updated; 6 unchanged; 0 deleted
 0:09.69 Total wall time: 4.90s; CPU time: 4.70s; Efficiency: 96%; Untracked: 0.15s
 0:09.73 =============
 0:09.73 You are building Firefox for Android. After your build completes, you can open
 0:09.73 the top source directory in IntelliJ or Android Studio directly and build using
 0:09.73 Gradle.  See the documentation at
 0:09.73 You should verify any changes using |mach build|.
 0:09.73 =============
Configure complete!
Be sure to run |mach build| to pick up any changes


$ ./mach build
22:23.59 Overall system resources - Wall time: 1343s; CPU: 52%; Read bytes: 92479488; Write bytes: 5720313856; Read time: 47564; Write time: 3477320
22:23.59 Swap in/out (MB): 0/0
22:24.01 ccache (direct) hit rate: 0.0%; (preprocessed) hit rate: 0.0%; miss rate: 100.0%
22:24.03 Notification center failed: Install the python dbus module to get a notification when the build finishes.
22:24.03 We know it took a while, but your build finally finished successfully!
To view resource usage of the build, run |mach resource-usage|.
For more information on what to do now, see


$ ./mach package
 0:29.63 Verification succesful
 0:29.63 Testing is disabled - No Android Robocop for you
 0:29.63 Install bouncer is disabled - No trampolines for you
 0:29.63 make[3]: Leaving directory '/home/user/tor-browser/obj-tbb-arm-linux-androideabi/mobile/android/installer'
 0:29.63 make[2]: Leaving directory '/home/user/tor-browser/obj-tbb-arm-linux-androideabi/mobile/android/installer'
 0:29.63 make[1]: Leaving directory '/home/user/tor-browser/obj-tbb-arm-linux-androideabi/mobile/android/installer'
 0:29.63 make: Leaving directory '/home/user/tor-browser/obj-tbb-arm-linux-androideabi'
 0:29.64 Notification center failed: Install the python dbus module to get a notification when the build finishes.

The resulting, packaged, APK is under obj-tbb-arm-linux-androideabi/dist

 ls -l obj-tbb-arm-linux-androideabi/dist/fennec*.apk
-rw-r--r-- 1 user user 29689027 Mar 26 12:19 obj-tbb-arm-linux-androideabi/dist/
-rw-r--r-- 1 user user 29801794 Mar 26 12:19 obj-tbb-arm-linux-androideabi/dist/

You can use the second .apk for testing, the first should be signed with the appropriate signing key and distributed.

Mozilla have nice documentation and you may find it helpful.

Orfox Release

First, you need to check out a copy of the Orfox browser:

git clone
cd Orfox

That is it, if you want to run it, you can use the Android adb tool or

./mach run

It will install and run in your android device.


If you want to modify Orbot, this section is for you:


Dependency version
Android SDK Tools 25
Android Build Tools 26.0.2
Android NDK r11b

Fetching and Building

First, you need to check out a copy of the orbot repo with:

git clone
cd orbot
git submodule update --init --recursive

To build it (in debug mode), from the top directory of the orbot repo, do:

./gradlew assembleDebug

The command will generate an APK (self signed) that can be used in you device or simulator.

Running Multiple Tor Browsers

Now that you have a developer build (or several builds), you probably want to know how to run more than one of them at once. There are two main ways to do this: reusing an existing Tor process, and launching Tor process on a new pair of SOCKS and Control ports.

Using an Existing Tor Process

Let's assume that Tor process is listening on port 9150 for SOCKS, and 9151 for the control port.

export TOR_SOCKS_PORT=9150
export TOR_CONTROL_PORT=9151
export TOR_CONTROL_COOKIE_AUTH_FILE=~/tbb/tor-browser_en-US/Browser/TorBrowser/Data/Tor/control_auth_cookie

cd $INSTDIR # from the 'Partial Builds' section above

Launching Tor with an Alternate SOCKS and Control port

If you need to test Tor Launcher changes, you probably want to launch the Tor process too. Here's a quick hack to put that on a different port pair (9250 and 9251):

export TOR_SOCKS_PORT=9250
export TOR_CONTROL_PORT=9251

cd $INSTDIR   # From the 'Partial Builds' section above

Tor Browser Team Communication and Organizational Patterns

The Tor Browser development team is very geographically distributed. We use a few different written forms of communication to discuss development over the Internet: Mailing lists, IRC, and this bug tracker. We also hold weekly IRC meetings.

Communication Mechanisms and Meetings

The mailinglist for Tor Browser development discussion is tbb-dev. You can also subscribe to the list of Tor Browser code commits via tbb-commits. All updates to Tor Browser specific bugs are sent to tbb-bugs. Release tags and test builds are posted to tor-qa for community review and testing.

Our primary mode of day-to-day communication is the #tor-dev IRC channel on (port 6697 is ssl). We hold weekly meetings on this IRC channel at 19:00 UTC on Mondays. For details on our meeting format, please see the original meeting announcement post (note however that the time has changed since that posting).

How we use Trac

For historical reasons, Tor Browser tickets are spread across several Trac components: "Tor bundles/installation", "TorBrowserButton", "Firefox Patch Issues", and "Tor Launcher". We are considering consolidating many of these components and switching to keywords instead, but that hasn't happened yet.

Trac Keywords

What follows is a partial list of trac keywords we use to categorize issues, independent of the component they actually arise in.

Tickets that represent reported crash or hang issues
Tickets that represent usability issues. Has many subcategories as suffixes of tbb-usability.
Tickets that represent usability issues that cause users to be unable to use TBB (this is a subset of the previous query)
Tickets that represent frequently encountered support issues or blog/twitter commentary
Tickets that represent a violation of our identifier unlinkability Privacy Requirement.
Tickets that represent a violation of our fingerprinting unlinkability Privacy Requirement. There are many subcategories of this tag as suffixes.
Tickets that represent a violation of our Disk Avoidance Security Requirement.
Tickets for problems with "New Identity"
Tickets for which we would like to have an automated testcase to prevent regressions.
Tickets for hardening TBB against exploitation.
Tickets in other Tor components that TBB needs solved.
Tickets for work on Tor Browser for mobile in particular
Tickets for work on Tor Browser's design documentation
Tickets for work on Tor Browser's security slider
Tickets for work on Tor Browser's update related code.
Tickets for work on feature parity between Tor Browser on different platforms.
Tickets that we could consider for backporting from the current alpha to the current stable series. The keyword gets cleared with every new major stable release and the cycle start from the beginning.

In addition to this list, if you would like someone to review a patch, you should set the state of that ticket to "needs review" and tag it that that person's name, followed by the year, the month, and the letter 'R'. For example: MikePerry201311R.

Design and Core Components

Ok, so you've got the lay of the land now, and want to really dive in. Here's how everything is organized.

Design Document

At a high level, Tor Browser development is driven by the design document: The Design and Implementation of the Tor Browser. This document specifies the Design Requirements and Philosophy that guides our development decisions and our modifications to Firefox, provides an adversary model, and provides a high level description of the actual changes we have made to Firefox.

Component Source Repositories

The Tor Browser is actually built from several components. Here are the main ones specific to the browser itself.

Firefox Branch Repo

We maintain a branch of the latest Firefox "Extended Support Release" (ESR) series, to which we have applied multiple patches to satisfy our design requirements and build security needs.

These branches live in the tor-browser git repo. The branches are named for the Firefox version they are based off of, along with an integer signifying a rebase number. To learn which branch a particular build uses, inspect its version file. The version file lists a tag for the specific commit used. This tag is derived from the branch name and an additional specific build number.


Torbutton is an addon with a long and storied history. It originated as ProxyButton (a simple Firefox addon to toggle proxy settings), which was rethemed by Scott Squires and configured specifically for Tor's proxy settings. After that initial work, Mike Perry began development to address the numerous security issues that arose when browser state from non-Tor activity leaked into Tor browsing mode, and vice-versa. This toggle mode was deprecated in favor of a standalone browser several years back.

As a result, Torbutton contains a lot of cruft code specific to the toggle behavior that has not yet been removed, but is otherwise inactive. However, it still provides a few privacy features by way of observers and other extension-level changes to Firefox to improve privacy and Tor security.

Tor Launcher

Tor Launcher is a Firefox addon that acts as a Tor Controller. It handles launching and configuring Tor for use with the browser. It also is compatible with Thunderbird, InstantBird, and XULRunner, and is used by the Tails project as well.


HTTPS-Everywhere contains tens of thousands of URL rewrite rules to enforce HTTPS for sites that support both HTTP and HTTPS URL schemes.


We don't modify NoScript directly, however we do have a number of preferences changes to it and other addons in the tor-browser-bundle preferences file in the bundle layout directories.

If you're interested in bisecting or otherwise tracking down a particular NoScript change, bug, or issue, avian2 maintains a complete git repository for NoScript, with one commit per NoScript release (including alphas, betas, and rc releases).

Pluggable Transports

Tor Browser includes several pluggable transports, which are a network traffic transformation layer to help avoid censorship and filtering mechanisms. If you are interested in getting your own pluggable transport added to the bundle, the FTE transport work is a good example to follow.

The original ticket for FTE is a good starting point. It resulted in a clean branch that merged easily.

Pluggable Transport Bridges are specified in the bridge_prefs.js configuration file in the Bundle Skeleton directory.

Debugging the Tor Browser

There are a few different ways to debug the Tor Browser, depending on the component involved. We'll focus on the extensions and the browser itself here.

Enabling debug logs in extensions

To enable extension debug logging, set these preferences in your about:config:

extensions.torbutton.loglevel 2
extensions.torbutton.logmethod 0
extensions.https_everywhere.LogLevel 2
extensions.https_everywhere.log_to_stdout true
extensions.torlauncher.loglevel 2
extensions.torlauncher.logmethod 0

Lower levels are more verbose, but if you go much below 2, you will likely be overwhelmed and/or the browser will be extremely slow.

If you want to save your logs to a file, you need to use the --log argument to start-tor-browser.desktop. It takes an optional filename. Without a filename, it writes tor-browser.log in the current directory:

$ ./start-tor-browser.desktop --log
$ tail -f tor-browser.log

Offline Logging/Tracing

Sometimes you need to resort to printf style debugging (for instance, on platforms which do not have debug symbols) or you are diagnosing a race condition that's highly sensitive to timing. In such cases, check out TbbLogger ( ).

Apply the TbbLogger.patch to your firefox sources and you will be able to include the TbbLogger.h header throughout the firefox code base. This header defines two macros for your enjoyment: TBB_LOG(format-string, ...) and TBB_TRACE().

The TBB_LOG macro allow tracing using fmtlib ( ) formatting with some extra debug info: timestamp, parent/child content process, thread id, and log location. The TBB_TRACE macro does not include any message. This information, plus your format-string and args, are serialized to disk on a background thread as a binary blob. Logs are converted to plain-text via an offline 'aggregate' tool which will convert the binary blob to formatted messages sorted by timestamp. The timestamps ensure that messages are written in the order they actually happened, even between the parent and child content processes.

Example Usage


    #include "TbbLogger.h"
    void function_name()
        int some_int = 100;
        double some_double = 34.0;
        TBB_LOG("This is some logging %i %f", some_int, some_double);  


$ ./aggregate /tmp/firefox/*.bin 
[0.000323][Parent][29958] function_name in Test.cpp:18 
[0.000324][Parent][29958] function_name in Test.cpp:22 This is some logging 100 34.000000

Using the Javascript Debugger

XXX: Write or link to some documentation on using Venkman/JSD for extension debugging. There are two options for this: Venkman and the in-browser debugger. For TBB pre-5.0, Venkman was the way ( However, it is no longer supported. Instead, the built-in debugger must be used:

Debugging on Windows

Firstly, ignore the 'Using gdb' section immediately after this one, that's only for Linux. Then go to DebuggingOnWindows

Using gdb

Using Debug Symbols

If you're going to use GDB to debug an issue, the first thing you want is debug symbols. Tor Browser builds detached debug symbols for tor and firefox.

In the bundle release download directory there should be a file. Unfortunately, the directory structure of the debug zip doesn't exactly match what you need in order for gdb to find the symbols automatically. For the tor-browser-linux symbols, unzip the file in the bundle root directory, and then relocate it to the .debug subdirectory of Browser, like so:

$ cd tor-browser_en-US
$ wget
$ tar xavf tor-browser-linux64-debug.tar.xz
$ mv Debug/Browser Browser/.debug
$ gdb ./Browser/firefox.real

At this point, gdb should find all of the Firefox symbols automatically upon every invocation, and you can either attach to an existing process ID or launch firefox directly, as described in the following sections below.

Attaching an already running TBB

You can attach a gdb instance to an already running TBB firefox process. To do this, find the pid of your running TBB firefox.real, then tell gdb to attach the running process (note that on some systems you may need to run gdb as root for this to work):

$ for p in `pgrep firefox.real` ; do ps -v $p ; done
[...find the pid for your TBB firefox...]
$ gdb ./Browser/firefox.real
(gdb) attach <pid>

Starting firefox from inside gdb

Assuming you run an alpha build, starting firefox inside gdb:

 $ gdb ./Browser/firefox.real
 (gdb) set env LD_LIBRARY_PATH=Browser/TorBrowser/Tor
 (gdb) set env SELFRANDO_skip_shuffle=
 (gdb) run -profile Browser/TorBrowser/Data/Browser/profile.default

Generating and debugging core files

If you have a condition that crashes Tor Browser in an unreliable way, one helpful step is to generate a core file for crashes that do happen. To do this, before launching Tor Browser, run:

$ ulimit -c unlimited

Then, when Tor Browser crashes, a core file should show up in Browser/core. To debug this core, run:

$ gdb ./Browser/firefox ./Browser/core

You can then use the usual gdb commands (backtrace, print, up, down, etc) to inspect the stack, variables, and program state at the time of the crash.

Debugging ASan/selfrando builds

If you need to debug a hardened build that includes ASan and selfrando you have two options.

Temporarily disable selfrando

If you set the environmental variable SELFRANDO_skip_shuffle, selfrando will be disabled and gdb will work as usual. E.g.:

$ gdb -ex "set env LD_LIBRARY_PATH=$PWD/Browser/TorBrowser/Tor" -ex "set env SELFRANDO_skip_shuffle=" \
        -ex 'set env ASAN_OPTIONS="detect_leaks=0,abort_on_error=1"' -ex "set env NSS_DISABLE_HW_AES=1" \
        --args Browser/firefox -profile Browser/TorBrowser/Data/Browser/profile.default/

Convert ASan's stack trace message

This method can be used only to debug a crash. Start Tor Browser with Browser/start-tor-browser -v. After the browser crashes, you will see one or more stack traces that look like this:

==3896==ERROR: AddressSanitizer: heap-use-after-free on address 0x6040003b85e0 at pc 0x7f5dff50f35d bp 0x7ffe516e3a90 sp 0x7ffe516e3a88
READ of size 4 at 0x6040003b85e0 thread T0
SRAT init
    #0 0x7f5dff50f35c  (/path/to/directory/tor-browser/Browser/
    #1 0x7f5dfe153916  (/path/to/directory/tor-browser/Browser/
    #2 0x7f5e001ae7f6  (/path/to/directory/tor-browser/Browser/
    #43 0x418d98  (/path/to/directory/tor-browser/Browser/firefox+0x4089dc)
    #44 0x7f5e0b0d8f44 in __libc_start_main (/lib/x86_64-linux-gnu/
    #45 0x41e9dc  (/path/to/directory/tor-browser/Browser/firefox+0x408e34)

To get a meaningful stack trace you need to install a symbolizer (you can install clang and use llvm-symbolizer). Then, copy the relevant text from ASan's output, pipe it trough and then into the symbolizer. E.g.:

$ xsel -b | ./ | llvm-symbolizer-3.4

The script assumes that debug information is available in Browser/.debug (see Using Debug Symbols).

Using dtrace

Dtrace is a very powerful tracing and debugging system that requires kernel support, however all the grown-up Operating Systems support it (not supported by Linux). Like many of the powerful creations of Unix, dtrace immediately gave rise to an orgy of one-liners. That is, one-line dtrace programs that perform a useful task! Like awk, there are many such dtrace one-liners that people have documented and are still useful today, often with little or no modification. In fact, you can utilize both dtrace and awk in the same command pipeline to create something even more expressive!

The IllumOS (the new OpenSolaris) kernel has support for Linux zones which can run native x86 32bit and 64bit binaries in an isolated environment. They have done such a good job at this Linux binary system call emulation that it can run all the normal stuff including systemd and other monstrosities such as htop. ;-p My Debian 8 image indeed acts like a normal Debian 8 system... although it is definitely not running the Linux kernel.

The host's global zone can be used to dtrace native Linux and Solaris zones. Tor Browser Bundle runs fine using the Linux zones.

Isolating tor applications with SmartOS

onion -> noVNC http -> vnc4server -> tbb

more dtrace examples

dtrace examples for Tor Browser Bundle

Many of these examples collect dtrace probe information until the operator hits control-c. I found many dtrace exmamples. Here's some that might be useful:

Which files does firefox open?

dtrace -n 'lx-syscall::open*:entry /execname == "firefox"/ { printf("%s %s", execname, copyinstr(arg0)); }
dtrace: description 'lx-syscall::open*:entry ' matched 6 probes
CPU     ID                    FUNCTION:NAME
  0   3874                       open:entry firefox /dev/urandom
  0   3874                       open:entry firefox /home/human/tor-browser_en-US/Browser/TorBrowser/Tor/
  0   3874                       open:entry firefox /etc/
  0   3874                       open:entry firefox /lib/x86_64-linux-gnu/
  0   3874                       open:entry firefox /usr/lib/x86_64-linux-gnu/
  0   3874                       open:entry firefox /lib/
  0   3874                       open:entry firefox /usr/lib/
  0   3874                       open:entry firefox /home/human/tor-browser_en-US/Browser/TorBrowser/Tor/
  0   3874                       open:entry firefox /etc/
  0   3874                       open:entry firefox /lib/x86_64-linux-gnu/
  0   3874                       open:entry firefox /usr/lib/x86_64-linux-gnu/
  0   3874                       open:entry firefox /lib/
  0   3874                       open:entry firefox /usr/lib/
  0   3874                       open:entry firefox /dev/urandom
  0   3874                       open:entry firefox /dev/urandom

syscall frequency count

dtrace -n 'lx-syscall:::entry /pid == 44622/ { @num[probefunc] = count(); }'
dtrace: description 'lx-syscall:::entry ' matched 676 probes

  read                                                            725
  write                                                           725
  writev                                                         1400
  futex                                                          3548
  poll                                                           5686
  recvmsg                                                        6911
  clock_gettime                                                 17440

function and module top 10 frequency count lx_proc_func_count.d

#!/usr/sbin/dtrace -s
pid$target:::entry { 
@a[probemod,probefunc] = count(); 
END { trunc(@a,10); }
./lx_proc_func_count.d -p 44622
dtrace: script './lx_proc_func_count.d' matched 30865 probes
CPU     ID                    FUNCTION:NAME
  0      2                             :END 

  firefox                                             realloc                                                       31609                                      moz_xmalloc                                                   33383                                      moz_free                                                      36504
  firefox                                             malloc                                                        50687
  firefox                                             free                                                          54604                                     pthread_self                                                  58444                                     pthread_getspecific                                           69741                                     pthread_mutex_unlock                                         204393                                     pthread_mutex_lock                                           204394                                     __pthread_mutex_unlock_usercnt                          


#!/usr/sbin/dtrace -s
#pragma D option quiet
PROTO values can be found here:
SOCKOPT values can be found here:
        printf("%6s %20s %5s %s\n", "PID", "NAME", "PROTO", "SOCKOPT");
        printf("%6d %20s %5d %d\n", pid, execname, arg1, arg2);
   PID                 NAME PROTO SOCKOPT
 44622              firefox     6 1
 15388                  tor     1 2
 44622              firefox     6 4
 44622              firefox     6 5
 44622              firefox     6 6
 44622              firefox     6 4
 44622              firefox     6 5
 44622              firefox     6 6
 44622              firefox     1 9
 44622              firefox     6 4
 44622              firefox     6 5
 44622              firefox     6 6
 44622              firefox     1 9

track malloc allocations

dtrace -n 'pid8880::malloc:entry { printf ("Firefox is asking for %d bytes", arg0); }'  

  0  74421                     malloc:entry Firefox is asking for 24 bytes
  0  74421                     malloc:entry Firefox is asking for 48 bytes
  0  74421                     malloc:entry Firefox is asking for 16 bytes
  0  74421                     malloc:entry Firefox is asking for 32 bytes
  0  74421                     malloc:entry Firefox is asking for 16 bytes
  0  74421                     malloc:entry Firefox is asking for 8176 bytes

in real-time, find all the code modules which utilize malloc:

  dtrace -l -n 'pid$1::malloc:entry' 1774

     ID   PROVIDER            MODULE                          FUNCTION NAME
   74421    pid1774           firefox                            malloc entry
   74578    pid1774      LMfd`                            malloc entry
   75306    pid1774 LMfd`                            malloc entry
   76053    pid1774    LMfd`                            malloc entry
   84541    pid1774                            malloc entry
   85794    pid1774                            malloc entry


If you found a bug and want to start bisecting to find the exact commit which introduced the problem you have three major cases to consider.

The easy case

You found your bug is part of either Torbutton, Tor Launcher or HTTPS-Everywhere. In this case you check out the respective repository and do the usual bisecting there. To test the various revisions you can take a clean Tor Browser and load the .xpi's into it. Theoretically, this would work in the NoScript case as well but unfortunately there is no public version control system available and thus if you found a bug in NoScript you need to identify the version it showed first up manually and file a ticket.

The medium difficult case

Okay, you ruled out a bug in one of the extensions we ship and determined it got introduced by one of our Tor Browser patches or changes to the bundling/build process (testing whether the bug occurs in a corresponding vanilla Firefox is helpful here). The first thing you are doing now is finding out which Tor Browser version is the one that introduced the bug. Using the Tor Browser archive is a good starting point. If you found the culprit and the bug did not get introduced while switching to a new Firefox ESR (the next section deals with the switching case) chances are high that you don't need to bisect at all. Comparing the changelogs between the last version without the bug and the first version with the bug should be enough in this case. But if the changelogs don't ring a bell and you suspect this is a bug introduced by the build process/bundling looking at the changes introduced in the tor-browser-bundle repository between the two Tor Browser releases should reveal the bad commit. If the changelogs don't help and you suspect an issue with one or more of our Tor Browser patches you need to clone the tor-browser repository and do a normal bisect following the Partial Builds strategy outlined above between the last tor-browser patch of the good Tor Browser and the last tor-browser patch that got into the bad Tor Browser.

The tricky case

The patchset effectively did not change and you are only switching to a new ESR. There could be three reasons for the bad Tor Browser then. The first one: rebasing one or more patches went wrong. The second one: some change in the new ESR is causing the trouble. The third one: a combination of the first two. The strategy to deal with this group of cases is to rule out the first one (and thus the third one as well) and then narrow down the possible patches that could be affected by changes in the new ESR. These patches in turn are applied during bisecting the commits in the mozilla-central repository that made it into the bad Tor Browser.

Testing in TaskCluster

If you suspect there is an issue with Tor's toolchain, you can use Tor's toolchain in taskcluster relatively easily, like so:

QA and Testing

Some automated tests are run on nightly builds, and new releases. The main page for the results is

If you want to run the test suite yourself, read the installation instructions, and the usage instructions. You can also learn how to add a new test.

The different categories of tests we are running are described below.

Tor Browser Test Suite

This test suite contains a series of tests to check a Tor Browser Bundle. It is used to check different things:

  • the binaries included in the bundle are correctly linked and compiled
  • the tor daemon is working, with bridges, some pluggable transports and with an http proxy
  • some mozill and selenium tests

The list of tests is defined in TBBTestSuite/TestSuite/ Documentation for adding new tests is available.

This test suite is automatically run in the following cases:

  • when a Tor Browser developer created a tbb-qa.yml file to request a build to be test. The result of the tests is emailed to the developer requesting the tests. See the section below for details about requesting tests on custum builds.

VirusTotal uploads

The Windows version of the Tor Browser .exe file is uploaded to to check it with different antivirus. All executable files included in the archive are also uploaded.

The uploads are automatically done in the following cases:

Browser Unit Tests

The Browser Unit Tests are the tests which are included in the Mozilla sources tree (xpcshell and mochitests). The Tor Browser patches can add new tests to be run. Before running those tests, we need to build the sources tree.

We are able to run those tests on a series of commits, and display the differences in the results between each commits and its ancestor.

It is not currently run automatically. In the future, it should be possible to specify a commit or branch to be tested, by editing the tbb-qa.yml file. Until then, you can ask me to edit the config file to test a specific branch or commit.

Rebasing Tests

A prototype for a rebasing tests has been made. The goal is to try to automatically rebase all Tor Browser patches on the master branch of gecko-dev.

It is not yet run automatically.

Requesting testing of a custom build using the tbb-qa.yml file

To request a custom build to be tested, you need an account on and be listed in the config/testrequests file (ask me if you want to be added).

Upload your build to perdulce in directory ~public_html/builds/x.y.z-featureA

Create a file public_html/builds/tbb-qa.yml with permission 744 and a list of build directory names using the YAML syntax:

 - x.y.z-featureA

You should receive an email on your email address when the tests finished running. Make sure to include a proper sha256sums.txt file and its signature in the respective build directory.

The tbb-qa.yml file can also be used to request other types of tests. Instead of adding a string which is a directory name in your builds directory, you can add a hash table containing the options for your test requests and a 'type' key containing the type of tests you want to run.

For instance the following tbb-qa.yml file can be used to request a test of type 'browserunit' (Tor Browser unit tests) on a specific commit:

- type: browserunit
  commit: e1a8bafb44367592b

The following types of tests are available:

Tor Browser Unit Tests (xpcshell and mochitest)

type name: browserunit


  • commit: the commit that you want to build and run tests on. This can be a commit hash, tag or branch.
  • esr_branch: using this option means that you want all commits from the Mozilla ESR branch to the selected commit to be tested. Example: esr31.
  • git_url: the URL of the git repository containing the selected commit. If unspecified, is used by default.


There are two supported way for testing (and developing) Tor Browser on Android.

  • Command line

Mozilla provide support for building and running the test suits on an emulator or a device via mach. This is the easiest and most straight forward method right now.

  • Android Studio

Android Studio provides a nice IDE for developing Android Apps. You can follow the initial build instructions for Android on this page, and then go to Mozilla's Android Studio instructions section: Developing Firefox for Android in Android Studio. Following those instructions should get you up and running.

A note on Android emulators. Mozilla Fennec required the ARM processor support NEON. Unfortunately, it seems like Android kernels compiled for older APIs don't support this (?). It's annoying. As an example, compare the CPU Features:

a stock armeabi-v7a API 18 emulator does not support that extension:

root@generic:/ # uname -a
/system/bin/sh: uname: not found
126|root@generic:/ # cat /proc/sys/kernel/osrelease                            
root@generic:/ # cat /proc/sys/kernel/ostype                                   
root@generic:/ # cat /proc/sys/kernel/version                                  
#8 SMP PREEMPT Mon May 23 14:53:39 PDT 2016
root@generic:/ # cat /proc/sys/kernel/hostname                                 
root@generic:/ # cat /proc/cpuinfo                                             
processor	: 0
model name	: ARMv7 Processor rev 1 (v7l)
BogoMIPS	: 125.00
Features	: swp half thumb fastmult vfp edsp vfpv3 tls vfpv4 idiva idivt vfpd32 evtstrm 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x2
CPU part	: 0xc0f
CPU revision	: 1

Hardware	: Dummy Virtual Machine
Revision	: 0000
Serial		: 0000000000000000

a stock armeabi-v7a API 24 emulator does support that extension:

generic:/ $ uname -a
Linux localhost 3.10.0+ #1 SMP PREEMPT Wed May 18 00:25:13 UTC 2016 armv7l
generic:/ $ cat /proc/cpuinfo
processor	: 0
model name	: ARMv7 Processor rev 1 (v7l)
BogoMIPS	: 125.00
Features	: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 evtstrm 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x2
CPU part	: 0xc0f
CPU revision	: 1

Hardware	: Dummy Virtual Machine
Revision	: 0000
Serial		: 0000000000000000


FPCentral is a tool which was created by Pierre Laperdrix as a Google Summer of Code project. We use this tool to detect changes in the fingerprint of new Tor Browser releases.

An instance of FPCentral is available at the following URL:

The git repository containing the sources is at:

The tests for the different fingerprint attributes are defined in the fingerprint/attributes directory. If you want to add a new test, you will need to create a javascript file containing a function returning an attribute value, and a json file describing this attribute. See the file for more details.

When you run the fingerprint tests using Tor Browser, it should tell you if all attributes have an acceptable value. The list of acceptable values for each attribute is defined in the fingerprint/acceptable/torbrowser70.json file. When adding a new attribute definition, you should also define an acceptable value in this file.

Adding New Default Bridges

The anti-censorship team takes care of adding, maintaining, and monitoring default bridges. There's a wiki page that details the process of adding default bridges to Tor Browser.

Other Resources

Last modified 6 months ago Last modified on Apr 29, 2020, 12:30:00 PM

Attachments (1)

Download all attachments as: .zip