Skip to main content

TTP - Transparent Tor Proxy

A Linux CLI tool that transparently routes all system traffic through the Tor network using nftables.

Sponsor Linux Python CI Status Documentation PyPI - Downloads OpenSSF Best Practices License

Features • Requirements • Installation • Usage • How It Works • Verification • Contribute


TTP Demo


No per-application setup needed - just sudo ttp start and every connection goes through Tor.

New in 0.5.0: required watchdog readiness, typed session evidence and optional desktop notifications. Read the operator guide for independent --watchdog / --notifications selection, configurable deadlines, exit codes and explicit emergency termination.

VPN before Tor (new in 0.5.0): see the VPN guide before using --require-vpn UUID. It requires an already active native NetworkManager WireGuard tunnel, watchdog and no bypass. Supported profiles, limitations, deliberate stop/recovery and VM qualification results are documented together; this is not a general VPN-manager integration.

Why TTP?

Legacy transparent proxy scripts (TorGhost, Anonsurf) overwrite configuration files and build iptables rulesets that fail open: when they break, traffic leaves in cleartext. TTP is built the other way round - it fails closed, and keeps nothing on disk.

Fail-closed by construction An isolated inet ttp nftables table with a catch-all reject and policy drop on forwarding. On a crash, a watchdog trigger or an unclean exit, traffic is either routed through Tor or blocked - never released.
Nothing persists Session state, torrc, lock file and logs live only in tmpfs (/run/ttp/, /run/tor/ttp/). A reboot leaves no residue and no stale lock - and no session either: see Known Behavior & Limitations.
No per-application setup TCP and DNS are intercepted at the network layer. No SOCKS5 settings, no proxy environment variables, no application support required.
DNS without rewriting your system A mount --bind overlay on /etc/resolv.conf rather than an edit, plus a volatile drop-in that neutralises systemd-resolved, backed by a kernel-level drop on any non-loopback resolver traffic.
The leak claim is measured Every containment rule is tested in an isolated network namespace against the real generated ruleset, and each test first proves it can see a leak before asserting there is none. See Verification.

Features

  • Continuous integrity protection (--watchdog) - a watchdog governed by a formal FSM (transitions) compares the live inet ttp table, rule for rule, with the one the session applied, and watches Tor and the DNS overlay. It is woken by nftables and inotify events rather than polling, so a flushed or altered table reaches the killswitch in tens of milliseconds (31-48 ms measured). A failed Tor is restarted once; a changed table or DNS overlay is treated as tampering. Either way, if the session is not intact the watchdog applies an emergency killswitch and holds it until ttp stop, re-applying it if something removes or alters it.
  • Split tunnelling - exempt users or groups (--bypass-user, --bypass-group) with native nftables UID/GID matching, or run a single command outside Tor with ttp bypass <cmd> via a cgroups v2 slice.
  • LAN preserved - private and link-local subnets stay reachable, except the reserved Tor virtual ranges. Onion mappings take precedence over LAN bypass; ordinary fd00::/8 ULA networks remain available.
  • Dual-stack, or no stack - IPv6 is routed through Tor when loopback routing is available, and dropped outright when it is not. There is no third option where it leaks.
  • DoH and DoT contained by construction - all TCP goes to Tor, DNS on port 53 goes to Tor's DNSPort, everything else is rejected. A browser's DoH or DoT query therefore leaves through a Tor exit like any other connection, whoever the resolver is; no blocklist is involved (ADR 0012).
  • AppArmor confinement - on AppArmor kernels, managed Tor must have a verified ttp-tor (enforce) label. See requirements, diagnosis and limits; the watchdog contains loss of confinement.
  • Coexists with your system Tor - runs its own volatile ttp-tor.service on non-standard ports, leaving an existing Tor instance untouched.
  • Bridges - obfs4 and snowflake, with BYOD (bring your own daemon) mode.

Requirements

  • Linux with systemd
  • Python 3.12+
  • nftables (pre-installed on most modern distros)
  • Root privileges (required for firewall and DNS modifications)

Installation

Choose the method that best fits your needs. Native packages are strongly recommended for system stability, security, and clean uninstallation.

Installing via native packages ensures that all system dependencies (tor, nftables) and kernel-level optimizations (SELinux) are managed by your OS package manager.

