doc: warn about -bind interaction with automatic Tor hidden service

bitcoin/bitcoin: PR #36943

4 minor findings · 1 suggestion

Findings

Link

[minor] · Warning omits -whitelist permissions granted to untagged Tor peers

The new warning omits pre-existing behavior that grants remote Tor peers local -whitelist permissions when automatic forwarding uses an untagged ordinary -bind and the whitelist matches the Tor daemon's source address.

Location: src/init.cpp:564 (head).

Details and suggested fix

With -listenonion=1, a working automatic hidden service, ordinary -bind values and no =onion bind, the service targets vBinds.front() without adding it to onion_binds. CreateNodeFromAcceptedSocket therefore matches inbound whitelists against the Tor daemon's TCP source instead of excluding address-based permissions. For a daemon connecting from 127.0.0.1, either -whitelist=127.0.0.1 or -whitelist=noban@127.0.0.1 gives every forwarded remote peer NoBan. MaybeDiscourageAndDisconnect then skips misbehavior disconnection before reaching the localhost rule. Expand the warning to tell operators not to whitelist the daemon's source address without an =onion bind, rather than describing only statistics. The documented dedicated onion bind prevents this permission grant.


Link

[minor] · Warning omits clearnet self-advertisement to untagged Tor peers

The new warning omits a pre-existing privacy effect: when the node knows a routable clearnet local address, automatic Tor peers arriving through an untagged ordinary -bind can receive that address in self-announcements.

Location: doc/tor.md:231 (head).

Details and suggested fix

With -listenonion=1, ordinary -bind addresses and no =onion bind, forwarded connections have m_inbound_onion=false. GetLocal consequently excludes the node's onion address but permits clearnet entries in mapLocalHost. A routable entry, for example from -externalip, can reach the peer through MaybeSendAddr after handshake, outside IBD, once the inbound peer enables address relay with GETADDR. For a loopback source, the peer-reported-address override cannot replace that selection. A proxy setup with discovery disabled and no clearnet local entry does not disclose a clearnet address through this path. Eviction bucketing also changes, although loopback peers retain localhost protection rather than losing all protection.

Expand the warning and help text to explain the conditional clearnet advertisement and failure to advertise the onion address. The =onion bind restores Tor-aware handling, not merely reporting. Operators who do not want automatic service creation can instead use -listenonion=0 without adding a listener.


Link

[minor] · Tor warning names the wrong RPC and loopback classification

The warning names getnetworkinfo, which has no per-network peer counts, and describes IPv4/IPv6 where an untagged loopback source appears as not_publicly_routable (npr) in getpeerinfo and -netinfo.

Location: doc/tor.md:231 (head).

Details and suggested fix

getnetworkinfo derives its connection totals solely from inbound/outbound direction, and its networks array reports reachability and proxy settings. The affected classification is the network field in getpeerinfo, which -netinfo counts. Without the onion tag, ConnectedThroughNetwork() uses addr.GetNetClass() for the Tor daemon's accepted TCP source. Loopback is not routable, so it produces not_publicly_routable, displayed as npr, rather than an IPv4/IPv6 category. Replace getnetworkinfo with getpeerinfo and explain that these peers are classified by the daemon's source address instead of as onion, usually as not_publicly_routable for a local loopback connection.


Link

[minor] · -bind help warning omits the explicit-bind precondition

The added help condition also describes the no--bind configuration, even though that configuration creates a tagged onion listener and does not suffer the stated misclassification.

Location: src/init.cpp:564 (head).

Details and suggested fix

With no explicit -bind, vBinds is empty and initialization appends DefaultOnionServiceTarget to onion_binds. InitBinds then opens that tagged loopback listener. The help entry's (default: 0.0.0.0) makes the added sentence sound applicable to this configuration too. Start the condition with “If -bind addresses are specified while -listenonion is enabled but none has =onion, ...”, matching the narrower condition already used in doc/tor.md.


Optional improvements

Link

[suggestion] · Automatic-service warning misses the automatic-setup section

Readers of section 2, which documents automatic onion-service creation, receive no warning about custom -bind addresses because the new paragraph appears only in the manual-setup section.

Location: doc/tor.md:231 (head).

Details and suggested fix

The surrounding HiddenServicePort and -externalip example configures a manual service with a fixed target, whereas this paragraph explains how -listenonion selects an automatic target. Automatic creation can still be enabled during manual setup, so retaining a cross-reference here is useful. Move the warning beside the -listenonion description in section 2, which currently has neither the warning nor a link to it.


Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

An explicit ordinary bind was intended to restrict listening sockets, including allowing users to disable the otherwise implicit Tor listener. Bitcoin Core 28.0 documented that custom bind=addr:port now binds only that endpoint, rather than additionally opening 127.0.0.1:8334 even when Tor was unused.

This is the historical constraint behind avoiding a dedicated Tor socket when ordinary binds are explicitly configured. The release notes require an explicit onion bind to preserve the old additional listening endpoint, not to make every automatic hidden service reachable.

Source 1 · Source 2