net: stop sharing P2P listeners with automatic Tor services #36170

Open
l0rinc wants to merge 6 commits from l0rinc/identify-tor-shared-binds into master AGit
l0rinc commented 2026-09-04 21:25:39 +00:00 (Migrated from github.com)

Problem: With a normal -bind but no dedicated onion bind, the automatically created Tor onion service can forward incoming connections to the normal P2P listener, where they may be misclassified and inherit IP-based whitelist permissions.

Fix: Without a dedicated onion bind, keep Tor control available for outbound proxy discovery but skip automatic onion service creation and log a warning after authenticating with Tor.
The node starts with its configured listeners, including the default onion listener when no -bind is supplied, and starts Tor control only after those listeners have opened successfully.

To accept incoming Tor connections, add a specific non-wildcard -bind=<addr>:<port>=onion reachable from the Tor daemon.

Wildcard onion binds are rejected when -listenonion is enabled.
With -listenonion=0, they remain accepted, but incoming connections are not identified as Tor connections.

**Problem:** With a normal `-bind` but no dedicated onion bind, the automatically created Tor onion service can forward incoming connections to the normal P2P listener, where they may be misclassified and inherit IP-based whitelist permissions. **Fix:** Without a dedicated onion bind, keep Tor control available for outbound proxy discovery but skip automatic onion service creation and log a warning after authenticating with Tor. The node starts with its configured listeners, including the default onion listener when no `-bind` is supplied, and starts Tor control only after those listeners have opened successfully. To accept incoming Tor connections, add a specific non-wildcard `-bind=<addr>:<port>=onion` reachable from the Tor daemon. Wildcard onion binds are rejected when `-listenonion` is enabled. With `-listenonion=0`, they remain accepted, but incoming connections are not identified as Tor connections.
DrahtBot commented 2026-09-04 21:25:46 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK jeanpablojp
Stale ACK vasild, jpk68, winterrdog

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36937 (test: fix race in Tor control reconnect check by ANAMASGARD)
  • #36861 (Configuration argument handling improvements. by jlopp)
  • #36759 (torcontrol: Improve connection logging by ViniciusCestarii)
  • #35027 (net: add -outboundbind option for outgoing source address by 8144225309)
  • #17783 (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky)
  • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36170 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36170.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36170#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [jeanpablojp](https://github.com/bitcoin/bitcoin/pull/36170#pullrequestreview-5123605952) | | Stale ACK | [vasild](https://github.com/bitcoin/bitcoin/pull/36170#pullrequestreview-5569390414), [jpk68](https://github.com/bitcoin/bitcoin/pull/36170#issuecomment-6321045795), [winterrdog](https://github.com/bitcoin/bitcoin/pull/36170#pullrequestreview-5605645895) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36937](https://github.com/bitcoin/bitcoin/pull/36937) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36937.svg"></sub> (test: fix race in Tor control reconnect check by ANAMASGARD) * [#36861](https://github.com/bitcoin/bitcoin/pull/36861) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36861.svg"></sub> (Configuration argument handling improvements. by jlopp) * [#36759](https://github.com/bitcoin/bitcoin/pull/36759) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36759.svg"></sub> (torcontrol: Improve connection logging by ViniciusCestarii) * [#35027](https://github.com/bitcoin/bitcoin/pull/35027) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35027.svg"></sub> (net: add -outboundbind option for outgoing source address by 8144225309) * [#17783](https://github.com/bitcoin/bitcoin/pull/17783) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/17783.svg"></sub> (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky) * [#17580](https://github.com/bitcoin/bitcoin/pull/17580) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/17580.svg"></sub> (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
jeanpablojp (Migrated from github.com) reviewed 2026-09-06 00:55:26 +00:00
jeanpablojp (Migrated from github.com) left a comment

Concept ACK

0.0.0.0 is the default for -bind itself, and -bind=0.0.0.0:8334=onion passes the new check while tagging nothing. addr_bind comes from GetBindAddress on the accepted socket, so what CreateNodeFromAcceptedSocket compares against m_onion_binds is the concrete address the peer reached.

Same node, same arriving address, same -whitelist. With -bind=0.0.0.0:P=onion the inbound peer is classified by its IP network in getpeerinfo and keeps its noban. Spelling that same address out instead of the wildcard gives onion with no permissions. [::] is classified the same way, and either wildcard is what reaches Tor as the ADD_ONION target.

Rejecting a wildcard onion bind would close that. Naming 127.0.0.1:8334=onion in the message would only make it less likely. Is the first one in scope here?

Concept ACK `0.0.0.0` is the default for `-bind` itself, and `-bind=0.0.0.0:8334=onion` passes the new check while tagging nothing. `addr_bind` comes from `GetBindAddress` on the accepted socket, so what `CreateNodeFromAcceptedSocket` compares against `m_onion_binds` is the concrete address the peer reached. Same node, same arriving address, same `-whitelist`. With `-bind=0.0.0.0:P=onion` the inbound peer is classified by its IP network in `getpeerinfo` and keeps its `noban`. Spelling that same address out instead of the wildcard gives `onion` with no permissions. `[::]` is classified the same way, and either wildcard is what reaches Tor as the `ADD_ONION` target. Rejecting a wildcard onion bind would close that. Naming `127.0.0.1:8334=onion` in the message would only make it less likely. Is the first one in scope here?
jeanpablojp (Migrated from github.com) commented 2026-09-06 00:55:27 +00:00

The release note covers upgraders. For someone setting Tor up from scratch, the -bind help advertises default: 127.0.0.1:8334=onion, which still holds with no explicit -bind but not once one is given, and section 2 of doc/tor.md does not mention the dedicated bind. Would a line in one of the two be worth it?

The release note covers upgraders. For someone setting Tor up from scratch, the `-bind` help advertises `default: 127.0.0.1:8334=onion`, which still holds with no explicit `-bind` but not once one is given, and section 2 of `doc/tor.md` does not mention the dedicated bind. Would a line in one of the two be worth it?
jeanpablojp (Migrated from github.com) commented 2026-09-06 00:55:27 +00:00

nit: this could use the helper the file already uses further down, and then re, assert_raises and FailedToStartError drop out of the imports. It does loosen the exit status from exactly 1 to any non-zero. Ran it that way and it passes.

        self.nodes[2].assert_start_raises_init_error(
                    self.expected[2][0] + ["-listenonion=1"],
                    "Error: The Tor onion service cannot share a -bind address",
                    match=ErrorMatch.PARTIAL_REGEX)
