Glossary

Tor and Bitcoin

Using the Tor anonymity network to hide a Bitcoin node's IP address, improving privacy but introducing potential attack vectors.

Key Takeaways

  • Bitcoin Core has built-in Tor support: nodes can route all peer connections through Tor and automatically create .onion addresses for inbound connections, hiding the operator's IP from the network and their ISP.
  • Running Tor-only introduces risks: because Tor addresses are free to create, attackers can cheaply spin up thousands of fake peers to launch Sybil and eclipse attacks against isolated nodes.
  • A dual-stack approach (clearnet + Tor, or adding I2P) is the recommended configuration: it preserves privacy benefits while forcing attackers to control nodes across multiple networks to isolate a victim.

What Is Tor and Bitcoin?

Tor (The Onion Router) is a privacy network that routes internet traffic through multiple encrypted relays, concealing the user's IP address from the destination and from network observers. When applied to Bitcoin, Tor allows a Bitcoin node to communicate with peers without revealing its real IP address, and to host a .onion hidden service so other nodes can connect to it anonymously.

Without Tor, every peer your node connects to can see your IP address. Since ISPs maintain records linking IPs to real identities, this creates a chain from Bitcoin transactions back to real-world identity. Tor breaks this chain by routing connections through at least three encrypted hops, ensuring that no single relay knows both the origin and the destination.

Bitcoin Core has included native Tor support for years. Version 0.21.0 (January 2021) added Tor v3 onion address support, and version 22.0 (September 2021) dropped Tor v2 entirely. Today, a significant portion of reachable Bitcoin nodes advertise .onion addresses.

How It Works