Download the .deb or .rpm for the version you want from the latest release - the packages are release assets and are not checked into the repository - then install it:

  • Debian / Ubuntu: sudo apt install ./transparent-tor-proxy_0.5.1_all.deb

  • Fedora 44: sudo dnf install ./transparent-tor-proxy-0.5.1-1.fc44.noarch.rpm

  • Arch Linux: build from the repository with cd packaging && makepkg -si

  • Fedora 45: its own .fc45.noarch.rpm, with an OpenPGP signature embedded in the RPM. Its release assets include the public key (*-fc45-rpm-key.asc) and a Sigstore bundle for both the key and RPM. See the verification guide before importing the key.

For instructions on how to verify the integrity and authenticity of the release assets, see the Release Verification Guide.


2. Manual Source Install (Developer/Universal)

If you are a developer or want to install from the repository:

git clone https://github.com/onyks-os/TransparentTorProxy.git
cd TransparentTorProxy
sudo ./scripts/install.sh

3. Alternative Installation Methods (Fallback)

For installing TTP via Python-specific package managers (pipx or pip with virtual environments), see the Alternative Installation Methods Reference.

Usage

TTP is designed to be simple and lightweight. For the complete list of CLI commands, options and exit codes, see the CLI reference; for the technical specification, the External Interfaces Reference.

Quick Start

Most network-modifying commands require root privileges (sudo):

  • Start the proxy:

    sudo ttp start
    
  • Stop the proxy:

    sudo ttp stop
    
  • Check current session status:

    sudo ttp status
    
  • Watch local session observations and changes:

    sudo ttp monitor
    

    The terminal view is passive. Its Tor result is the last recorded check, not a new verification; close it with Ctrl-C without stopping the session.

  • Verify that traffic reaches Tor:

    sudo ttp check
    
  • Request a new exit IP (rotate circuits):

    sudo ttp refresh
    

For more advanced setups and circumvention profiles, see the Advanced Security & Usage Profiles Reference or consult the External Interfaces Reference.

Checking Your Session

Click to expand manual verification steps

For point-in-time functional checks, run these as an ordinary, non-bypassed user. They do not establish absence of leaks during faults or other traffic:

  1. Verify Tor Exit IP:

    curl -s https://check.torproject.org/api/ip
    
  2. Verify DNS Routing:

    # Should return a valid IP via Tor's DNSPort
    dig +short A check.torproject.org
    
  3. Additional DNS diagnostic:

    # Observe the response; empty output is not proof of containment
    dig +short TXT whoami.ipv4.akahelp.net
    

    Tor's DNSPort does not support arbitrary TXT queries. Empty output, timeout, SERVFAIL, REFUSED and NOTIMP can also occur on a direct resolver path. Neither those outcomes nor an aggregate redirect counter prove where this query went. See calibrated DNS/UDP measurements.

  4. Web-based Verification: Browser leak-test pages can provide additional diagnostics. Their results apply to the browser and requests tested, not every application or the interval between a fault and containment.

Full Uninstallation

To remove TTP completely from the system:

sudo ./scripts/uninstall.sh

How It Works

TTP transparently routes all network traffic by orchestrating standard Linux kernel subsystems, system utilities, and Tor's control interfaces:

flowchart LR
    App["Application"] -->|TCP| NFT["nftables (inet ttp)"]
    App -->|DNS| Resolver["/etc/resolv.conf overlay<br/>or systemd-resolved"]
    Resolver -->|port 53| NFT
    NFT -->|redirect| TransPort["Tor TransPort"]
    NFT -->|redirect| DNSPort["Tor DNSPort"]
    NFT -->|anything else| Reject["rejected"]
    TransPort --> Tor["Tor"]
    DNSPort --> Tor
    Tor --> Internet["Internet"]
  1. Atomic Firewall Redirection: Generates and loads an isolated inet ttp nftables ruleset atomically: TCP is redirected to Tor's TransPort, DNS on port 53 to Tor's DNSPort, and every other packet is rejected.
  2. DNS Bind-Mount Overlay: Overlays /etc/resolv.conf with a volatile RAM-backed configuration via a kernel-level bind-mount to ensure DNS calls are resolved by Tor.
  3. Tor Daemon Integration: Configures, runs, and monitors an isolated Tor instance via volatile systemd services on non-standard ports to prevent port conflicts.
  4. Session Watchdog (--watchdog): An optional background daemon that verifies the session's integrity on every nftables or inotify event and every 15 seconds. It restarts a failed Tor once; anything else that is not intact - the table, the DNS overlay - engages a fail-closed emergency killswitch, which it holds until ttp stop.

