rustybird / corridor

Tor traffic whitelisting gateway
ISC License
67 stars 6 forks source link
firewall tor

corridor, a Tor traffic whitelisting gateway

Not affiliated with the Tor Project.

There are several transparently torifying gateways. They suffer from the same problems:

corridor takes a different approach. It allows only connections to Tor relays to pass through (no clearnet leaks!), but client computers are themselves responsible for torifying their own traffic. In other words, it is a filtering gateway, not a proxying gateway.

You can think of it as a fail-safe for your vanilla Tor Browser or Tails, for your beautiful scary experimental Qubes proxying schemes, etc. Or invite the hood to use your WiFi without getting into trouble.

Principle of operation

  1. The corridor-data script opens a Tor control connection and subscribes to NEWCONSENSUS events (announcements listing all public relays), unless you inform it of any bridges to use instead.
  2. That data is used to atomically update a Linux ipset (a list of IP-address:TCP-port entries accessible in constant time) named corridor_relays containing either all your bridges or all acceptable relays along with their ORPort. Acceptable means the relays have a Valid flag and a Guard or Authority flag.
  3. iptables rules refuse to forward packets unless they are going to / coming from one of the relays inside the ipset.

Pitfalls

Installation

You may also be interested in Patrick Schleizer's corridor Debian package, or the corridor page in the Whonix wiki

# Install corridor and its systemd units to the default location in /usr/local.
make install install-systemd

# Edit the configuration.
$EDITOR /etc/corridor.d/*

Manual usage

# Set up IP traffic forwarding.
corridor-init-forwarding

# Set up Source NAT with iptables.
corridor-init-snat

# Keep track of acceptable Tor relays.
corridor-data &

# Log attempted leaks from selected clients.
# This command will block until corridor_relays gets populated!
corridor-init-logged

systemd

# If you use something other than systemd-networkd to bring up your
# network interfaces (make sure that whatever it is correctly orders
# itself after network-pre.target!), you must add a dependency:
mkdir /etc/systemd/system/some.service.d
cat  >/etc/systemd/system/some.service.d/corridor.conf <<END
[Unit]
Requires=corridor-init-forwarding.service
END

# Start corridor
systemctl start corridor.target

# Start corridor when booting
systemctl enable corridor.target

Qubes

This has barely even been tested, be careful!

# In your template:
dnf install tor ipset socat perl make  # or apt-get ...
make PREFIX=/usr install install-systemd install-qubes
systemctl enable corridor.target

# In dom0:
qvm-create --prop provides_network=True --template your-template --label blue corridor-gateway
qvm-service --enable corridor-gateway corridor

How does corridor-data open a Tor control connection?

If $TOR_CONTROL_SOCKET is nonempty, use it. Otherwise, connect to $TOR_CONTROL_HOST (localhost if unset) on $TOR_CONTROL_PORT (9051 if unset).

If $TOR_CONTROL_COOKIE_AUTH_FILE is nonempty, use it. Otherwise, pass $TOR_CONTROL_PASSWD.

The default configuration file sets $TOR_CONTROL_SOCKET to /var/run/tor/control, and $TOR_CONTROL_COOKIE_AUTH_FILE to /var/run/tor/control.authcookie. These values work on Debian and Fedora.

Dependencies so far

Todo

Version numbers

Semantic Versioning is used in the form of signed git tags.

Redistribution

corridor is permissively licensed, see the LICENSE-ISC file for details.