Bitcoin Core integrates with Tor at two levels: outbound connections (routing traffic through Tor's SOCKS proxy) and inbound connections (creating a Tor onion service so peers can reach you without knowing your IP).

  1. The node operator runs Tor locally and enables its control port for authentication
  2. Bitcoin Core connects to the Tor SOCKS proxy (typically 127.0.0.1:9050) to route outbound peer connections through the Tor network
  3. If listening is enabled, Bitcoin Core uses the Tor control port to automatically create an ephemeral v3 onion service for inbound connections
  4. The node advertises its .onion address to peers via the gossip protocol, allowing other Tor-enabled nodes to connect

Configuration

The Tor daemon requires control port access. A minimal /etc/tor/torrc configuration:

ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1
DataDirectoryGroupReadable 1

Bitcoin Core accepts several flags for Tor integration. The most important ones:

FlagPurpose
-proxy=127.0.0.1:9050Route all connections through Tor SOCKS proxy
-onion=127.0.0.1:9050Separate proxy for .onion connections only
-listenonion=1Automatically create onion service (default: enabled)
-onlynet=onionRestrict all outbound connections to .onion peers
-torcontrol=127.0.0.1:9051Tor control port for automatic onion service management
-dnsseed=0 -dns=0Prevent DNS leaks when running Tor-only

A typical Tor-enabled configuration in bitcoin.conf:

# Route all traffic through Tor
proxy=127.0.0.1:9050

# Enable automatic onion service
listenonion=1
torcontrol=127.0.0.1:9051

# Prevent DNS leaks
dnsseed=0
dns=0

# Optional: restrict to Tor-only
# onlynet=onion

Why It Matters

Running a Bitcoin node over Tor provides several layers of privacy protection that are relevant to anyone operating node infrastructure:

  • IP address concealment: peers never learn your real IP, preventing them from linking your node to a physical location or identity
  • ISP opacity: your ISP sees encrypted Tor traffic rather than Bitcoin protocol data, preventing them from knowing you run a node
  • Transaction origin privacy: without Tor, network observers can perform timing analysis on transaction broadcasts to identify the originating node
  • Physical security: if attackers know you run a Bitcoin node (especially a Lightning node with visible channel capacity), you could become a target for physical attacks
  • NAT traversal: Tor onion services allow nodes behind NAT routers to accept inbound connections without port forwarding, which is a major practical benefit for home node operators

For Lightning Network nodes, Tor is especially popular. The majority of Lightning nodes use Tor or other darknet transports, primarily because onion services solve the NAT traversal problem for home setups. Implementations like LND support automatic Tor v3 onion service creation and stream isolation (using separate Tor circuits per connection) for enhanced privacy. For a deeper look at how Lightning handles privacy, see the research on Lightning Network privacy and onion routing on Lightning.

Risks and Attack Vectors

While Tor improves privacy, it introduces a distinct set of security tradeoffs. Nodes running Tor-only are particularly exposed to attacks that exploit the low cost of creating Tor identities.

Sybil Attacks via Free Tor Addresses

Tor .onion addresses can be generated at zero cost, unlike IPv4 addresses which require real infrastructure. An attacker can create thousands of fake Bitcoin peers with .onion addresses and flood the network's address tables. This asymmetry makes Sybil attacks cheaper on Tor than on the clearnet.

A 2015 paper by Biryukov and Pustogarov ("Bitcoin over Tor isn't a Good Idea," IEEE S&P) demonstrated a complete man-in-the-middle attack against Bitcoin nodes using Tor. The attack deployed approximately 1,000 to 1,500 malicious Bitcoin peers, operated Tor exit relays with restricted exit policies, and banned legitimate Tor exit nodes by sending malformed messages through them to trigger Bitcoin's DoS protection. The total cost was estimated at under $2,500 per month. Many of the specific vulnerabilities exploited in this paper have since been mitigated in subsequent Bitcoin Core releases.

Eclipse Attacks

If a node uses -onlynet=onion and an attacker controls enough onion-addressed Bitcoin peers, they can eclipse the node: isolating it from the honest network entirely. An eclipsed node sees only the attacker's fabricated view of the blockchain, making double-spend attacks possible and potentially blocking time-sensitive transactions like Lightning penalty transactions.

This risk also intersects with BGP hijacking: an AS-level adversary (such as a malicious ISP) can execute stealthy eclipse attacks by manipulating internet routing at the network layer. Bitcoin Core 20.0 introduced the ASMap feature to mitigate this by selecting peers based on Autonomous System number rather than IP address.

Latency and Performance

Tor circuits add significant latency overhead, with each hop introducing additional delay. This has practical consequences:

  • Initial block download is dramatically slower over Tor, sometimes taking days instead of hours
  • Lightning routing nodes running Tor-only experience reduced routing performance and lower available inbound liquidity
  • Block propagation delays can increase the risk of stale blocks for miners

Exit Node Manipulation

While Bitcoin's peer-to-peer protocol validates blocks and transactions cryptographically (preventing content tampering), malicious Tor relays have been documented performing attacks on other cryptocurrency services. The KAX17 threat actor operated over 900 malicious Tor relays between 2017 and 2021, performing SSL stripping attacks targeting cryptocurrency traffic. For Bitcoin nodes communicating peer-to-peer, the v2 transport protocol (BIP324, enabled by default since Bitcoin Core 27.0) adds an additional layer of encryption that complements Tor.

Countermeasures in Bitcoin Core

Bitcoin Core has implemented several protections against Tor-specific attack vectors over the years:

ProtectionVersionDescription
Anchor connections19.0+Saves 2 block-relay-only peers to disk, reconnecting on restart to prevent restart-based eclipse attacks
ASMap20.0+Selects peers based on AS number rather than IP prefix, mitigating AS-level Sybil attacks
Network diversity26.0+Maintains at least one outbound connection per reachable network (IPv4, IPv6, Tor, I2P, CJDNS)
BIP324 v2 transport27.0+Opportunistic encryption for all P2P traffic, making Bitcoin data indistinguishable from random bytes

I2P and the Dual-Stack Approach

Bitcoin Core 22.0 (September 2021) added support for I2P (Invisible Internet Project), a fully encrypted peer-to-peer network that uses garlic routing instead of Tor's onion routing. I2P connects via the SAM v3.1 protocol:

# Enable I2P in bitcoin.conf
i2psam=127.0.0.1:7656
i2pacceptincoming=1

The recommended configuration for privacy-conscious node operators is running a dual-stack or multi-network setup rather than relying on any single anonymity network. This means connecting to peers on both clearnet and Tor (and optionally I2P or CJDNS, added in Bitcoin Core 23.0). The benefits of this approach:

  • Eclipse attack resistance increases dramatically because the attacker must control nodes across multiple independent networks
  • Bridge nodes that span clearnet and Tor strengthen the overall Bitcoin network by relaying blocks and transactions between the two
  • Performance remains acceptable because latency-sensitive operations can use clearnet connections while privacy-sensitive traffic routes through Tor

One caveat: running on multiple networks simultaneously can allow an adversary with visibility into several networks to correlate your identities across them. If unlinkability is your primary requirement, a single-network setup may be preferable despite the higher eclipse risk.

For a comparison of different node configurations and their tradeoffs, see the research on Bitcoin node implementation comparison.

Lightning Network and Tor

Tor is widely used in the Lightning Network, where it serves a dual purpose: privacy and connectivity. Lightning implementations provide built-in Tor support:

  • LND supports automatic v3 onion service creation, stream isolation (separate Tor circuits per connection), and hybrid mode combining Tor and clearnet simultaneously
  • Core Lightning enables persistent Tor addresses for nodes behind NAT routers, removing the need for port forwarding or a static public IP

However, Tor-only Lightning nodes face practical limitations. Clearnet Lightning nodes hold significantly more channel capacity than Tor-only nodes, reflecting the performance tradeoff. Routing reliability is lower over Tor due to added latency, which can cause HTLC timeouts on multi-hop routes. Many node operators run hybrid configurations to balance privacy with routing performance.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.