Version 105 (modified by 13 months ago) (diff) | ,
---|
- The Tor Browser Hacking Guide
- Ways to Build Tor Browser
- Building Orfox
- Running Multiple Tor Browsers
- Tor Browser Team Communication and Organizational Patterns
- Design and Core Components
- Debugging the Tor Browser
- FPCentral
- Adding New Default Bridges
- 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.
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 https://git.torproject.org/builders/tor-browser-build.git 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 gitian (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 # https://gitweb.torproject.org/builders/tor-browser-bundle.git/tree/gitian/descriptors/linux/gitian-firefox.yml#l8 # 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++ \ libpulse-dev # 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 # Generate the configure scripts: make $CONFIGURE_ARGS -f client.mk configure CONFIGURE_ARGS="--with-tor-browser-version=tbb-nightly --with-distribution-id=org.torproject --enable-update-channel=default --enable-bundled-fonts" # And... compile: make $MAKEOPTS -f client.mk build make -C obj-* package INNER_MAKE_PACKAGE=true # 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 https://git.torproject.org/tor-launcher.git 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-0.2.7.6.xpi $INSTDIR/Browser/TorBrowser/Data/Browser/profile.default/extensions/tor-launcher@torproject.org.xpi
For Torbutton:
# Point the INSTDIR at an existing TBB directory: export INSTDIR="$HOME/tbb/test/tor-browser_en-US" git clone https://git.torproject.org/torbutton.git cd torbutton # do some work ./makexpi.sh # Will create an xpi in pkg, but you need to find the version for the next step cp pkg/torbutton-1.9.3.1.xpi $INSTDIR/Browser/TorBrowser/Data/Browser/profile.default/extensions/torbutton@torproject.org.xpi
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 Tor Browser Mobile or its components (e.g. Orbot), and who wish to test their patches.
Orfox
First, you need to check out a copy of the Orfox browser and fetch all sub modules with:
git clone https://github.com/guardianproject/Orfox.git cd Orfox git submodule update --init --recursive
Later, instead of downloading dependency by dependency, you can use Mozilla bootstrap command to download all of them at once.
cd external/tor-browser ./mach bootstrap
Now we need to use the Orfox mozconfig and update it.
export MOZCONFIG=`pwd`"/external/tor-browser/.mozconfig-orfox-release"
Open the .mozconfig-orfox-release file and replace the $NDK_BASE and $SDK_BASE with the path to the installed Android NDK and SDK, respectively.
Now we can build it and generate the APK
./mach configure ./mach build ./mach package ./mach build-backend -b AndroidEclipse
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.
Orbot
If you want to modify Orbot, this section is for you:
Dependencies
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 https://github.com/n8fr8/orbot.git 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 export TOR_SKIP_LAUNCH=1 cd $INSTDIR # from the 'Partial Builds' section above ./start-tor-browser.desktop
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 unset TOR_SKIP_LAUNCH unset TOR_CONTROL_COOKIE_AUTH_FILE cd $INSTDIR # From the 'Partial Builds' section above sed -i -e 's/Port 915/Port 925/' ./Browser/TorBrowser/Data/Tor/torrc-defaults ./start-tor-browser.desktop
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 irc.oftc.net (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.
- tbb-crash
- Tickets that represent reported crash or hang issues
- tbb-usability
- Tickets that represent usability issues. Has many subcategories as suffixes of tbb-usability.
- tbb-usability-stoppoint
- Tickets that represent usability issues that cause users to be unable to use TBB (this is a subset of the previous query)
- tbb-helpdesk-frequent
- Tickets that represent frequently encountered support issues or blog/twitter commentary
- tbb-linkability
- Tickets that represent a violation of our identifier unlinkability Privacy Requirement.
- tbb-fingerprinting
- Tickets that represent a violation of our fingerprinting unlinkability Privacy Requirement. There are many subcategories of this tag as suffixes.
- tbb-disk-leak
- Tickets that represent a violation of our Disk Avoidance Security Requirement.
- tbb-newnym
- Tickets for problems with "New Identity"
- tbb-testcase
- Tickets for which we would like to have an automated testcase to prevent regressions.
- tbb-security
- Tickets for hardening TBB against exploitation.
- tbb-needs
- Tickets in other Tor components that TBB needs solved.
- tbb-mobile
- Tickets for work on Tor Browser for mobile in particular
- tbb-spec
- Tickets for work on Tor Browser's design documentation
- tbb-security-slider
- Tickets for work on Tor Browser's security slider
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
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
HTTPS-Everywhere contains tens of thousands of URL rewrite rules to enforce HTTPS for sites that support both HTTP and HTTPS URL schemes.
NoScript
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
:
SETTING NAME | VALUE |
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
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 (https://addons.mozilla.org/en-us/firefox/addon/javascript-debugger/). However, it is no longer supported. Instead, the built-in debugger must be used: https://developer.mozilla.org/en-US/docs/Debugging_JavaScript#JavaScript_Debugger
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 tor-browser-linux64-debug.zip
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 https://dist.torproject.org/torbrowser/5.0a3/tor-browser-linux64-debug.zip $ unzip tor-browser-linux64-debug.zip $ mv Debug/Browser Browser/.debug $ gdb ./Browser/firefox
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, 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` ; do ps -v $p ; done [...find the pid for your TBB firefox...] $ gdb ./Browser/firefox (gdb) attach <pid>
Starting firefox from inside gdb
Starting firefox inside gdb:
$ gdb ./Browser/firefox (gdb) set env LD_LIBRARY_PATH=Browser/TorBrowser/Tor (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/libxul.so+0x4af0a9a) #1 0x7f5dfe153916 (/path/to/directory/tor-browser/Browser/libxul.so+0x4af0d32) #2 0x7f5e001ae7f6 (/path/to/directory/tor-browser/Browser/libxul.so+0x392d7e8) [...] #43 0x418d98 (/path/to/directory/tor-browser/Browser/firefox+0x4089dc) #44 0x7f5e0b0d8f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44) #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 convert-asan-to-symbolizer.py and then into the symbolizer. E.g.:
$ xsel -b | ./convert-asan-to-symbolizer.py | 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 https://wiki.smartos.org/display/DOC/DTrace
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/libcanberra.so.0 0 3874 open:entry firefox /etc/ld.so.cache 0 3874 open:entry firefox /lib/x86_64-linux-gnu/libcanberra.so.0 0 3874 open:entry firefox /usr/lib/x86_64-linux-gnu/libcanberra.so.0 0 3874 open:entry firefox /lib/libcanberra.so.0 0 3874 open:entry firefox /usr/lib/libcanberra.so.0 0 3874 open:entry firefox /home/human/tor-browser_en-US/Browser/TorBrowser/Tor/libcanberra.so.0 0 3874 open:entry firefox /etc/ld.so.cache 0 3874 open:entry firefox /lib/x86_64-linux-gnu/libcanberra.so.0 0 3874 open:entry firefox /usr/lib/x86_64-linux-gnu/libcanberra.so.0 0 3874 open:entry firefox /lib/libcanberra.so.0 0 3874 open:entry firefox /usr/lib/libcanberra.so.0 0 3874 open:entry firefox /dev/urandom 0 3874 open:entry firefox /dev/urandom ^C
syscall frequency count
dtrace -n 'lx-syscall:::entry /pid == 44622/ { @num[probefunc] = count(); }' dtrace: description 'lx-syscall:::entry ' matched 676 probes ^C 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 ^C CPU ID FUNCTION:NAME 0 2 :END firefox realloc 31609 libmozalloc.so moz_xmalloc 33383 libmozalloc.so moz_free 36504 firefox malloc 50687 firefox free 54604 libpthread.so.0 pthread_self 58444 libpthread.so.0 pthread_getspecific 69741 libpthread.so.0 pthread_mutex_unlock 204393 libpthread.so.0 pthread_mutex_lock 204394 libpthread.so.0 __pthread_mutex_unlock_usercnt
lxsockopt.d
#!/usr/sbin/dtrace -s #pragma D option quiet /** PROTO values can be found here: https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers SOCKOPT values can be found here: https://github.com/joyent/illumos-joyent/blob/master/usr/src/lib/brand/lx/lx_brand/common/socket.c */ BEGIN { printf("%6s %20s %5s %s\n", "PID", "NAME", "PROTO", "SOCKOPT"); } lx-syscall::setsockopt:entry { printf("%6d %20s %5d %d\n", pid, execname, arg1, arg2); }
./lxsockopt.d 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`ld.so.1 malloc entry 75306 pid1774 LMfd`libmapmalloc.so.1 malloc entry 76053 pid1774 LMfd`libc.so.1 malloc entry 84541 pid1774 libc.so.6 malloc entry 85794 pid1774 ld-linux-x86-64.so.2 malloc entry
Bisecting
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.
QA and Testing
Some automated tests are run on nightly builds, and new releases. The main page for the results is http://test-reports.tbb.torproject.org/reports/.
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/BrowserBundleTests.pm. Documentation for adding new tests is available.
This test suite is automatically run in the following cases:
- when a new nightly build is available on https://people.torproject.org/~linus/builds/. An email of the results is sent to a list of people defined in config/linus-nightly. You can ask me if you want to be added to this list.
- when a new release is tagged on git and available on https://people.torproject.org/~user/builds/$version/. The result of the tests is emailed to tor-qa@….
- 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 virustotal.com 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:
- when a new nightly build is available on https://people.torproject.org/~linus/builds/. The results are available on http://test-reports.tbb.torproject.org/reports/index-browserbundle_virustotal.html. No emails are sent at the moment (you can ask me if you are interested to receive them).
- when a new release is tagged on git and available on https://people.torproject.org/~user/builds/$version/. The results are sent to tor-qa@….
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 people.torproject.org 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 @torproject.org 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
Options:
- 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, https://git.torproject.org/tor-browser.git is used by default.
FPCentral
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: https://fpcentral.tbb.torproject.org/
The git repository containing the sources is at: https://gitweb.torproject.org/fpcentral.git/
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 README.md 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
- Once the bridge is running, find its bridge line. For obfs4, the bridge line is in the file
<datadir>/pt_state/obfs4_bridgeline.txt
. You need to insert the external IP/port, and the fingerprint from the file<datadir>/fingerprint
. - File a new ticket that contains the bridge line.
Component: Applications/Tor Browser
Keywords: tbb-bridges - Make a pull request at https://github.com/OpenObservatory/ooni-resources that adds the new bridge's IP/port to the file bridge_reachability/tor-bridges-ip-port.csv. (This will cause OONI to start testing the reachability of the new bridge.)
Other Resources
Attachments (1)
-
convert-asan-to-symbolizer.py (392 bytes) - added by 3 years ago.
Python helper script to get symbols for a stack trace produced by ASan
Download all attachments as: .zip