For a detailed walkthrough of the execution flows, system hooks, security boundaries, and modular components, please refer to the:

Technical Architecture & Design Guide

Crash Recovery

TTP is designed to always restore your network, even in edge cases:

Scenario What happens
ttp stop Zero-leak cleanup: stops the watchdog, applies the teardown lockdown, shuts Tor down gracefully, closes every redirected connection's socket and verifies it is gone (otherwise exits 8 and keeps protection), flushes connection tracking, removes the inet ttp table, restores DNS, and deletes the lock file - the lock last, even if a step before it fails
Ctrl+C / kill Signal handler catches SIGINT/SIGTERM and runs normal cleanup before exit
kill -9 / Power Outage Next ttp start detects the orphaned lock file, clears any stale mount stacks, and auto-restores
Manual emergency Run sudo ./scripts/restore-network.sh to flush all nftables rules, reset DNS, and delete the lock file

Known Behavior & Limitations

For a full breakdown of residual risks, architectural trust boundaries, and the STRIDE threat model, see:

docs/security-assessment.md

Development & Testing

TTP uses a Makefile to automate and standardize the testing pipeline. This ensures that every change is verified against unit and integration tests before being committed.

The "Pre-Push" Rule

[!IMPORTANT] Always run make verify before pushing code. If this command fails, the code is NOT ready for production.

Essential Commands

Command Goal
make verify The gate to run before every push: lint (ruff, mypy, ShellCheck, markdownlint, secret scan), unit tests, dependency audit.
make test Unit tests only (no root needed, fully mocked).
make coverage Unit tests with a coverage report; fails below the ratchet.
make test-nse The zero-leak ruleset suite in a network namespace (root, .[nse] extra).
make integration-debian Integration tests in a privileged Docker container (also -fedora, -arch, -all).
make chaos-monkey The watchdog chaos sweep on a disposable host (root).
make verify-full The pre-release suite: lint, unit, integration and packages.
make packages Builds the native .deb and .rpm packages (make build builds the Python distributions).
make clean Removes all build artifacts, caches, and temp files.

Verification

TTP's zero-leak claim is measured, not asserted. The Network Sandbox Engine builds an isolated network namespace, loads TTP's real generated ruleset into it, generates the traffic a leak would consist of, and watches the boundary veth interface with a Scapy sniffer.

Every containment test runs twice. assert no leaks is also true when the sniffer never started, when the interface name is wrong, or when the traffic never left the process, so each test first runs the same stimulus with the ruleset flushed and requires the packet to be seen. Only then does it assert that TTP's ruleset stops it. A harness that cannot observe a leak fails the test rather than passing it.

Covered: plain DNS (UDP and TCP), ordinary TCP, DoT on 853, QUIC DoH on UDP/443, ICMP, arbitrary UDP, IPv6 and routable ICMPv6; containment with a Docker-, ufw-, firewalld- or WireGuard-shaped ruleset loaded alongside TTP's, and with a foreign NAT chain that DNATs DNS to a LAN resolver; forwarded traffic; the teardown lockdown; a connection open before ttp start, which must be reset rather than left hanging. And the other direction: a bypassed UID still reaches the LAN and gets an answer back. A firewall that blocked everything would pass every containment test and fail those.

# libpcap is required: the sniffer compiles a BPF filter, and Scapy dlopen()s
# the unversioned libpcap.so that only the -devel/-dev package ships.
sudo apt install nftables iproute2 conntrack libpcap0.8 libpcap-dev   # Debian/Ubuntu
sudo dnf install nftables iproute2 conntrack libpcap libpcap-devel    # Fedora/RHEL
pip install -e ".[nse]"
make test-nse            # runs as root; TTP_REQUIRE_NSE=1 so it cannot skip itself

This runs in CI on every push (the Zero-leak ruleset verification job) and as a step in scripts/verify.sh before a release.

Lifecycle and chaos, in a VM

