Repository navigation
net: don’t self advertise tor exit node ip addresses in outbound connections - #35578
stratospher wants to merge 4 commits into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
|
Concept ACK, it makes sense to me to not advertise an address we know we can't be reached on. I think this is the case when using I've looked at the number of connections my nodes make to Tor exit node IPs in this post: In mid 2026, my nodes each make between 7.5 to 12.5 connection attempts per day to Tor exit node IPs. While nearly all of these connection attempts fail (as expected), there's about 20 IPs where I've seen some connections to Tor exit node IPs succeed over the last years. I assume these are hosts that run (or ran at some point) a Tor exit node and a Bitcoin node, which isn't too unexpected. |
Hm are we sure this is being used like this? With just Lines 812 to 825 in 93012d7 bitcoin/src/net_processing.cpp Lines 5475 to 5476 in 93012d7 |
good point. it's either this or people using even though there is the soft-set init parameter interactions which does
quick GitHub search shows |
|
Concept ACK On master, I noticed that sometimes clearnet outbound peers would send me their own addresses as my address, and I would occasionally self-advertise those same addresses back to them. I think this PR fixes that only for proxy, but maybe we should also add check so that a peer does not send us their own address. tested 412aa3d with My logs show that even when the score flip favoured the peers reported address for an outbound clearnet (tor_proxied ) peer , we do not advertise it , instead we now always fallback to advertising our own adress that we know. Logs |
mzumsande
left a comment
There was a problem hiding this comment.
Concept ACK
I wonder if it is really all explained by misconfigurations, overriding defaults, and if everyone would be running this branch, the exit nodes would stop being relayed.
Maybe it could also due to transparent torification where users do not change any defaults but the traffic is rerouted via tor externally, e.g. by an OS such as Whonix? In that case, the fix might not solve the problem completely.
|
@stratospher what is the status here? There are a few unaddressed comments. |
|
@mzumsande good point! I don't think we have a way to know unless we see it in action in the P2P network and this patch obviously won't work for systems running transparent torrification. but we can try to reduce it from core's end when people override defaults. even though it's not a problem currently, ~95% of the tor exit IPs don't have ports in if we ever switch to non default ports - it might get problematic for the tor exits. so I think it's still good to reduce unnecessary connection attempts to tor exits from our side (this is not an issue currently). |
b5d58ee to
d7e3ec6
Compare
|
CI failure is unrelated. could someone start the failed CI job again? thanks! |
d7e3ec6 to
38f2716
Compare
When outbound connections to clearnet peers are made via a proxy, - During self advertisement - we advertise "IP address we think we are" and sometimes replace it with what "IP address the peer thinks we are". - the "IP address the peer thinks we are" is the proxy's ip address. and can get relayed as our self advertisement - in normal cases the proxy's ip address is not a reachable inbound address and shouldn't be relayed on the network. there is a soft-set init parameter interaction proxy → discover=0 to prevent this situation but don't think it works in practice because people might end up overriding it with discover=1 in real life, 55-76% of all tor exit nodes were present in various addrman snapshots from now and few years ago. so would be nice to check when behind a proxy before self advertising.
a unit test that sets a proxy would leak it into later cases in the same binary without a ResetProxy function.
With a proxy set, check that when we make an: - outbound: the peer's view of us is the proxy's address, so it is no longer used and nothing is advertised - inbound: unaffected, no proxy is involved and the peer does observe our own address - -externalip: still advertised
add a note for advanced operators who want to run reachable proxies (ex: tor exits and bitcoin nodes)
38f2716 to
3c6293a
Compare

GetLocalAddrFromPeer- we advertise the "IP address we think we are" and sometimes replace it with what "IP address the peer thinks we are".Example: when a node running both Tor and clearnet via a SOCKS5 proxy connects to a clearnet peer (
proxy=127.0.0.1:9050, listen=1, discover=1(or)onion=127.0.0.1:9050), the "IP address the peer thinks we are" is the Tor exit node's IP address and doesn't make sense to relay it. 55-76% of all tor exit nodes were present in various addrman snapshots I checked (my node and the ones from b10c’s peer.observer) from now and few years ago. would be nice to not unnecessarily relay these tor exit IPs since they end up being stored as fresh and gossiped from multiple sources entries in our addrman.an advanced node runner might have a proxy whose ip address is also a reachable inbound address. I've personally not used such a proxy but 1 difference for them is that they'd need to explicitly set
-externalip=<addr>to self-advertise their proxy address. i feel it’s an acceptable tradeoff and would imagine they are already using-externalip=<addr>config flag as they are explicitly managing their node's public address.