nit: this could use the helper the file already uses further down, and then `re`, `assert_raises` and `FailedToStartError` drop out of the imports. It does loosen the exit status from exactly 1 to any non-zero. Ran it that way and it passes. ```suggestion self.nodes[2].assert_start_raises_init_error( self.expected[2][0] + ["-listenonion=1"], "Error: The Tor onion service cannot share a -bind address", match=ErrorMatch.PARTIAL_REGEX) ```
winterrdog (Migrated from github.com) reviewed 2026-09-08 07:12:25 +00:00
winterrdog (Migrated from github.com) left a comment

Approach ACK

Approach ACK
l0rinc (Migrated from github.com) reviewed 2026-09-24 05:19:45 +00:00
l0rinc (Migrated from github.com) left a comment

Rejecting a wildcard onion bind would close that. Naming 127.0.0.1:8334=onion in the message would only make it less likely. Is the first one in scope here?

Thanks , added a wildcard-bind check and test (added you as coauthor), but I’d appreciate a second look from e.g. @vasild who has more experience with this part of the networking code than I do.

> Rejecting a wildcard onion bind would close that. Naming 127.0.0.1:8334=onion in the message would only make it less likely. Is the first one in scope here? Thanks , added a wildcard-bind check and test (added you as coauthor), but I’d appreciate a second look from e.g. @vasild who has more experience with this part of the networking code than I do.
l0rinc (Migrated from github.com) commented 2026-09-24 05:17:03 +00:00

Thanks, added this to both the -bind help and section 2 of doc/tor.md. They now explain when the default onion bind is added and when an explicit, non-wildcard =onion bind is required.

Thanks, added this to both the `-bind` help and section 2 of `doc/tor.md`. They now explain when the default onion bind is added and when an explicit, non-wildcard `=onion` bind is required.
l0rinc (Migrated from github.com) commented 2026-09-24 05:18:20 +00:00

Switched to assert_start_raises_init_error, thanks.

Switched to `assert_start_raises_init_error`, thanks.
vasild (Migrated from github.com) reviewed 2026-10-01 13:03:41 +00:00
vasild (Migrated from github.com) left a comment

Approach ACK 69116ee97c

Approach ACK 69116ee97cefa089f9eb6665918fb6c8b1ff62d4
vasild (Migrated from github.com) commented 2026-10-01 12:33:54 +00:00
Nodes configured with `-bind` but no specific `-bind=<addr:port>=onion` now refuse to start when `-listenonion` is enabled.
```suggestion Nodes configured with `-bind` but no specific `-bind=<addr:port>=onion` now refuse to start when `-listenonion` is enabled. ```
vasild (Migrated from github.com) commented 2026-10-01 12:35:20 +00:00
Shared binds cannot distinguish Tor-forwarded connections from direct connections, which can grant Tor peers unintended IP-based whitelist permissions.

same reasoning as in the comment above, wildcard can distinguish.

```suggestion Shared binds cannot distinguish Tor-forwarded connections from direct connections, which can grant Tor peers unintended IP-based whitelist permissions. ``` same reasoning as in the comment above, wildcard can distinguish.
vasild (Migrated from github.com) commented 2026-10-01 13:03:15 +00:00

The impression is that 127.0.0.1 must be used.