Two things a namespace cannot show run in a disposable VM, in CI (.github/workflows/lifecycle.yml) whenever firewall, lifecycle, DNS or watchdog code changes, and weekly:

  • Lifecycle transitions - shutdown, reboot, and suspend/resume onto a new network, judged from a packet capture QEMU writes outside the guest, on Debian 13 (systemd-networkd) and Fedora 44 (NetworkManager, SELinux enforcing).
  • The watchdog chaos sweep - every fault once against a live session (Tor stopped or killed behind systemd's back, the table flushed or destroyed, the DNS overlay unmounted, the link flapped). The VM wrapper continuously samples TCP, UDP and DNS during each fault, retaining calibrated external captures and reporting initial enforcement exposure separately from subsequent recovery. See continuous fault evidence.

What each asserts, and what it found, is in section 4.3 of the security assessment. To run them locally, see VM & Chaos Testing.

Diagnostics

If something goes wrong, run the diagnostic command:

sudo ttp diagnose

Project Structure

├── pyproject.toml          # Package metadata and dependencies
├── README.md
├── CONTRIBUTING.md         # Contribution guidelines
├── SECURITY.md             # Security policy
├── scripts/                # Installation, verification, and VM management scripts
├── assets/                 # Branding and demo assets
├── packaging/              # Packaging configurations (.deb, .rpm, Arch PKGBUILD)
├── ttp/                    # Main Python source package
│   └── resources/          # Internal package resources (SELinux policies, etc.)
├── tests/                  # Unit, integration, and leak testing suites
└── docs/                   # Technical documentation, threat models, and ADRs

Project statistics

GitHub stars Estimated release downloads PyPI downloads per month

Star history

TTP has no telemetry and never will: these numbers are read from outside. GitHub counts every download of a release asset, including this project's own release verification, mirrors and crawlers, which fetch every file. The estimated count subtracts each release's floor of automated downloads (its least downloaded SBOM, which nobody fetches by hand) from its packages. It is an estimate: one person downloading twice counts twice. The method is in scripts/release_stats.py; the weekly history is on the stats branch.

Have you tried TTP?

TTP is maintained in free time, and hearing from people who try it helps guide development. Whether it worked well, something was confusing, or you decided not to keep using it, a short note is welcome.

Share your experience in GitHub Discussions. Even “works on Fedora” or “I couldn't get past installation” is useful. Your distro and TTP version help, but there's no need to explain what you use it for or share personal details.

For bugs, please use Issues; for security vulnerabilities, follow SECURITY.md.

Contributing

Contributions are welcome, and the areas where help matters most are narrow and specific:

  1. Linux networking - nftables, routing tables, network namespaces, VPN interface detection.
  2. Tor internals - daemon configuration, Stem, bridges, bootstrap edge cases.
  3. CI/CD - keeping the privileged test suites fast and reliable on GitHub Actions.

Start with CONTRIBUTING.md, which documents the two rules this codebase is built on: never fix a bug without adding the check that would have caught it, and a test that asserts an absence must first prove it can detect a presence.

Bugs and feature requests GitHub Issues
Security vulnerabilities SECURITY.md - please do not open a public issue
Version support and EOL SUPPORT.md
Releases and packages GitHub Releases · PyPI

This project is maintained in free time. A star helps others find it; sponsorship helps it keep going.

License

MIT. See LICENSE for more information.

Metadata

Release files for transparent-tor-proxy 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for transparent-tor-proxy 0.5.1
File Size Uploaded Provenance Actions
transparent_tor_proxy-0.5.1.tar.gz 1.5 MB With provenance Details for transparent_tor_proxy-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for transparent-tor-proxy 0.5.1
File Interpreter ABI Platform Actions
transparent_tor_proxy-0.5.1-py3-none-any.whl Python 3 none any Details for transparent_tor_proxy-0.5.1-py3-none-any.whl

Total release size: 1.7 MB

Release files / transparent_tor_proxy-0.5.1.tar.gz

Download URL transparent_tor_proxy-0.5.1.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
fb1e1bdd6de27d11017161cbf1a3e118965d0eb63b339356ffbc00b5ddac6a1b
BLAKE2b-256 checksum
How to use checksums
8bd2813079612b9d721794fc79e1d2a30bb5972e6a99cda4dc3f837ac9a951f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / transparent_tor_proxy-0.5.1-py3-none-any.whl

Download URL transparent_tor_proxy-0.5.1-py3-none-any.whl
Size 170.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4764b1398197ca0380d4a453192d9ec6c0772cf3bb75aa655f72d98f6f0aee6e
BLAKE2b-256 checksum
How to use checksums
a7b8af8265dbfc371c8b47e5abecefc72ed18cc8f8655f869a3529e9cb203d10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for transparent-tor-proxy 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for transparent_tor_proxy-0.5.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page