← Socratic Seminar #52 ← → or space to navigate

Bitcoin Core #36757 · merged 2026-11-12

Ignore a privacy-network peer's view of our address

A malicious Tor or I2P peer could make your node reveal its listening port, then use that port to link your onion identity to your clearnet IP.

Author: stratospher · Found by Project Loupe and instagibbs · github.com/bitcoin/bitcoin/pull/36757

Background

Nodes ask peers "what's my address?"

  • Every VERSION message carries addrMe: the IP the sender thinks the receiver has.
  • With -discover on, Core sometimes trusts that view and self-advertises it back to the peer in an ADDR message, so the peer can gossip how to reach us.
  • On an outbound connection the peer can't see our listening port, so Core keeps the IP the peer reported and fills in our real listening port.
  • Honest Tor/I2P peers send addrMe as all zeroes, since they can't see our IP. A malicious one can put anything there.

The leak

A Tor peer fakes addrMe and gets our port back

Sequence: our node connects out to a malicious Tor peer, which sends a fake routable addrMe; our node self-advertises that IP with its real listening port, leaking the port. Our node listening on :18444 (unusual) Malicious Tor peer xyz…abc.onion ① outbound connection over Tor (we picked them from addrman) ② VERSION, addrMe = 203.0.113.7 any routable IP; an honest Tor peer would send 0.0.0.0 ③ ADDR self-advertisement: 203.0.113.7:18444 their IP, but OUR real listening port Peer learns: port 18444

The IP in the advertisement is junk the attacker chose. The port is the real secret.

The correlation

An unusual port links the two identities

The attacker matches the leaked port 18444 from the onion peer against a scan of clearnet nodes; the one clearnet node listening on 18444 is linked to the onion identity. SEEN OVER TOR abc…xyz.onion leaked port 18444 CLEARNET NODE SCAN 198.51.100.4 : 8333 192.0.2.88 : 8333 203.0.113.50 : 18444 198.51.100.9 : 8333 … thousands on 8333 port match onion node = 203.0.113.50

On the default port 8333 the leak blends in with thousands of nodes. A rare port is a near-unique fingerprint.

How bad was it?

Real, but hard to pull off

You must pick them

The attacker's Tor/I2P peer has to be one your node chooses for an outbound connection from addrman.

You need a rare port

The leak only singles you out if your listening port is unusual. On 8333 you're one of thousands.

You run both networks

The node has to be reachable on clearnet and Tor/I2P, with -discover on, so there are two identities to link.

The PR notes this "would become easier in a future if we ever support random ports."

The fix

Never trust a Tor/I2P peer's view of us

// src/net.cpp · IsPeerAddrLocalGood()
-    return fDiscover && pnode->addr.IsRoutable() && addrLocal.IsRoutable() &&
+    // Tor/I2P peers can't see our clearnet address and the Tor/I2P address
+    // won't fit in addrMe (addrv1). so ignore it.
+    return fDiscover && !pnode->IsConnectedThroughPrivacyNet() &&
+           pnode->addr.IsRoutable() && addrLocal.IsRoutable() &&
           g_reachable_nets.Contains(addrLocal);
  • One condition: if the peer is on a privacy network, its addrMe is ignored for both inbound and outbound connections.
  • A Tor peer can never legitimately see our IP anyway, so nothing useful is lost.
  • New unit tests cover an inbound I2P peer and an outbound onion peer.

Discussion

Questions for the room

  • Second Loupe find this month (after CVE-2026-117348). Are LLM scanners now the main source of Core bug reports?
  • Should mixed clearnet + Tor nodes be discouraged entirely, or is that too much to ask of node runners?
  • Random listening ports would make this attack easier. What other leaks would they enable?
  • Running on a non-default port for "privacy": does it help or hurt?