Users should add a specific `-bind=<addr:port>=onion` to accept incoming Tor connections, or set `-listenonion=0` to disable automatic onion service creation.
The impression is that `127.0.0.1` must be used. ```suggestion Users should add a specific `-bind=<addr:port>=onion` to accept incoming Tor connections, or set `-listenonion=0` to disable automatic onion service creation. ```
vasild (Migrated from github.com) commented 2026-10-01 11:38:01 +00:00
    if (args.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION) && !binds.empty() && std::ranges::none_of(binds, [](auto& b) { return b.ends_with("=onion"); })) {
```suggestion if (args.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION) && !binds.empty() && std::ranges::none_of(binds, [](auto& b) { return b.ends_with("=onion"); })) { ```
vasild (Migrated from github.com) commented 2026-10-01 11:45:04 +00:00
        return InitError(_("The automatic Tor onion service requires a dedicated onion bind. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0."));

With this PR the automatic Tor service requires a dedicated bind, always, unconditionally. Not only "when -bind is set".

To clarify - if the user did not set -bind, then the defaults do provide both -bind and -bind=...=onion.

```suggestion return InitError(_("The automatic Tor onion service requires a dedicated onion bind. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0.")); ``` With this PR the automatic Tor service requires a dedicated bind, always, unconditionally. Not only "when -bind is set". To clarify - if the user did not set `-bind`, then the defaults do provide both `-bind` and `-bind=...=onion`.
Lines 2281-2283
vasild (Migrated from github.com) commented 2026-10-01 12:17:16 +00:00

Isn't this check redundant? Seems to be the same as the added check in AppInitParameterInteraction(). Better have just one. I prefer this one because it uses connOptions.onion_binds. The other one manually "parses" the arguments and checks for =onion suffix which is redundant with the code that sets connOptions.onion_binds. That is, if =onion would have to be changed to e.g. to support case insensitive match, then it would have to be changed in two places, not nice.

Isn't this check redundant? Seems to be the same as the added check in `AppInitParameterInteraction()`. Better have just one. I prefer this one because it uses `connOptions.onion_binds`. The other one manually "parses" the arguments and checks for `=onion` suffix which is redundant with the code that sets `connOptions.onion_binds`. That is, if `=onion` would have to be changed to e.g. to support case insensitive match, then it would have to be changed in two places, not nice.
Lines 2284-2286
vasild (Migrated from github.com) commented 2026-10-01 12:24:08 +00:00

This message is technically not correct. If wildcard address is used, incoming Tor connections will still be identified just fine. For example: -bind=1.2.3.4:8333 -bind=0.0.0.0:8334=onion - anything that arrives on port 8334 will be correctly identified as incoming Tor.

The problem, however, is that 0.0.0.0:8334 in addition to being used for binding and classifying connections is also used to instruct the Tor daemon to forward incoming connections to it. And telling the Tor daemon to forward connections to 0.0.0.0:8334 is ill.

So, maybe something like: "The automatic Tor onion service cannot use a wildcard onion bind because the Tor daemon wouldn't be able to forward incoming connections to us. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0."

Or just: "The automatic Tor onion service cannot use a wildcard onion bind. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0."

This message is technically not correct. If wildcard address is used, incoming Tor connections will still be identified just fine. For example: `-bind=1.2.3.4:8333 -bind=0.0.0.0:8334=onion` - anything that arrives on port `8334` will be correctly identified as incoming Tor. The problem, however, is that `0.0.0.0:8334` in addition to being used for binding and classifying connections is also used to instruct the Tor daemon to forward incoming connections to it. And telling the Tor daemon to forward connections to `0.0.0.0:8334` is ill. So, maybe something like: "The automatic Tor onion service cannot use a wildcard onion bind because the Tor daemon wouldn't be able to forward incoming connections to us. Use a specific address such as `-bind=127.0.0.1:<port>=onion`, or disable the service with `-listenonion=0`." Or just: "The automatic Tor onion service cannot use a wildcard onion bind. Use a specific address such as `-bind=127.0.0.1:<port>=onion`, or disable the service with `-listenonion=0`."
vasild (Migrated from github.com) commented 2026-10-01 11:31:08 +00:00
            self.extra_args[2] + ["-listenonion=1", "-torcontrol=127.0.0.1:1"],

(not tested)

```suggestion self.extra_args[2] + ["-listenonion=1", "-torcontrol=127.0.0.1:1"], ``` (not tested)
vasild (Migrated from github.com) commented 2026-10-01 11:32:18 +00:00
        self.restart_node(1, extra_args=self.extra_args[1] + ["-listenonion=1", "-torcontrol=127.0.0.1:1"])

(not tested)

```suggestion self.restart_node(1, extra_args=self.extra_args[1] + ["-listenonion=1", "-torcontrol=127.0.0.1:1"]) ``` (not tested)
First-time contributor

Earlier concerns neither republished nor resolved: 1 major finding · 2 suggestions. See the Run archive linked from the Review report for their assessments.

🔵 Suggestion · -listenonion help omits wildcard-bind startup rejection

The help says proxy discovery remains available without a non-wildcard onion bind, but a wildcard onion bind aborts startup rather than merely disabling service creation.

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

🔵 Suggestion · Skipped services lack a startup notice, and explicit -onion leaves an idle controller

Explicit Tor configurations with only normal -bind settings get no GUI or stderr notice that incoming service creation is skipped; an explicit -onion also leaves the controller with neither service creation nor proxy discovery to perform.

Location: src/torcontrol.cpp:574 (head).

🔵 Suggestion · Default onion forwarding has no mock-controller coverage

The mock-controller tests never exercise the retained no--bind or -whitebind-only path, so they cannot detect losing automatic service creation for those configurations.

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

🔵 Suggestion · IPv6 availability guard skips a socket-independent rejection test

The IPv6 wildcard check needs only numeric address parsing, so test_ipv6_local() unnecessarily skips it on hosts without a route to ::1.

Location: test/functional/feature_bind_extra.py:120 (head).

🔵 Suggestion · Skipped-service coverage omits existing onion identities

The new skipped-service test deletes the cached key first, leaving identity preservation across the recommended bind migration untested; source inspection shows no current key loss.

Location: test/functional/feature_torcontrol.py:219 (head).

🔵 Suggestion · Remote-Tor bind guidance omits access restrictions

The remote-Tor guidance does not warn that exposing a non-loopback =onion listener to other hosts lets direct peers be treated as Tor peers and become eligible for onion self-advertisements.

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


Reviewed: 0dfaa81cca91 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:e1a29e5e677c47d383756f0fcf8f3760725c91d1104dd3ccb2f333b6217eba26:47880f5569fd2047d249266f337c4f2a509adf7d96c3ccb1c7644c2c2a650bff --> <!-- ralph-base:0bc1e88dd332476e143eaee3c74911f4ce91f0a1 --> <!-- ralph-head:0dfaa81cca91f3fd74ef480404f2e4b4de3af899 --> <!-- ralph-case:f3e38fb1c44069be27ca976275c9e91d90a118429d21bd126ac8727b611d250d --> Earlier concerns neither republished nor resolved: 1 major finding · 2 suggestions. See the Run archive linked from the Review report for their assessments. **🔵 Suggestion · `-listenonion` help omits wildcard-bind startup rejection** The help says proxy discovery remains available without a non-wildcard onion bind, but a wildcard onion bind aborts startup rather than merely disabling service creation. Location: [`src/init.cpp:578`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/0dfaa81cca91f3fd74ef480404f2e4b4de3af899/src/init.cpp#L578>) (head). **🔵 Suggestion · Skipped services lack a startup notice, and explicit `-onion` leaves an idle controller** Explicit Tor configurations with only normal `-bind` settings get no GUI or stderr notice that incoming service creation is skipped; an explicit `-onion` also leaves the controller with neither service creation nor proxy discovery to perform. Location: [`src/torcontrol.cpp:574`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/0dfaa81cca91f3fd74ef480404f2e4b4de3af899/src/torcontrol.cpp#L574>) (head). **🔵 Suggestion · Default onion forwarding has no mock-controller coverage** The mock-controller tests never exercise the retained no-`-bind` or `-whitebind`-only path, so they cannot detect losing automatic service creation for those configurations. Location: [`src/init.cpp:2312`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/0dfaa81cca91f3fd74ef480404f2e4b4de3af899/src/init.cpp#L2312>) (head). **🔵 Suggestion · IPv6 availability guard skips a socket-independent rejection test** The IPv6 wildcard check needs only numeric address parsing, so `test_ipv6_local()` unnecessarily skips it on hosts without a route to `::1`. Location: [`test/functional/feature_bind_extra.py:120`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/0dfaa81cca91f3fd74ef480404f2e4b4de3af899/test/functional/feature_bind_extra.py#L120>) (head). **🔵 Suggestion · Skipped-service coverage omits existing onion identities** The new skipped-service test deletes the cached key first, leaving identity preservation across the recommended bind migration untested; source inspection shows no current key loss. Location: [`test/functional/feature_torcontrol.py:219`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/0dfaa81cca91f3fd74ef480404f2e4b4de3af899/test/functional/feature_torcontrol.py#L219>) (head). **🔵 Suggestion · Remote-Tor bind guidance omits access restrictions** The remote-Tor guidance does not warn that exposing a non-loopback `=onion` listener to other hosts lets direct peers be treated as Tor peers and become eligible for onion self-advertisements. Location: [`doc/tor.md:114`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/0dfaa81cca91f3fd74ef480404f2e4b4de3af899/doc/tor.md#L114>) (head). <!-- Review tier: sensitive --> --- Reviewed: [`0dfaa81cca91`](<https://git.fish.foo/bitcoin/bitcoin/commit/0dfaa81cca91f3fd74ef480404f2e4b4de3af899>) · [Review report](<https://review.fish.foo/report/36170-0dfaa81cca91f3fd74ef480404f2e4b4de3af899-3467-8.html>) · [Previous reports](<https://review.fish.foo/traces/36170/>) [permalink](<https://review.fish.foo/report/36170-0dfaa81cca91f3fd74ef480404f2e4b4de3af899-3467-8.html>)
schildbach commented 2026-10-06 14:21:40 +00:00 (Migrated from github.com)

Keep in mind that when running in a container, it is considered best practise to bind to 0.0.0.0 / [::] rather than a specific IP. That is because most container engines (e.g. Docker) use dynamic IPs.

The issue that 0.0.0.0 / [::] are unsuitable to pass via Tor control should imho be solved by a second configuration option, as suggested in https://github.com/bitcoin/bitcoin/issues/25094.

Keep in mind that when running in a container, it is considered best practise to bind to `0.0.0.0` / `[::]` rather than a specific IP. That is because most container engines (e.g. Docker) use dynamic IPs. The issue that `0.0.0.0` / `[::]` are unsuitable to pass via Tor control should imho be solved by a second configuration option, as suggested in https://github.com/bitcoin/bitcoin/issues/25094.
l0rinc (Migrated from github.com) reviewed 2026-10-07 05:30:23 +00:00
Lines 2276-2278
l0rinc (Migrated from github.com) commented 2026-10-07 05:30:23 +00:00

I originally added it to reject the configuration before loading chainstate, but I agree that duplicating the argument parsing just for this case isn’t worth it - removed, thanks

I originally added it to reject the configuration before loading chainstate, but I agree that duplicating the argument parsing just for this case isn’t worth it - removed, thanks
l0rinc (Migrated from github.com) reviewed 2026-10-07 05:40:02 +00:00
l0rinc (Migrated from github.com) left a comment

Addressed @vasild’s suggestions: reused the configured test arguments, removed the duplicate early check, shortened the errors, and clarified the release notes.

The issue that 0.0.0.0 / [::] are unsuitable to pass via Tor control should imho be solved by a second configuration option

I'd keep rejecting these configurations in this PR and handle that support separately. What do you think @vasild?

Addressed @vasild’s suggestions: reused the configured test arguments, removed the duplicate early check, shortened the errors, and clarified the release notes. > The issue that `0.0.0.0` / `[::]` are unsuitable to pass via Tor control should imho be solved by a second configuration option I'd keep rejecting these configurations in this PR and handle that support separately. What do you think @vasild?
l0rinc (Migrated from github.com) commented 2026-10-07 05:32:40 +00:00

I kept "wildcard" here because the IPv4 and IPv6 checks described above both showed misclassification and retained whitelist permissions.

I kept "wildcard" here because the IPv4 and IPv6 checks described above both showed misclassification and retained whitelist permissions.
l0rinc (Migrated from github.com) commented 2026-10-07 05:34:16 +00:00

I prefer non-negated versions, it was deliberate

I prefer non-negated versions, it was deliberate
Lines 2279-2281
l0rinc (Migrated from github.com) commented 2026-10-07 05:31:17 +00:00

Used your shorter version, thanks.

Used your shorter version, thanks.
vasild (Migrated from github.com) reviewed 2026-10-19 09:17:29 +00:00
vasild (Migrated from github.com) commented 2026-10-19 09:17:29 +00:00

Further clarification (thanks for double checking this after an offline chat):

  • Indeed shared binds cannot distinguish incoming Tor vs direct connections. E.g. if we bind on 1.2.3.4:8333 and accept incoming Tor and incoming direct connections on that address and port then we can't distinguish, obviously.

  • If we use a wildcard bind for Tor, e.g. -bind=0.0.0.0:8334=onion, then the problem is slightly different. I got this wrong initially, thanks for correcting me. The wildcard will bind on all addresses of the machine, e.g. 127.0.0.1:8334, 1.2.3.4:8334, 5.6.7.8:8334 and there will be no overlap between those and the direct connections 1.2.3.4:8333. So far so good, but when an incoming Tor connection arrives, we will then compare the address it arrived on e.g. 5.6.7.8:8334 to whatever was given to -bind which is 0.0.0.0:8334 and that will not match 💣. So the connection will be wrongly not considered as an incoming Tor connection. In theory, if we want to fix this:

github.com/bitcoin/bitcoin@6301d464f7/src/net.cpp (L1791)

then we would have to tweak that comparison to "if there is an entry in m_onion_bind that is a wildcard and the port matches to the port in addr_bind, then consider they are equal. I think that is unnecessary.

  • s/Tor-forwarded connections/incoming Tor connections/
Further clarification (thanks for double checking this after an offline chat): * Indeed shared binds cannot distinguish incoming Tor vs direct connections. E.g. if we bind on `1.2.3.4:8333` and accept incoming Tor and incoming direct connections on that address and port then we can't distinguish, obviously. * If we use a wildcard bind for Tor, e.g. `-bind=0.0.0.0:8334=onion`, then the problem is slightly different. I got this wrong initially, thanks for correcting me. The wildcard will bind on all addresses of the machine, e.g. `127.0.0.1:8334`, `1.2.3.4:8334`, `5.6.7.8:8334` and there will be no overlap between those and the direct connections `1.2.3.4:8333`. So far so good, but when an incoming Tor connection arrives, we will then compare the address it arrived on e.g. `5.6.7.8:8334` to whatever was given to `-bind` which is `0.0.0.0:8334` and that will not match :bomb:. So the connection will be wrongly not considered as an incoming Tor connection. In theory, if we want to fix this: https://github.com/bitcoin/bitcoin/blob/6301d464f72d2752867c974e747f7a78b4f8322f/src/net.cpp#L1791 then we would have to tweak that comparison to "if there is an entry in `m_onion_bind` that is a wildcard and the port matches to the port in `addr_bind`, then consider they are equal. I think that is unnecessary. * `s/Tor-forwarded connections/incoming Tor connections/`
vasild (Migrated from github.com) approved these changes 2026-10-19 09:21:47 +00:00
vasild (Migrated from github.com) left a comment

ACK 5527295cb4

The issue that 0.0.0.0 / [::] are unsuitable to pass via Tor control should imho be solved by a second configuration option

IMO it would be an overkill to add one more configuration option to cover this. I think it should be possible to retrieve the IP address that docker assigned to the VM or instruct docker to assign a given one.

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

ACK 5527295cb4b606cc372159cf040acbbe742b91ec

> The issue that `0.0.0.0` / `[::]` are unsuitable to pass via Tor control should imho be solved by a second configuration option

IMO it would be an overkill to add one more configuration option to cover this. I think it should be possible to retrieve the IP address that docker assigned to the VM or instruct docker to assign a given one.
-----BEGIN PGP SIGNATURE-----

iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmrV4QIbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/TN0f/R+EbsI+jQJdDAntyXfC
wWpQ+eFu3j3AC7K/CoYrtVwhPUomeJMOJL8Q8RzZWE7XkdXU7Zu/ey9ezML3m3KD
sKXdTc9YA/d6+MTGHZbReqksTzoX0sWS8ayXjyIpoSB/FtPE2mAvHnCLHXt+ZAtM
DlZbZ1ocGXwxURECUGSwve92lvBnLv6ayS0lrmZPoMvq4kSgw1K9eR6Neqq0VTT6
n2eVYc7Y2eFjCX4RDbXua9AYMoF+15KCXegABF0HzuCek929LaQeQMhrZXMn/3xK
c47752l96wwRTgw3AigbtlwvT4jvlyD1s9jxhgTWRCX4uCWw55NImS5Yab5bsL6+
YqfrsXOiWJ8hkqEcBnYP270iJV51wOOx3F+6a7laFo6fXkw+Sa1O/R0K6zldR/ud
70aVQBVRrp0SxTyz5o4FeIqWEBXmkWTTRTZWU7BW0ZOwlCEMGDZqCb/oA9D8v5t3
7KxdXsWg4rfJpQADr07GYTQO4JaouB+HY+ncpi3M7fXosO/okP2yu8zfyEn+N2zs
TtE67DFJM28m8eCq2Fk1RX26Xjyd/EPpc4TT/WUpaEJrirwxoe6n4yENUC9fEfIW
LNJfbV+n436P59fe7TQxhJDuFLN5N64pqViOPJcO6su2+QK5KnSPdjsMmvmFXSmQ
uVcQgz91Lgh8NfrPTT04Hyj3mMsEkb8UH1qiNz+qCM/OHlWX9nUnT66aPG/b/uzh
IlhWSBJwjDVxWe56H31LmVMFviSIpwZ1XU2J7leYUuFgr+P9wlGlT5BIInPhbuWp
5fznSMTGSpglRH6UgOF5D4v/v9RpmKbmOcqkltjL0TD5xDrOzLXcaEJo7xb5lBTa
rIjMxevrNx/2SFCMtNCtjoezRLexR+/MuDMZMHEAwXf5NmcMnpny5/co07+JHSX1
24KrTq/3xGGiT+iuFU4ZjrY3TsUXpR84PA6nFpBWiVwl+Kkw7USJFt+6W2fc9tQ1
IPgYo6Bho3HYUu/vXdgWCywaD18SZtdUshxi4FBx5XL6qwhv4QVJwzSfB628orDd
Q8aP54a/pQrr+V3j14tHOJqYjIZgXNhyMASgoE0uU5jFDrY90yhIq/oz6siDOf1W
D9VZ1HE9TRVlE2di1RrlmA2DM+gjjLPqFWnKXdPrr3StSa+6819Mgw5sffQO//wb
mYO6mxhvXSGXmqMnbEGWKXaAk56NJL10HLL3t1xtQqBwYY1SdgF6T6DDr1bOh8Qm
MO1DkHELCKZ+QLawGaKkPOIGBTtOlbauANxUd1uuJ9Hka30kjsj4+7+o4Lytpu6B
O/CB0qlkOzeDIIjy9aCTd3lCvIz/4jg3D+7+LqjtRPPxVrw8UoYSA9jOLNV93vtQ
9sw=
=4syh
-----END PGP SIGNATURE-----

vasild's public key is on openpgp.org

ACK 5527295cb4b606cc372159cf040acbbe742b91ec > The issue that `0.0.0.0` / `[::]` are unsuitable to pass via Tor control should imho be solved by a second configuration option IMO it would be an overkill to add one more configuration option to cover this. I think it should be possible to retrieve the IP address that docker assigned to the VM or instruct docker to assign a given one. <details> <summary>Show Signature</summary> ``` -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ACK 5527295cb4b606cc372159cf040acbbe742b91ec > The issue that `0.0.0.0` / `[::]` are unsuitable to pass via Tor control should imho be solved by a second configuration option IMO it would be an overkill to add one more configuration option to cover this. I think it should be possible to retrieve the IP address that docker assigned to the VM or instruct docker to assign a given one. -----BEGIN PGP SIGNATURE----- iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmrV4QIbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/TN0f/R+EbsI+jQJdDAntyXfC wWpQ+eFu3j3AC7K/CoYrtVwhPUomeJMOJL8Q8RzZWE7XkdXU7Zu/ey9ezML3m3KD sKXdTc9YA/d6+MTGHZbReqksTzoX0sWS8ayXjyIpoSB/FtPE2mAvHnCLHXt+ZAtM DlZbZ1ocGXwxURECUGSwve92lvBnLv6ayS0lrmZPoMvq4kSgw1K9eR6Neqq0VTT6 n2eVYc7Y2eFjCX4RDbXua9AYMoF+15KCXegABF0HzuCek929LaQeQMhrZXMn/3xK c47752l96wwRTgw3AigbtlwvT4jvlyD1s9jxhgTWRCX4uCWw55NImS5Yab5bsL6+ YqfrsXOiWJ8hkqEcBnYP270iJV51wOOx3F+6a7laFo6fXkw+Sa1O/R0K6zldR/ud 70aVQBVRrp0SxTyz5o4FeIqWEBXmkWTTRTZWU7BW0ZOwlCEMGDZqCb/oA9D8v5t3 7KxdXsWg4rfJpQADr07GYTQO4JaouB+HY+ncpi3M7fXosO/okP2yu8zfyEn+N2zs TtE67DFJM28m8eCq2Fk1RX26Xjyd/EPpc4TT/WUpaEJrirwxoe6n4yENUC9fEfIW LNJfbV+n436P59fe7TQxhJDuFLN5N64pqViOPJcO6su2+QK5KnSPdjsMmvmFXSmQ uVcQgz91Lgh8NfrPTT04Hyj3mMsEkb8UH1qiNz+qCM/OHlWX9nUnT66aPG/b/uzh IlhWSBJwjDVxWe56H31LmVMFviSIpwZ1XU2J7leYUuFgr+P9wlGlT5BIInPhbuWp 5fznSMTGSpglRH6UgOF5D4v/v9RpmKbmOcqkltjL0TD5xDrOzLXcaEJo7xb5lBTa rIjMxevrNx/2SFCMtNCtjoezRLexR+/MuDMZMHEAwXf5NmcMnpny5/co07+JHSX1 24KrTq/3xGGiT+iuFU4ZjrY3TsUXpR84PA6nFpBWiVwl+Kkw7USJFt+6W2fc9tQ1 IPgYo6Bho3HYUu/vXdgWCywaD18SZtdUshxi4FBx5XL6qwhv4QVJwzSfB628orDd Q8aP54a/pQrr+V3j14tHOJqYjIZgXNhyMASgoE0uU5jFDrY90yhIq/oz6siDOf1W D9VZ1HE9TRVlE2di1RrlmA2DM+gjjLPqFWnKXdPrr3StSa+6819Mgw5sffQO//wb mYO6mxhvXSGXmqMnbEGWKXaAk56NJL10HLL3t1xtQqBwYY1SdgF6T6DDr1bOh8Qm MO1DkHELCKZ+QLawGaKkPOIGBTtOlbauANxUd1uuJ9Hka30kjsj4+7+o4Lytpu6B O/CB0qlkOzeDIIjy9aCTd3lCvIz/4jg3D+7+LqjtRPPxVrw8UoYSA9jOLNV93vtQ 9sw= =4syh -----END PGP SIGNATURE----- ``` vasild's public key is [on openpgp.org](https://keys.openpgp.org/vks/v1/by-fingerprint/850E138BA9C0923881DFD55FCE712013582E2230) </details>
jpk68 commented 2026-10-21 16:29:39 +00:00 (Migrated from github.com)
ACK 5527295cb4b606cc372159cf040acbbe742b91ec
winterrdog (Migrated from github.com) reviewed 2026-10-21 20:14:42 +00:00
winterrdog (Migrated from github.com) left a comment

tACK 5527295cb4

successfully built & tested with clang++-19 on FreeBSD 15.0, targeting x86_64. changes LGTM


since #34892 was closed in favour of this PR (https://github.com/bitcoin/bitcoin/pull/34892#issuecomment-5577081511), i think it makes sense to add a fixes #33458 in the the PR description so that the issue can be closed on merge because this PR actually resolves the issue

tACK 5527295cb4b606cc372159cf040acbbe742b91ec successfully built & tested with `clang++-19` on FreeBSD `15.0`, targeting `x86_64`. changes LGTM --- since #34892 was closed in favour of this PR (https://github.com/bitcoin/bitcoin/pull/34892#issuecomment-5577081511), i think it makes sense to add a `fixes #33458` in the the PR description so that the issue can be closed on merge because this PR actually resolves the issue
sedited commented 2026-11-04 14:54:38 +00:00 (Migrated from github.com)

Because -listenonion is enabled by default when listening, existing configurations with only a normal -bind must also be updated.

I'm not sure about this approach. So any existing deployment that has a single bind, which I think is a common configuration, will now fail to start? That seems harsh to me. How about falling back to the default onion bind if no explicit one is given? Maybe I'm missing something, but wouldn't that match more closely with what would be expected to happen with a default on feature?

> Because -listenonion is enabled by default when listening, existing configurations with only a normal -bind must also be updated. I'm not sure about this approach. So any existing deployment that has a single bind, which I think is a common configuration, will now fail to start? That seems harsh to me. How about falling back to the default onion bind if no explicit one is given? Maybe I'm missing something, but wouldn't that match more closely with what would be expected to happen with a default on feature?
vasild commented 2026-11-04 18:49:58 +00:00 (Migrated from github.com)

So any existing deployment that has a single bind, which I think is a common configuration

Shouldn't be because that is flawed because then incoming IP and Tor cannot be distinguished. But I have no idea how widespread it is.

will now fail to start?

Right.

That seems harsh to me.

I agree, it is.

Like a wake up call "fix your config!"

How about falling back to the default onion bind if no explicit one is given? Maybe I'm missing something, but wouldn't that match more closely with what would be expected to happen with a default on feature?

Note that then there is no way to disable the Tor bind. Right now we have:

  • by default both IP and Tor bind (if the user specifies no options)
  • if the user specifies only IP bind then we bind for IP only
  • if the user specifies both IP bind and Tor bind then we bind for both.

I think that is logical and is a natural way to disable the Tor bind. By IP bind I mean -bind= and by Tor bind I mean -bind=...=onion.

I agree it is harsh. I think it is acceptable though. But if others find it unacceptable, then it is unacceptable. What other ways might be, hmm...

> So any existing deployment that has a single bind, which I think is a common configuration Shouldn't be because that is flawed because then incoming IP and Tor cannot be distinguished. But I have no idea how widespread it is. > will now fail to start? Right. > That seems harsh to me. I agree, it is. Like a wake up call "fix your config!" > How about falling back to the default onion bind if no explicit one is given? Maybe I'm missing something, but wouldn't that match more closely with what would be expected to happen with a default on feature? Note that then there is no way to disable the Tor bind. Right now we have: * by default both IP and Tor bind (if the user specifies no options) * if the user specifies only IP bind then we bind for IP only * if the user specifies both IP bind and Tor bind then we bind for both. I think that is logical and is a natural way to disable the Tor bind. By IP bind I mean `-bind=` and by Tor bind I mean `-bind=...=onion`. I agree it is harsh. I think it is acceptable though. But if others find it unacceptable, then it is unacceptable. What other ways might be, hmm...
vasild commented 2026-11-05 05:33:41 +00:00 (Migrated from github.com)

So, the problem is if -listenonion=1 and only -bind= is used without -bind=...=onion. Then we tell the Tor daemon to forward incoming Tor connections to our normal bind and we cannot distinguish those from incoming IP connections.

Some ideas, if the current approach seems unacceptable:

  • Log a startup warning and still end up in a state where IP and Tor incomings cannot be distinguished. A warning in the GUI as a pop up window will be noticed, but bitcoind users with only a warning in the log will probably miss it.

  • Brick only the Tor listening service. That is - allow start but refuse to create the Tor listening service and log a warning periodically, like:

-listenonion is enabled but the Tor listening service was not created because there is no separate -bind=...=onion. To accept incoming Tor connections either remove the explicit -bind= which you have used (that will enable the default -bind=127.0.0.1:8334=onion) or add an explicit -bind=...=onion to your config.

Might result the node operating in semi-degraded state for a long time before the user notices they have no incoming Tor connections and starts investigating. I still like more the refuse-to-start approach because it is obvious.

So, the problem is if `-listenonion=1` and only `-bind=` is used without `-bind=...=onion`. Then we tell the Tor daemon to forward incoming Tor connections to our normal bind and we cannot distinguish those from incoming IP connections. Some ideas, if the current approach seems unacceptable: * Log a startup warning and still end up in a state where IP and Tor incomings cannot be distinguished. A warning in the GUI as a pop up window will be noticed, but `bitcoind` users with only a warning in the log will probably miss it. * Brick only the Tor listening service. That is - allow start but refuse to create the Tor listening service and log a warning periodically, like: > -listenonion is enabled but the Tor listening service was not created because there is no separate -bind=...=onion. To accept incoming Tor connections either remove the explicit -bind= which you have used (that will enable the default -bind=127.0.0.1:8334=onion) or add an explicit -bind=...=onion to your config. Might result the node operating in semi-degraded state for a long time before the user notices they have no incoming Tor connections and starts investigating. I still like more the refuse-to-start approach because it is obvious.
vasild commented 2026-11-05 08:45:32 +00:00 (Migrated from github.com)

The root problem here is that there are two options that have to be set together: if -listenonion is set, then -bind=...=onion must also be set. And we are trying to handle the cases in which the later is not set. That is a bad interface.

A good interface is impossible to misuse.

So, what about another idea: the name of the option -listenonion is very confusing. I have always wished to do something about it ever since I grasped what it does. What it does is to automatically create the Tor service. It has nothing to do with listening, as in -bind. We might accept incoming Tor connections without it as well, if the Tor service is statically configured inside the Tor daemon, in torrc.

So, what about replacing -listenonion with -bind=addr:port=onionauto? Note that in order to enable the auto Tor service creation, now one must specify a bind address and port. It is bundled together, impossible to misuse. Currently one can enable auto Tor service without specifying the listening address:port and that is a problem.

old new
-listenonion=0 don't specify -bind=addr:port=onionauto
-listenonion=1 -bind=addr:port=onionauto

The old default is as if -listenonion=1 -bind=0.0.0.0:8333 -bind=127.0.0.1:8334=onion were given. The new one will be as if -bind=0.0.0.0:8333 -bind=127.0.0.1:8334=onionauto were given.

What about the problematic case where the user has only explicitly set -bind=addr:port and has inherited the default -listenonion=1 (and thus cannot distinguish incoming IP from Tor)? In the new variant with only an explicit -bind=addr:port and without an explicit -bind=addr:port=onionauto the Tor service will not be created.

The root problem here is that there are two options that have to be set together: if `-listenonion` is set, then `-bind=...=onion` must also be set. And we are trying to handle the cases in which the later is not set. That is a bad interface. **A good interface is impossible to misuse.** So, what about another idea: the name of the option `-listenonion` is very confusing. I have always wished to do something about it ever since I grasped what it does. What it does is to automatically create the Tor service. It has nothing to do with listening, as in `-bind`. We might accept incoming Tor connections without it as well, if the Tor service is statically configured inside the Tor daemon, in `torrc`. So, what about replacing `-listenonion` with `-bind=addr:port=onionauto`? Note that in order to enable the auto Tor service creation, now one must specify a bind address and port. It is bundled together, impossible to misuse. Currently one can enable auto Tor service without specifying the listening address:port and that is a problem. old | new ---|--- `-listenonion=0` | don't specify `-bind=addr:port=onionauto` `-listenonion=1` | `-bind=addr:port=onionauto` The old default is as if `-listenonion=1 -bind=0.0.0.0:8333 -bind=127.0.0.1:8334=onion` were given. The new one will be as if `-bind=0.0.0.0:8333 -bind=127.0.0.1:8334=onionauto` were given. What about the problematic case where the user has only explicitly set `-bind=addr:port` and has inherited the default `-listenonion=1` (and thus cannot distinguish incoming IP from Tor)? In the new variant with only an explicit `-bind=addr:port` and without an explicit `-bind=addr:port=onionauto` the Tor service will not be created.
sedited commented 2026-11-06 11:25:49 +00:00 (Migrated from github.com)

Shouldn't be because that is flawed because then incoming IP and Tor cannot be distinguished. But I have no idea how widespread it is.

Doing a cursory search, singular binds in general seem very common, it's even on the bitcoin wiki. I did find a couple of deployment configurations that don't include tor and set a single bind (1, 2).

Brick only the Tor listening service. That is - allow start but refuse to create the Tor listening service and log a warning periodically, like:

I don't see why we would necessarily have to brick it. Wouldn't using the current default bind if not onion bind is provided just continue working for most deployments?

> Shouldn't be because that is flawed because then incoming IP and Tor cannot be distinguished. But I have no idea how widespread it is. Doing a cursory search, singular binds in general seem very common, it's even on the bitcoin wiki. I did find a couple of deployment configurations that don't include tor and set a single bind ([1](https://github.com/bitaps-com/bitcoin-core), [2](https://github.com/fooock/bitcoind-ansible/blob/main/templates/bitcoin.conf.j2)). > Brick only the Tor listening service. That is - allow start but refuse to create the Tor listening service and log a warning periodically, like: I don't see why we would necessarily have to brick it. Wouldn't using the current default bind if not onion bind is provided just continue working for most deployments?
vasild commented 2026-11-06 14:21:54 +00:00 (Migrated from github.com)

Wouldn't using the current default bind if not onion bind is provided just continue working for most deployments?

That is to ditch this PR? Then leave the problem it tries to resolve opened, from the OP:

Problem: When the automatic onion service has no dedicated -bind==onion, Tor forwards incoming connections to the first normal P2P bind. ... network classification is incorrect and Tor peers may inherit permissions granted to the Tor daemon's IP address.

FWIW I considered this fine (to not be able to distinguish incoming Tor from IP), but I didn't think it would be widespread. It is a misconfiguration. And then AIs came and told us this this dangerous and I kind of agree to some extent...

> Wouldn't using the current default bind if not onion bind is provided just continue working for most deployments? That is to ditch this PR? Then leave the problem it tries to resolve opened, from the OP: > Problem: When the automatic onion service has no dedicated -bind=<addr>=onion, Tor forwards incoming connections to the first normal P2P bind. ... network classification is incorrect and Tor peers may inherit permissions granted to the Tor daemon's IP address. FWIW I considered this fine (to not be able to distinguish incoming Tor from IP), but I didn't think it would be widespread. It is a misconfiguration. And then AIs came and told us this this dangerous and I kind of agree to some extent...
sedited commented 2026-11-12 12:43:18 +00:00 (Migrated from github.com)

That is to ditch this PR? Then leave the problem it tries to resolve opened, from the OP:

I'm not suggesting doing nothing. Maybe I'm not quite following the actual problems, but what I'm suggesting is basically along the lines of adding -bind=127.0.0.1:<-port+1>=onion internally whenever a non-onion bind at port is detected in combination with -listenonion and no onion bind is given. Could also combine this with a warning that they should set their onion bind explicitly. I'm also not really sold whether to call this a misconfiguration, or a bug on our side.

> That is to ditch this PR? Then leave the problem it tries to resolve opened, from the OP: I'm not suggesting doing nothing. Maybe I'm not quite following the actual problems, but what I'm suggesting is basically along the lines of adding `-bind=127.0.0.1:<-port+1>=onion` internally whenever a non-onion bind at port is detected in combination with `-listenonion` and no onion bind is given. Could also combine this with a warning that they should set their onion bind explicitly. I'm also not really sold whether to call this a misconfiguration, or a bug on our side.
l0rinc commented 2026-11-13 17:52:53 +00:00 (Migrated from github.com)

Requested comments on IRC:

RFC for #36170: Tor peers sharing a normal bind can inherit IP-based whitelist permissions.
Should we add a default onion listener (see https://github.com/bitcoin/bitcoin/pull/36170#issuecomment-6823929169), refuse startup (current PR), or warn and skip service creation?
Refusal affects non-Tor setups because -listenonion defaults on - adding a listener changes explicit bind behavior (and maybe risks port conflicts).

Requested comments on [IRC](https://bitcoin-irc.chaincode.com/bitcoin-core-dev/2026-11-13#1274242): > RFC for #36170: Tor peers sharing a normal bind can inherit IP-based whitelist permissions. Should we add a default onion listener (see https://github.com/bitcoin/bitcoin/pull/36170#issuecomment-6823929169), refuse startup (current PR), or warn and skip service creation? Refusal affects non-Tor setups because -listenonion defaults on - adding a listener changes explicit bind behavior (and maybe risks port conflicts).
hodlinator commented 2026-11-13 21:28:00 +00:00 (Migrated from github.com)

Wonder if we can navigate this issue through only failing during startup if:
-listenonion AND -bind=IP AND -whitelist has been set.
E.g., if this only is an issue when differing permissions are set for different IPs and adjusting permissions is not common, then this should catch the cases we worry about, while letting harmless & common cases continue.

But maybe I'm missing some detail, I've just had a first look.
(This idea was also communicated out of band with l0rinc).

Wonder if we can navigate this issue through only failing during startup if: `-listenonion` AND `-bind=IP` AND `-whitelist` has been set. E.g., if this *only* is an issue when differing permissions are set for different IPs *and* adjusting permissions is not common, then this should catch the cases we worry about, while letting harmless & common cases continue. But maybe I'm missing some detail, I've just had a first look. (This idea was also communicated out of band with l0rinc).
mzumsande (Migrated from github.com) reviewed 2026-11-16 15:04:09 +00:00
mzumsande (Migrated from github.com) left a comment

I agree with sedited that this solution, which makes non-tor users of -bind change their setup by changing a tor-related config option set by default is not great. They haven't misconfigured anything, and it is not their fault that -listenonion is enabled by default if they don't use it or even know about it, so they should not be expected to turn it off.

My favourite short-term solution would be to do what vasild mentioned ("Brick only the Tor listening service"). We could log a warning in torcontrol, but could still have tor outbounds with torcontrol.
Having inbounds is, for the most part, a service to the network, and unlike on clearnet, inbound capacity isn't scarce on the tor network, so a couple of nodes not having inbounds anymore until they fix their config wouldn't be a major problem in my opinion.

As a long-term solution, I would agree that replacing -listenonion makes sense, but that would require every tor user to change their config, so is not easily done.

"-listenonion AND -bind=IP AND -whitelist has been set." would work, but it feels a little bit like a hack to me to disallow a certain combination of options that are not really related logically.

I agree with sedited that this solution, which makes non-tor users of `-bind` change their setup by changing a tor-related config option set by default is not great. They haven't misconfigured anything, and it is not their fault that `-listenonion` is enabled by default if they don't use it or even know about it, so they should not be expected to turn it off. My favourite short-term solution would be to do what vasild mentioned ("Brick only the Tor listening service"). We could log a warning in torcontrol, but could still have tor outbounds with torcontrol. Having inbounds is, for the most part, a service to the network, and unlike on clearnet, inbound capacity isn't scarce on the tor network, so a couple of nodes not having inbounds anymore until they fix their config wouldn't be a major problem in my opinion. As a long-term solution, I would agree that replacing `-listenonion` makes sense, but that would require every tor user to change their config, so is not easily done. "-listenonion AND -bind=IP AND -whitelist has been set." would work, but it feels a little bit like a hack to me to disallow a certain combination of options that are not really related logically.
l0rinc commented 2026-11-17 11:23:08 +00:00 (Migrated from github.com)

Thanks for the reviews and discussions!

Rebased and pushed, a missing dedicated onion bind now disables only automatic incoming service creation instead of preventing startup, preserving the configured listeners and outbound proxy discovery.
The controller warns after authentication so affected Tor users can add an explicit =onion bind to restore incoming connections.

Tor control now waits for successful binding before requesting a service, and wildcard onion binds remain rejected with -listenonion enabled.
To simplify review, refactors/characterization tests remain separate from behavior fixes (and their matching test updates), with documentation and comments last.

Thanks for the reviews and discussions! Rebased and pushed, a missing dedicated onion bind now [disables only automatic incoming service creation](https://github.com/bitcoin/bitcoin/pull/36170#pullrequestreview-5922188056) instead of preventing startup, preserving the configured listeners and outbound proxy discovery. The controller warns after authentication so affected Tor users can add an explicit `=onion` bind to restore incoming connections. Tor control now waits for successful binding before requesting a service, and wildcard onion binds remain rejected with `-listenonion` enabled. To simplify review, refactors/characterization tests remain separate from behavior fixes (and their matching test updates), with documentation and comments last.
DrahtBot commented 2026-11-21 01:20:39 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
l0rinc commented 2026-11-24 12:22:22 +00:00 (Migrated from github.com)

Rebased after #36637: its new -torpassword test now sets an explicit onion bind so it can verify that successful authentication leads to onion service creation.

Rebased after #36637: its new `-torpassword` test now sets an explicit onion bind so it can verify that successful authentication leads to onion service creation.
DrahtBot commented 2026-12-02 16:06:20 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
l0rinc commented 2026-12-03 09:37:41 +00:00 (Migrated from github.com)

Rebase after #36759

Rebase after #36759
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36170
No description provided.